Skip to content

Commit 28f4fe6

Browse files
authored
fix(pathfinder): Fix CRC computation of PathFinder::m_wallPieces (#2575)
1 parent 5692462 commit 28f4fe6

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11338,10 +11338,20 @@ void Pathfinder::crc( Xfer *xfer )
1133811338

1133911339
xfer->xferInt(&m_numWallPieces);
1134011340
CRCDEBUG_LOG(("m_numWallPieces: %8.8X", ((XferCRC *)xfer)->getCRC()));
11341-
for (Int i=0; i<MAX_WALL_PIECES; ++i)
11341+
11342+
#if RETAIL_COMPATIBLE_CRC
11343+
// TheSuperHackers @fix The original code effectively accessed m_numWallPieces 128 times,
11344+
// because it used &m_wallPieces[MAX_WALL_PIECES] which is out-of-bounds and points to m_numWallPieces.
11345+
static_assert(sizeof(Int) == sizeof(ObjectID), "Type sizes must be equal for correct xfer");
11346+
11347+
for (Int i = 0; i < MAX_WALL_PIECES; ++i)
1134211348
{
11343-
xfer->xferObjectID(&m_wallPieces[MAX_WALL_PIECES]);
11349+
xfer->xferInt(&m_numWallPieces);
1134411350
}
11351+
#else
11352+
xfer->xferUser(m_wallPieces, sizeof(m_wallPieces));
11353+
#endif
11354+
1134511355
CRCDEBUG_LOG(("m_wallPieces: %8.8X", ((XferCRC *)xfer)->getCRC()));
1134611356

1134711357
xfer->xferReal(&m_wallHeight);

0 commit comments

Comments
 (0)