@@ -6565,10 +6565,14 @@ Path *Pathfinder::internalFindPath( Object *obj, const LocomotorSet& locomotorSe
6565
6565
zone2 = m_zoneManager.getEffectiveZone (locomotorSet.getValidSurfaces (), isCrusher, goalCell->getZone ());
6566
6566
6567
6567
if (layer==LAYER_WALL && zone1 == 0 ) {
6568
+ goalCell->releaseInfo ();
6569
+ parentCell->releaseInfo ();
6568
6570
return NULL ;
6569
6571
}
6570
6572
6571
6573
if (destinationLayer==LAYER_WALL && zone2 == 0 ) {
6574
+ goalCell->releaseInfo ();
6575
+ parentCell->releaseInfo ();
6572
6576
return NULL ;
6573
6577
}
6574
6578
@@ -6650,7 +6654,6 @@ Path *Pathfinder::internalFindPath( Object *obj, const LocomotorSet& locomotorSe
6650
6654
Path *path = buildActualPath ( obj, locomotorSet.getValidSurfaces (), from, goalCell, centerInCell, false );
6651
6655
parentCell->releaseInfo ();
6652
6656
cleanOpenAndClosedLists ();
6653
- goalCell->releaseInfo ();
6654
6657
return path;
6655
6658
}
6656
6659
@@ -7105,6 +7108,7 @@ Path *Pathfinder::findGroundPath( const Coord3D *from,
7105
7108
PathfindLayerEnum layer = TheTerrainLogic->getLayerForDestination (from);
7106
7109
PathfindCell *parentCell = getClippedCell ( layer,&clipFrom );
7107
7110
if (parentCell == NULL ) {
7111
+ goalCell->releaseInfo ();
7108
7112
return NULL ;
7109
7113
}
7110
7114
if (parentCell!=goalCell) {
@@ -7169,7 +7173,6 @@ Path *Pathfinder::findGroundPath( const Coord3D *from,
7169
7173
Path *path = buildGroundPath (crusher, from, goalCell, centerInCell, pathDiameter );
7170
7174
parentCell->releaseInfo ();
7171
7175
cleanOpenAndClosedLists ();
7172
- goalCell->releaseInfo ();
7173
7176
return path;
7174
7177
}
7175
7178
@@ -8268,7 +8271,6 @@ Bool Pathfinder::pathDestination( Object *obj, const LocomotorSet& locomotorSet
8268
8271
8269
8272
if (parentCell!=goalCell) {
8270
8273
if (!parentCell->allocateInfo (startCellNdx)) {
8271
- desiredCell->releaseInfo ();
8272
8274
goalCell->releaseInfo ();
8273
8275
return FALSE ;
8274
8276
}
@@ -8383,6 +8385,8 @@ Bool Pathfinder::pathDestination( Object *obj, const LocomotorSet& locomotorSet
8383
8385
8384
8386
if (!newCell->allocateInfo (newCellCoord)) {
8385
8387
// Out of cells for pathing...
8388
+ cleanOpenAndClosedLists ();
8389
+ goalCell->releaseInfo ();
8386
8390
return cellCount;
8387
8391
}
8388
8392
cellCount++;
@@ -8567,18 +8571,17 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8567
8571
parentCell = m_openList;
8568
8572
m_openList = parentCell->removeFromOpenList (m_openList);
8569
8573
8570
- // put parent cell onto closed list - its evaluation is finished
8571
- m_closedList = parentCell->putOnClosedList ( m_closedList );
8572
-
8573
8574
if (parentCell==goalCell) {
8574
8575
Int cost = parentCell->getTotalCost ();
8575
8576
m_isTunneling = false ;
8576
8577
parentCell->releaseInfo ();
8577
8578
cleanOpenAndClosedLists ();
8578
- goalCell->releaseInfo ();
8579
8579
return cost;
8580
8580
}
8581
8581
8582
+ // put parent cell onto closed list - its evaluation is finished
8583
+ m_closedList = parentCell->putOnClosedList ( m_closedList );
8584
+
8582
8585
if (cellCount > MAX_CELL_COUNT) {
8583
8586
continue ;
8584
8587
}
@@ -8639,8 +8642,11 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8639
8642
8640
8643
if (!newCell->allocateInfo (newCellCoord)) {
8641
8644
// Out of cells for pathing...
8645
+ parentCell->releaseInfo ();
8646
+ cleanOpenAndClosedLists ();
8647
+ goalCell->releaseInfo ();
8642
8648
return cellCount;
8643
- }
8649
+ }
8644
8650
cellCount++;
8645
8651
8646
8652
newCostSoFar = newCell->costSoFar ( parentCell );
@@ -8826,6 +8832,7 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
8826
8832
if (parentCell!=goalCell) {
8827
8833
worldToCell (&clipFrom, &pos2d);
8828
8834
if (!parentCell->allocateInfo (pos2d)) {
8835
+ goalCell->releaseInfo ();
8829
8836
return NULL ;
8830
8837
}
8831
8838
}
@@ -9121,13 +9128,11 @@ void Pathfinder::prependCells( Path *path, const Coord3D *fromPos,
9121
9128
prevCell = cell;
9122
9129
}
9123
9130
9124
- if (cell->hasInfo ()) {
9125
- m_zoneManager.setPassable (cell->getXIndex (), cell->getYIndex (), true );
9126
- if (goalCellNull) {
9127
- // Very short path.
9128
- adjustCoordToCell (cell->getXIndex (), cell->getYIndex (), center, pos, cell->getLayer ());
9129
- path->prependNode ( &pos, cell->getLayer () );
9130
- }
9131
+ m_zoneManager.setPassable (cell->getXIndex (), cell->getYIndex (), true );
9132
+ if (goalCellNull) {
9133
+ // Very short path.
9134
+ adjustCoordToCell (cell->getXIndex (), cell->getYIndex (), center, pos, cell->getLayer ());
9135
+ path->prependNode ( &pos, cell->getLayer () );
9131
9136
}
9132
9137
9133
9138
// put actual start position as first node on the path, so it begins right at the unit's feet
@@ -10528,14 +10533,14 @@ Path *Pathfinder::patchPath( const Object *obj, const LocomotorSet& locomotorSet
10528
10533
}
10529
10534
if (startNode == originalPath->getLastNode ()) {
10530
10535
parentCell->releaseInfo ();
10531
- cleanOpenAndClosedLists ();
10532
10536
return NULL ; // no open nodes.
10533
10537
}
10534
10538
PathfindCell *candidateGoal;
10535
10539
candidateGoal = getCell (LAYER_GROUND, &goalPos); // just using for cost estimates.
10536
10540
ICoord2D goalCellNdx;
10537
10541
worldToCell (&goalPos, &goalCellNdx);
10538
10542
if (!candidateGoal->allocateInfo (goalCellNdx)) {
10543
+ parentCell->releaseInfo ();
10539
10544
return NULL ;
10540
10545
}
10541
10546
0 commit comments