@@ -6561,10 +6561,14 @@ Path *Pathfinder::internalFindPath( Object *obj, const LocomotorSet& locomotorSe
6561
6561
zone2 = m_zoneManager.getEffectiveZone (locomotorSet.getValidSurfaces (), isCrusher, goalCell->getZone ());
6562
6562
6563
6563
if (layer==LAYER_WALL && zone1 == 0 ) {
6564
+ goalCell->releaseInfo ();
6565
+ parentCell->releaseInfo ();
6564
6566
return NULL ;
6565
6567
}
6566
6568
6567
6569
if (destinationLayer==LAYER_WALL && zone2 == 0 ) {
6570
+ goalCell->releaseInfo ();
6571
+ parentCell->releaseInfo ();
6568
6572
return NULL ;
6569
6573
}
6570
6574
@@ -6646,7 +6650,6 @@ Path *Pathfinder::internalFindPath( Object *obj, const LocomotorSet& locomotorSe
6646
6650
Path *path = buildActualPath ( obj, locomotorSet.getValidSurfaces (), from, goalCell, centerInCell, false );
6647
6651
parentCell->releaseInfo ();
6648
6652
cleanOpenAndClosedLists ();
6649
- goalCell->releaseInfo ();
6650
6653
return path;
6651
6654
}
6652
6655
@@ -7101,6 +7104,7 @@ Path *Pathfinder::findGroundPath( const Coord3D *from,
7101
7104
PathfindLayerEnum layer = TheTerrainLogic->getLayerForDestination (from);
7102
7105
PathfindCell *parentCell = getClippedCell ( layer,&clipFrom );
7103
7106
if (parentCell == NULL ) {
7107
+ goalCell->releaseInfo ();
7104
7108
return NULL ;
7105
7109
}
7106
7110
if (parentCell!=goalCell) {
@@ -7160,7 +7164,6 @@ Path *Pathfinder::findGroundPath( const Coord3D *from,
7160
7164
Path *path = buildGroundPath (crusher, from, goalCell, centerInCell, pathDiameter );
7161
7165
parentCell->releaseInfo ();
7162
7166
cleanOpenAndClosedLists ();
7163
- goalCell->releaseInfo ();
7164
7167
return path;
7165
7168
}
7166
7169
@@ -8249,7 +8252,6 @@ Bool Pathfinder::pathDestination( Object *obj, const LocomotorSet& locomotorSet
8249
8252
8250
8253
if (parentCell!=goalCell) {
8251
8254
if (!parentCell->allocateInfo (startCellNdx)) {
8252
- desiredCell->releaseInfo ();
8253
8255
goalCell->releaseInfo ();
8254
8256
return FALSE ;
8255
8257
}
@@ -8364,6 +8366,8 @@ Bool Pathfinder::pathDestination( Object *obj, const LocomotorSet& locomotorSet
8364
8366
8365
8367
if (!newCell->allocateInfo (newCellCoord)) {
8366
8368
// Out of cells for pathing...
8369
+ cleanOpenAndClosedLists ();
8370
+ goalCell->releaseInfo ();
8367
8371
return cellCount;
8368
8372
}
8369
8373
cellCount++;
@@ -8548,18 +8552,17 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8548
8552
parentCell = m_openList;
8549
8553
m_openList = parentCell->removeFromOpenList (m_openList);
8550
8554
8551
- // put parent cell onto closed list - its evaluation is finished
8552
- m_closedList = parentCell->putOnClosedList ( m_closedList );
8553
-
8554
8555
if (parentCell==goalCell) {
8555
8556
Int cost = parentCell->getTotalCost ();
8556
8557
m_isTunneling = false ;
8557
8558
parentCell->releaseInfo ();
8558
8559
cleanOpenAndClosedLists ();
8559
- goalCell->releaseInfo ();
8560
8560
return cost;
8561
8561
}
8562
8562
8563
+ // put parent cell onto closed list - its evaluation is finished
8564
+ m_closedList = parentCell->putOnClosedList ( m_closedList );
8565
+
8563
8566
if (cellCount > MAX_CELL_COUNT) {
8564
8567
continue ;
8565
8568
}
@@ -8620,8 +8623,11 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8620
8623
8621
8624
if (!newCell->allocateInfo (newCellCoord)) {
8622
8625
// Out of cells for pathing...
8626
+ parentCell->releaseInfo ();
8627
+ cleanOpenAndClosedLists ();
8628
+ goalCell->releaseInfo ();
8623
8629
return cellCount;
8624
- }
8630
+ }
8625
8631
cellCount++;
8626
8632
8627
8633
newCostSoFar = newCell->costSoFar ( parentCell );
@@ -8807,6 +8813,7 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
8807
8813
if (parentCell!=goalCell) {
8808
8814
worldToCell (&clipFrom, &pos2d);
8809
8815
if (!parentCell->allocateInfo (pos2d)) {
8816
+ goalCell->releaseInfo ();
8810
8817
return NULL ;
8811
8818
}
8812
8819
}
@@ -9102,13 +9109,11 @@ void Pathfinder::prependCells( Path *path, const Coord3D *fromPos,
9102
9109
prevCell = cell;
9103
9110
}
9104
9111
9105
- if (cell->hasInfo ()) {
9106
- m_zoneManager.setPassable (cell->getXIndex (), cell->getYIndex (), true );
9107
- if (goalCellNull) {
9108
- // Very short path.
9109
- adjustCoordToCell (cell->getXIndex (), cell->getYIndex (), center, pos, cell->getLayer ());
9110
- path->prependNode ( &pos, cell->getLayer () );
9111
- }
9112
+ m_zoneManager.setPassable (cell->getXIndex (), cell->getYIndex (), true );
9113
+ if (goalCellNull) {
9114
+ // Very short path.
9115
+ adjustCoordToCell (cell->getXIndex (), cell->getYIndex (), center, pos, cell->getLayer ());
9116
+ path->prependNode ( &pos, cell->getLayer () );
9112
9117
}
9113
9118
9114
9119
// put actual start position as first node on the path, so it begins right at the unit's feet
@@ -10509,14 +10514,14 @@ Path *Pathfinder::patchPath( const Object *obj, const LocomotorSet& locomotorSet
10509
10514
}
10510
10515
if (startNode == originalPath->getLastNode ()) {
10511
10516
parentCell->releaseInfo ();
10512
- cleanOpenAndClosedLists ();
10513
10517
return NULL ; // no open nodes.
10514
10518
}
10515
10519
PathfindCell *candidateGoal;
10516
10520
candidateGoal = getCell (LAYER_GROUND, &goalPos); // just using for cost estimates.
10517
10521
ICoord2D goalCellNdx;
10518
10522
worldToCell (&goalPos, &goalCellNdx);
10519
10523
if (!candidateGoal->allocateInfo (goalCellNdx)) {
10524
+ parentCell->releaseInfo ();
10520
10525
return NULL ;
10521
10526
}
10522
10527
0 commit comments