Skip to content

Commit 151ef8e

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 17af495 commit 151ef8e

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
@@ -7430,7 +7430,7 @@ void Pathfinder::processHierarchicalCell( const ICoord2D &scanCell, const ICoord
74307430
}
74317431

74327432
newCell->allocateInfo(scanCell);
7433-
if (!newCell->getClosed() && !newCell->getOpen()) {
7433+
if (newCell->hasInfo() && !newCell->getClosed() && !newCell->getOpen()) {
74347434
m_closedList = newCell->putOnClosedList(m_closedList);
74357435
}
74367436

@@ -7588,7 +7588,11 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
75887588
// Close parent cell;
75897589
m_openList = parentCell->removeFromOpenList(m_openList);
75907590
m_closedList = parentCell->putOnClosedList(m_closedList);
7591-
startCell->allocateInfo(ndx);
7591+
if (!startCell->allocateInfo(ndx)) {
7592+
cleanOpenAndClosedLists();
7593+
goalCell->releaseInfo();
7594+
return NULL;
7595+
}
75927596
startCell->setParentCellHierarchical(parentCell);
75937597
cellCount++;
75947598
Int curCost = startCell->costToHierGoal(parentCell);
@@ -7600,7 +7604,11 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
76007604
m_openList = startCell->putOnSortedOpenList( m_openList );
76017605

76027606
cellCount++;
7603-
cell->allocateInfo(toNdx);
7607+
if(!cell->allocateInfo(toNdx)) {
7608+
cleanOpenAndClosedLists();
7609+
goalCell->releaseInfo();
7610+
return NULL;
7611+
}
76047612
curCost = cell->costToHierGoal(parentCell);
76057613
remCost = cell->costToHierGoal(goalCell);
76067614
cell->setCostSoFar(curCost);
@@ -7684,13 +7692,21 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
76847692
PathfindCell *startCell = getCell(LAYER_GROUND, ndx.x, ndx.y);
76857693
if (startCell==NULL) continue;
76867694
if (startCell != parentCell) {
7687-
startCell->allocateInfo(ndx);
7695+
if(!startCell->allocateInfo(ndx)) {
7696+
cleanOpenAndClosedLists();
7697+
goalCell->releaseInfo();
7698+
return NULL;
7699+
}
76887700
startCell->setParentCellHierarchical(parentCell);
76897701
if (!startCell->getClosed() && !startCell->getOpen()) {
76907702
m_closedList = startCell->putOnClosedList(m_closedList);
76917703
}
76927704
}
7693-
cell->allocateInfo(toNdx);
7705+
if(!cell->allocateInfo(toNdx)) {
7706+
cleanOpenAndClosedLists();
7707+
goalCell->releaseInfo();
7708+
return NULL;
7709+
}
76947710
cell->setParentCellHierarchical(startCell);
76957711

76967712
cellCount++;

0 commit comments

Comments
 (0)