Skip to content

Commit 631b78b

Browse files
author
Bart Roossien
committed
Clearing more cells to ensure a clean slate before the next pathfinding starts
1 parent 6ec72b1 commit 631b78b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,14 @@ Bool PathfindCell::allocateInfo( const ICoord2D &pos )
12971297
*/
12981298
void PathfindCell::releaseInfo( void )
12991299
{
1300+
@TheSuperHackers @info 04/06/2025 Skyaero/Mauller
1301+
// Parent cells don't always gets cleared if one of the conditions below is true.
1302+
// But they should be cleared anyway, otherwise future path
1303+
// generation could yield an invalid path, causing a application crash.
1304+
if (m_info && m_info->m_pathParent) {
1305+
m_info->m_pathParent = NULL;
1306+
}
1307+
13001308
if (m_type==PathfindCell::CELL_OBSTACLE) {
13011309
return;
13021310
}
@@ -7525,6 +7533,7 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
75257533
PathfindLayerEnum layer = TheTerrainLogic->getLayerForDestination(from);
75267534
PathfindCell *parentCell = getClippedCell( layer,&clipFrom );
75277535
if (parentCell == NULL) {
7536+
goalCell->releaseInfo();
75287537
return NULL;
75297538
}
75307539
if (parentCell!=goalCell) {
@@ -8812,6 +8821,7 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
88128821
if (parentCell!=goalCell) {
88138822
worldToCell(&clipFrom, &pos2d);
88148823
if (!parentCell->allocateInfo(pos2d)) {
8824+
goalCell->releaseInfo();
88158825
return NULL;
88168826
}
88178827
}

0 commit comments

Comments
 (0)