From 73f3efd97b1feb9b3578b56b6d61782373ebc568 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sun, 15 Mar 2026 12:10:27 +0100 Subject: [PATCH 1/3] Added specialized initialization classifyFence. --- .../GameEngine/Include/GameLogic/AIPathfind.h | 5 +++++ .../Source/GameLogic/AI/AIPathfind.cpp | 17 +++++++++++++++-- .../Source/GameLogic/System/GameLogic.cpp | 8 ++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPathfind.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPathfind.h index 4d2177adfd4..a6ed9631e67 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPathfind.h +++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPathfind.h @@ -896,6 +896,11 @@ class Pathfinder : PathfindServicesInterface, public Snapshot Int m_queuePRHead; Int m_queuePRTail; Int m_cumulativeCellsAllocated; + +#if RETAIL_COMPATIBLE_CRC +public: + Bool m_classifyFenceZeroInit; +#endif }; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index b92934e854a..e6860752d4e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3972,6 +3972,10 @@ void Pathfinder::reset() s_useFixedPathfinding = false; s_forceCleanCells = false; #endif + +#if RETAIL_COMPATIBLE_CRC + m_classifyFenceZeroInit = false; +#endif } /** @@ -4113,8 +4117,17 @@ void Pathfinder::classifyFence( Object *obj, Bool insert ) // 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; + if (m_classifyFenceZeroInit) + { + cellBounds.hi.x = 0; + cellBounds.hi.y = 0; + } + else + { + // the value just needs to be larger than the width and height of m_map + cellBounds.hi.x = 1000000; + cellBounds.hi.y = 1000000; + } #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); diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 1d671f180f5..355b0f4dd4f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2489,6 +2489,10 @@ void GameLogic::processDestroyList() { //USE_PERF_TIMER(processDestroyList) +#if RETAIL_COMPATIBLE_CRC + TheAI->pathfinder()->m_classifyFenceZeroInit = !m_objectsToDestroy.empty(); +#endif + for( ObjectPointerListIterator iterator = m_objectsToDestroy.begin(); iterator != m_objectsToDestroy.end(); iterator++ ) { Object* currentObject = (*iterator); @@ -2547,6 +2551,10 @@ void GameLogic::processDestroyList() removeObjectFromLookupTable( currentObject ); Object::friend_deleteInstance(currentObject);//actual delete + +#if RETAIL_COMPATIBLE_CRC + TheAI->pathfinder()->m_classifyFenceZeroInit = false; +#endif } m_objectsToDestroy.clear();//list full of bad pointers now, clear it. If anyone's deletion resulted From d0cee67395b6dd90ed0beabe710ade5fc2c88015 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Mon, 16 Mar 2026 00:26:42 +0100 Subject: [PATCH 2/3] Added Zero Hour macros. --- Core/GameEngine/Include/GameLogic/AIPathfind.h | 2 +- Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | 2 +- .../Code/GameEngine/Source/GameLogic/System/GameLogic.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/GameEngine/Include/GameLogic/AIPathfind.h b/Core/GameEngine/Include/GameLogic/AIPathfind.h index caa6f0309c4..2a2767945b5 100644 --- a/Core/GameEngine/Include/GameLogic/AIPathfind.h +++ b/Core/GameEngine/Include/GameLogic/AIPathfind.h @@ -905,7 +905,7 @@ class Pathfinder : PathfindServicesInterface, public Snapshot Int m_queuePRTail; Int m_cumulativeCellsAllocated; -#if RETAIL_COMPATIBLE_CRC +#if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC public: Bool m_classifyFenceZeroInit; #endif diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index b2213c0855c..034c41eb559 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -4021,7 +4021,7 @@ void Pathfinder::reset() s_forceCleanCells = false; #endif -#if RETAIL_COMPATIBLE_CRC +#if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC m_classifyFenceZeroInit = false; #endif } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 355b0f4dd4f..4519e39b326 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2489,7 +2489,7 @@ void GameLogic::processDestroyList() { //USE_PERF_TIMER(processDestroyList) -#if RETAIL_COMPATIBLE_CRC +#if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC TheAI->pathfinder()->m_classifyFenceZeroInit = !m_objectsToDestroy.empty(); #endif @@ -2552,7 +2552,7 @@ void GameLogic::processDestroyList() Object::friend_deleteInstance(currentObject);//actual delete -#if RETAIL_COMPATIBLE_CRC +#if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC TheAI->pathfinder()->m_classifyFenceZeroInit = false; #endif } From 0d06c98abbac4c9d1d9f2d791b8a43ee887d6f2c Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:52:04 +0100 Subject: [PATCH 3/3] Tweaked comments. --- Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | 5 ++--- .../Code/GameEngine/Source/GameLogic/System/GameLogic.cpp | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 034c41eb559..ea79ca66341 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -4163,8 +4163,8 @@ void Pathfinder::classifyFence( Object *obj, Bool insert ) #if RETAIL_COMPATIBLE_CRC //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. + // For retail the values on the stack are often either 0 or larger than the map size. + // We initialize them to reduce the likelihood of a mismatch. if (m_classifyFenceZeroInit) { cellBounds.hi.x = 0; @@ -4172,7 +4172,6 @@ void Pathfinder::classifyFence( Object *obj, Bool insert ) } else { - // the value just needs to be larger than the width and height of m_map cellBounds.hi.x = 1000000; cellBounds.hi.y = 1000000; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp index 4519e39b326..4caf59c8e85 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2490,6 +2490,7 @@ void GameLogic::processDestroyList() //USE_PERF_TIMER(processDestroyList) #if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC + // TheSuperHackers @info Set m_classifyFenceZeroInit to true for the first object. It's set to false when this function exits. TheAI->pathfinder()->m_classifyFenceZeroInit = !m_objectsToDestroy.empty(); #endif