@@ -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) {
@@ -7165,7 +7169,6 @@ Path *Pathfinder::findGroundPath( const Coord3D *from,
7165
7169
Path *path = buildGroundPath (crusher, from, goalCell, centerInCell, pathDiameter );
7166
7170
parentCell->releaseInfo ();
7167
7171
cleanOpenAndClosedLists ();
7168
- goalCell->releaseInfo ();
7169
7172
return path;
7170
7173
}
7171
7174
@@ -8264,7 +8267,6 @@ Bool Pathfinder::pathDestination( Object *obj, const LocomotorSet& locomotorSet
8264
8267
8265
8268
if (parentCell!=goalCell) {
8266
8269
if (!parentCell->allocateInfo (startCellNdx)) {
8267
- desiredCell->releaseInfo ();
8268
8270
goalCell->releaseInfo ();
8269
8271
return FALSE ;
8270
8272
}
@@ -8379,6 +8381,8 @@ Bool Pathfinder::pathDestination( Object *obj, const LocomotorSet& locomotorSet
8379
8381
8380
8382
if (!newCell->allocateInfo (newCellCoord)) {
8381
8383
// Out of cells for pathing...
8384
+ cleanOpenAndClosedLists ();
8385
+ goalCell->releaseInfo ();
8382
8386
return cellCount;
8383
8387
}
8384
8388
cellCount++;
@@ -8563,18 +8567,17 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8563
8567
parentCell = m_openList;
8564
8568
m_openList = parentCell->removeFromOpenList (m_openList);
8565
8569
8566
- // put parent cell onto closed list - its evaluation is finished
8567
- m_closedList = parentCell->putOnClosedList ( m_closedList );
8568
-
8569
8570
if (parentCell==goalCell) {
8570
8571
Int cost = parentCell->getTotalCost ();
8571
8572
m_isTunneling = false ;
8572
8573
parentCell->releaseInfo ();
8573
8574
cleanOpenAndClosedLists ();
8574
- goalCell->releaseInfo ();
8575
8575
return cost;
8576
8576
}
8577
8577
8578
+ // put parent cell onto closed list - its evaluation is finished
8579
+ m_closedList = parentCell->putOnClosedList ( m_closedList );
8580
+
8578
8581
if (cellCount > MAX_CELL_COUNT) {
8579
8582
continue ;
8580
8583
}
@@ -8635,8 +8638,11 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8635
8638
8636
8639
if (!newCell->allocateInfo (newCellCoord)) {
8637
8640
// Out of cells for pathing...
8641
+ parentCell->releaseInfo ();
8642
+ cleanOpenAndClosedLists ();
8643
+ goalCell->releaseInfo ();
8638
8644
return cellCount;
8639
- }
8645
+ }
8640
8646
cellCount++;
8641
8647
8642
8648
newCostSoFar = newCell->costSoFar ( parentCell );
@@ -8822,6 +8828,7 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
8822
8828
if (parentCell!=goalCell) {
8823
8829
worldToCell (&clipFrom, &pos2d);
8824
8830
if (!parentCell->allocateInfo (pos2d)) {
8831
+ goalCell->releaseInfo ();
8825
8832
return NULL ;
8826
8833
}
8827
8834
}
@@ -9117,13 +9124,11 @@ void Pathfinder::prependCells( Path *path, const Coord3D *fromPos,
9117
9124
prevCell = cell;
9118
9125
}
9119
9126
9120
- if (cell->hasInfo ()) {
9121
- m_zoneManager.setPassable (cell->getXIndex (), cell->getYIndex (), true );
9122
- if (goalCellNull) {
9123
- // Very short path.
9124
- adjustCoordToCell (cell->getXIndex (), cell->getYIndex (), center, pos, cell->getLayer ());
9125
- path->prependNode ( &pos, cell->getLayer () );
9126
- }
9127
+ m_zoneManager.setPassable (cell->getXIndex (), cell->getYIndex (), true );
9128
+ if (goalCellNull) {
9129
+ // Very short path.
9130
+ adjustCoordToCell (cell->getXIndex (), cell->getYIndex (), center, pos, cell->getLayer ());
9131
+ path->prependNode ( &pos, cell->getLayer () );
9127
9132
}
9128
9133
9129
9134
// put actual start position as first node on the path, so it begins right at the unit's feet
@@ -10524,14 +10529,14 @@ Path *Pathfinder::patchPath( const Object *obj, const LocomotorSet& locomotorSet
10524
10529
}
10525
10530
if (startNode == originalPath->getLastNode ()) {
10526
10531
parentCell->releaseInfo ();
10527
- cleanOpenAndClosedLists ();
10528
10532
return NULL ; // no open nodes.
10529
10533
}
10530
10534
PathfindCell *candidateGoal;
10531
10535
candidateGoal = getCell (LAYER_GROUND, &goalPos); // just using for cost estimates.
10532
10536
ICoord2D goalCellNdx;
10533
10537
worldToCell (&goalPos, &goalCellNdx);
10534
10538
if (!candidateGoal->allocateInfo (goalCellNdx)) {
10539
+ parentCell->releaseInfo ();
10535
10540
return NULL ;
10536
10541
}
10537
10542
0 commit comments