Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Core/GameEngine/Include/GameLogic/AIPathfind.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};


Expand Down
20 changes: 16 additions & 4 deletions Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4020,6 +4020,10 @@ void Pathfinder::reset()
s_useFixedPathfinding = false;
s_forceCleanCells = false;
#endif

#if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC
m_classifyFenceZeroInit = false;
#endif
}

/**
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is no early return, won't it always be set to false after exiting processDestoryList()?

Copy link
Author

@Caball009 Caball009 Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_classifyFenceZeroInit should be false after processDestoryList, so that's intended.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could do

processDestoryList()
{
  TheAI->pathfinder()->m_classifyFenceZeroInit = true;

  ... // loop code

  TheAI->pathfinder()->m_classifyFenceZeroInit = false;
}

but that adds more bloat imo.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay i see it now, i was missing the bit where removeObjectFromPathfindMap is getting called in an objects destructor().

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be good to comment that here since it looks strange doing this otherwise.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair; done.

#endif

for( ObjectPointerListIterator iterator = m_objectsToDestroy.begin(); iterator != m_objectsToDestroy.end(); iterator++ )
{
Object* currentObject = (*iterator);
Expand Down Expand Up @@ -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
Expand Down
Loading