diff --git a/Core/GameEngine/Include/GameLogic/AIPathfind.h b/Core/GameEngine/Include/GameLogic/AIPathfind.h index a6bf147af31..2a2767945b5 100644 --- a/Core/GameEngine/Include/GameLogic/AIPathfind.h +++ b/Core/GameEngine/Include/GameLogic/AIPathfind.h @@ -904,6 +904,11 @@ class Pathfinder : PathfindServicesInterface, public Snapshot Int m_queuePRHead; Int m_queuePRTail; Int m_cumulativeCellsAllocated; + +#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 0da5bc24120..ea79ca66341 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -4020,6 +4020,10 @@ void Pathfinder::reset() s_useFixedPathfinding = false; s_forceCleanCells = false; #endif + +#if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC + m_classifyFenceZeroInit = false; +#endif } /** @@ -4159,10 +4163,18 @@ 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. - cellBounds.hi.x = 253961804; - cellBounds.hi.y = 4202797; + // 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; + cellBounds.hi.y = 0; + } + else + { + 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..4caf59c8e85 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp @@ -2489,6 +2489,11 @@ 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 + for( ObjectPointerListIterator iterator = m_objectsToDestroy.begin(); iterator != m_objectsToDestroy.end(); iterator++ ) { Object* currentObject = (*iterator); @@ -2547,6 +2552,10 @@ void GameLogic::processDestroyList() removeObjectFromLookupTable( currentObject ); Object::friend_deleteInstance(currentObject);//actual delete + +#if RTS_ZEROHOUR && 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