Skip to content

Commit 982dd47

Browse files
Maullerroossienb
andcommitted
[ZH] Add extra allocateInfo checks within internal_findHierarchicalPath() and processHierarchicalCell()
Co-authored-by: Bart Roossien <roossienb@users.noreply.github.com>
1 parent ac23a95 commit 982dd47

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7449,7 +7449,7 @@ void Pathfinder::processHierarchicalCell( const ICoord2D &scanCell, const ICoord
74497449
}
74507450

74517451
newCell->allocateInfo(scanCell);
7452-
if (!newCell->getClosed() && !newCell->getOpen()) {
7452+
if (newCell->hasInfo() && !newCell->getClosed() && !newCell->getOpen()) {
74537453
m_closedList = newCell->putOnClosedList(m_closedList);
74547454
}
74557455

@@ -7607,7 +7607,11 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
76077607
// Close parent cell;
76087608
m_openList = parentCell->removeFromOpenList(m_openList);
76097609
m_closedList = parentCell->putOnClosedList(m_closedList);
7610-
startCell->allocateInfo(ndx);
7610+
if (!startCell->allocateInfo(ndx)) {
7611+
cleanOpenAndClosedLists();
7612+
goalCell->releaseInfo();
7613+
return NULL;
7614+
}
76117615
startCell->setParentCellHierarchical(parentCell);
76127616
cellCount++;
76137617
Int curCost = startCell->costToHierGoal(parentCell);
@@ -7619,7 +7623,11 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
76197623
m_openList = startCell->putOnSortedOpenList( m_openList );
76207624

76217625
cellCount++;
7622-
cell->allocateInfo(toNdx);
7626+
if(!cell->allocateInfo(toNdx)) {
7627+
cleanOpenAndClosedLists();
7628+
goalCell->releaseInfo();
7629+
return NULL;
7630+
}
76237631
curCost = cell->costToHierGoal(parentCell);
76247632
remCost = cell->costToHierGoal(goalCell);
76257633
cell->setCostSoFar(curCost);
@@ -7703,13 +7711,21 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
77037711
PathfindCell *startCell = getCell(LAYER_GROUND, ndx.x, ndx.y);
77047712
if (startCell==NULL) continue;
77057713
if (startCell != parentCell) {
7706-
startCell->allocateInfo(ndx);
7714+
if(!startCell->allocateInfo(ndx)) {
7715+
cleanOpenAndClosedLists();
7716+
goalCell->releaseInfo();
7717+
return NULL;
7718+
}
77077719
startCell->setParentCellHierarchical(parentCell);
77087720
if (!startCell->getClosed() && !startCell->getOpen()) {
77097721
m_closedList = startCell->putOnClosedList(m_closedList);
77107722
}
77117723
}
7712-
cell->allocateInfo(toNdx);
7724+
if(!cell->allocateInfo(toNdx)) {
7725+
cleanOpenAndClosedLists();
7726+
goalCell->releaseInfo();
7727+
return NULL;
7728+
}
77137729
cell->setParentCellHierarchical(startCell);
77147730

77157731
cellCount++;

0 commit comments

Comments
 (0)