From f5280c024d98bd52e4deae14709d7b43a01286fa Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Sat, 25 Oct 2025 21:30:59 +0200 Subject: [PATCH 1/2] Fix uninitialized variables in VC6 builds and possible source of mismatches. --- .../Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 4b2626e74c5..6041e17633b 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3866,8 +3866,11 @@ void Pathfinder::classifyFence( Object *obj, Bool insert ) cellBounds.lo.x = REAL_TO_INT_FLOOR((pos->x + 0.5f)/PATHFIND_CELL_SIZE_F); cellBounds.lo.y = REAL_TO_INT_FLOOR((pos->y + 0.5f)/PATHFIND_CELL_SIZE_F); // TheSuperHackers @fix Mauller 16/06/2025 Fixes uninitialized variables. - // To keep retail compatibility they need to be uninitialized in VC6 builds. -#if !(defined(_MSC_VER) && _MSC_VER < 1300) + // To keep retail compatibility they need to be set to 0 in VC6 builds. +#if RETAIL_COMPATIBLE_CRC + cellBounds.hi.x = 0; + cellBounds.hi.y = 0; +#else cellBounds.hi.x = REAL_TO_INT_CEIL((pos->x + 0.5f)/PATHFIND_CELL_SIZE_F); cellBounds.hi.y = REAL_TO_INT_CEIL((pos->y + 0.5f)/PATHFIND_CELL_SIZE_F); #endif From 292d2b909f3a7029d13a8137c6ae81c67deb2965 Mon Sep 17 00:00:00 2001 From: Helmut Buhler Date: Sat, 25 Oct 2025 22:23:05 +0200 Subject: [PATCH 2/2] Set values to numbers that are likely in the retail version. --- .../Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 6041e17633b..c2927794824 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3866,10 +3866,13 @@ void Pathfinder::classifyFence( Object *obj, Bool insert ) cellBounds.lo.x = REAL_TO_INT_FLOOR((pos->x + 0.5f)/PATHFIND_CELL_SIZE_F); cellBounds.lo.y = REAL_TO_INT_FLOOR((pos->y + 0.5f)/PATHFIND_CELL_SIZE_F); // TheSuperHackers @fix Mauller 16/06/2025 Fixes uninitialized variables. - // To keep retail compatibility they need to be set to 0 in VC6 builds. #if RETAIL_COMPATIBLE_CRC - cellBounds.hi.x = 0; - cellBounds.hi.y = 0; + //CRCDEBUG_LOG(("Pathfinder::classifyFence - (%d,%d)", cellBounds.hi.x, cellBounds.hi.y)); + + // In retail, the values in the stack often look like this. We set them + // to reduce the likelihood of mismatch. + cellBounds.hi.x = 253961804; + cellBounds.hi.y = 4202797; #else cellBounds.hi.x = REAL_TO_INT_CEIL((pos->x + 0.5f)/PATHFIND_CELL_SIZE_F); cellBounds.hi.y = REAL_TO_INT_CEIL((pos->y + 0.5f)/PATHFIND_CELL_SIZE_F);