Skip to content

Commit ad4a981

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 f44c689 commit ad4a981

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
@@ -7445,7 +7445,7 @@ void Pathfinder::processHierarchicalCell( const ICoord2D &scanCell, const ICoord
74457445
}
74467446

74477447
newCell->allocateInfo(scanCell);
7448-
if (!newCell->getClosed() && !newCell->getOpen()) {
7448+
if (newCell->hasInfo() && !newCell->getClosed() && !newCell->getOpen()) {
74497449
m_closedList = newCell->putOnClosedList(m_closedList);
74507450
}
74517451

@@ -7603,7 +7603,11 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
76037603
// Close parent cell;
76047604
m_openList = parentCell->removeFromOpenList(m_openList);
76057605
m_closedList = parentCell->putOnClosedList(m_closedList);
7606-
startCell->allocateInfo(ndx);
7606+
if (!startCell->allocateInfo(ndx)) {
7607+
cleanOpenAndClosedLists();
7608+
goalCell->releaseInfo();
7609+
return NULL;
7610+
}
76077611
startCell->setParentCellHierarchical(parentCell);
76087612
cellCount++;
76097613
Int curCost = startCell->costToHierGoal(parentCell);
@@ -7615,7 +7619,11 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
76157619
m_openList = startCell->putOnSortedOpenList( m_openList );
76167620

76177621
cellCount++;
7618-
cell->allocateInfo(toNdx);
7622+
if(!cell->allocateInfo(toNdx)) {
7623+
cleanOpenAndClosedLists();
7624+
goalCell->releaseInfo();
7625+
return NULL;
7626+
}
76197627
curCost = cell->costToHierGoal(parentCell);
76207628
remCost = cell->costToHierGoal(goalCell);
76217629
cell->setCostSoFar(curCost);
@@ -7699,13 +7707,21 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
76997707
PathfindCell *startCell = getCell(LAYER_GROUND, ndx.x, ndx.y);
77007708
if (startCell==NULL) continue;
77017709
if (startCell != parentCell) {
7702-
startCell->allocateInfo(ndx);
7710+
if(!startCell->allocateInfo(ndx)) {
7711+
cleanOpenAndClosedLists();
7712+
goalCell->releaseInfo();
7713+
return NULL;
7714+
}
77037715
startCell->setParentCellHierarchical(parentCell);
77047716
if (!startCell->getClosed() && !startCell->getOpen()) {
77057717
m_closedList = startCell->putOnClosedList(m_closedList);
77067718
}
77077719
}
7708-
cell->allocateInfo(toNdx);
7720+
if(!cell->allocateInfo(toNdx)) {
7721+
cleanOpenAndClosedLists();
7722+
goalCell->releaseInfo();
7723+
return NULL;
7724+
}
77097725
cell->setParentCellHierarchical(startCell);
77107726

77117727
cellCount++;

0 commit comments

Comments
 (0)