@@ -1297,6 +1297,12 @@ Bool PathfindCell::allocateInfo( const ICoord2D &pos )
1297
1297
*/
1298
1298
void PathfindCell::releaseInfo ( void )
1299
1299
{
1300
+ // TheSuperHackers @bugfix Mauller / SkyAero 04/05/2025 Parent cell links need clearing to prevent dangling pointers on start cells linking to an invalid parent cell.
1301
+ // Parent cells are only cleared within Pathfinder::prependCells, so cells that do not make it onto the final path do not get their parent cell cleared.
1302
+ // Cells with a special flags also do not get their pathfindinfo cleared and therefore can leave a parent cell set on a starting cell.
1303
+ if (m_info) {
1304
+ m_info->m_pathParent = NULL ;
1305
+ }
1300
1306
if (m_type==PathfindCell::CELL_OBSTACLE) {
1301
1307
return ;
1302
1308
}
@@ -6648,8 +6654,8 @@ Path *Pathfinder::internalFindPath( Object *obj, const LocomotorSet& locomotorSe
6648
6654
m_isTunneling = false ;
6649
6655
// construct and return path
6650
6656
Path *path = buildActualPath ( obj, locomotorSet.getValidSurfaces (), from, goalCell, centerInCell, false );
6651
- parentCell->releaseInfo ();
6652
6657
cleanOpenAndClosedLists ();
6658
+ parentCell->releaseInfo ();
6653
6659
return path;
6654
6660
}
6655
6661
@@ -6726,8 +6732,8 @@ Path *Pathfinder::internalFindPath( Object *obj, const LocomotorSet& locomotorSe
6726
6732
#endif
6727
6733
6728
6734
m_isTunneling = false ;
6729
- parentCell->releaseInfo ();
6730
6735
cleanOpenAndClosedLists ();
6736
+ parentCell->releaseInfo ();
6731
6737
goalCell->releaseInfo ();
6732
6738
return NULL ;
6733
6739
}
@@ -7162,8 +7168,8 @@ Path *Pathfinder::findGroundPath( const Coord3D *from,
7162
7168
m_isTunneling = false ;
7163
7169
// construct and return path
7164
7170
Path *path = buildGroundPath (crusher, from, goalCell, centerInCell, pathDiameter );
7165
- parentCell->releaseInfo ();
7166
7171
cleanOpenAndClosedLists ();
7172
+ parentCell->releaseInfo ();
7167
7173
return path;
7168
7174
}
7169
7175
@@ -7358,8 +7364,8 @@ Path *Pathfinder::findGroundPath( const Coord3D *from,
7358
7364
TheGameLogic->incrementOverallFailedPathfinds ();
7359
7365
#endif
7360
7366
m_isTunneling = false ;
7361
- parentCell->releaseInfo ();
7362
7367
cleanOpenAndClosedLists ();
7368
+ parentCell->releaseInfo ();
7363
7369
goalCell->releaseInfo ();
7364
7370
return NULL ;
7365
7371
}
@@ -7738,8 +7744,8 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
7738
7744
#endif
7739
7745
}
7740
7746
#endif
7741
- parentCell->releaseInfo ();
7742
7747
cleanOpenAndClosedLists ();
7748
+ parentCell->releaseInfo ();
7743
7749
goalCell->releaseInfo ();
7744
7750
return path;
7745
7751
}
@@ -7937,8 +7943,8 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
7937
7943
}
7938
7944
#endif
7939
7945
#endif
7940
- parentCell->releaseInfo ();
7941
7946
cleanOpenAndClosedLists ();
7947
+ parentCell->releaseInfo ();
7942
7948
goalCell->releaseInfo ();
7943
7949
return path;
7944
7950
}
@@ -7986,8 +7992,8 @@ Path *Pathfinder::internal_findHierarchicalPath( Bool isHuman, const LocomotorSu
7986
7992
TheGameLogic->incrementOverallFailedPathfinds ();
7987
7993
#endif
7988
7994
m_isTunneling = false ;
7989
- parentCell->releaseInfo ();
7990
7995
cleanOpenAndClosedLists ();
7996
+ parentCell->releaseInfo ();
7991
7997
goalCell->releaseInfo ();
7992
7998
return NULL ;
7993
7999
}
@@ -8424,8 +8430,8 @@ Bool Pathfinder::pathDestination( Object *obj, const LocomotorSet& locomotorSet
8424
8430
}
8425
8431
#endif
8426
8432
m_isTunneling = false ;
8427
- parentCell->releaseInfo ();
8428
8433
cleanOpenAndClosedLists ();
8434
+ parentCell->releaseInfo ();
8429
8435
goalCell->releaseInfo ();
8430
8436
return false ;
8431
8437
}
@@ -8555,8 +8561,8 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8555
8561
if (parentCell==goalCell) {
8556
8562
Int cost = parentCell->getTotalCost ();
8557
8563
m_isTunneling = false ;
8558
- parentCell->releaseInfo ();
8559
8564
cleanOpenAndClosedLists ();
8565
+ parentCell->releaseInfo ();
8560
8566
return cost;
8561
8567
}
8562
8568
@@ -8623,8 +8629,8 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8623
8629
8624
8630
if (!newCell->allocateInfo (newCellCoord)) {
8625
8631
// Out of cells for pathing...
8626
- parentCell->releaseInfo ();
8627
8632
cleanOpenAndClosedLists ();
8633
+ parentCell->releaseInfo ();
8628
8634
goalCell->releaseInfo ();
8629
8635
return cellCount;
8630
8636
}
@@ -8674,8 +8680,8 @@ Int Pathfinder::checkPathCost(Object *obj, const LocomotorSet& locomotorSet, con
8674
8680
}
8675
8681
8676
8682
m_isTunneling = false ;
8677
- parentCell->releaseInfo ();
8678
8683
cleanOpenAndClosedLists ();
8684
+ parentCell->releaseInfo ();
8679
8685
goalCell->releaseInfo ();
8680
8686
return MAX_COST;
8681
8687
}
@@ -8879,8 +8885,8 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
8879
8885
m_isTunneling = false ;
8880
8886
// construct and return path
8881
8887
Path *path = buildActualPath ( obj, locomotorSet.getValidSurfaces (), from, goalCell, centerInCell, blocked);
8882
- parentCell->releaseInfo ();
8883
8888
cleanOpenAndClosedLists ();
8889
+ parentCell->releaseInfo ();
8884
8890
goalCell->releaseInfo ();
8885
8891
return path;
8886
8892
}
@@ -8961,8 +8967,8 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
8961
8967
rawTo->y = closesetCell->getYIndex ()*PATHFIND_CELL_SIZE_F + PATHFIND_CELL_SIZE_F/2 .0f ;
8962
8968
// construct and return path
8963
8969
Path *path = buildActualPath ( obj, locomotorSet.getValidSurfaces (), from, closesetCell, centerInCell, blocked );
8964
- parentCell->releaseInfo ();
8965
8970
cleanOpenAndClosedLists ();
8971
+ parentCell->releaseInfo ();
8966
8972
goalCell->releaseInfo ();
8967
8973
return path;
8968
8974
}
@@ -8984,8 +8990,8 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
8984
8990
TheGameLogic->incrementOverallFailedPathfinds ();
8985
8991
#endif
8986
8992
m_isTunneling = false ;
8987
- parentCell->releaseInfo ();
8988
8993
cleanOpenAndClosedLists ();
8994
+ parentCell->releaseInfo ();
8989
8995
goalCell->releaseInfo ();
8990
8996
return NULL ;
8991
8997
}
@@ -10373,8 +10379,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj,
10373
10379
m_isTunneling = false ;
10374
10380
// construct and return path
10375
10381
Path *newPath = buildActualPath ( obj, locomotorSet.getValidSurfaces (), obj->getPosition (), parentCell, centerInCell, false );
10376
- parentCell->releaseInfo ();
10377
10382
cleanOpenAndClosedLists ();
10383
+ parentCell->releaseInfo ();
10378
10384
return newPath;
10379
10385
}
10380
10386
// put parent cell onto closed list - its evaluation is finished
@@ -10396,8 +10402,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj,
10396
10402
DEBUG_LOG ((" Unit '%s', time %f\n " , obj->getTemplate ()->getName ().str (), (::GetTickCount ()-startTimeMS)/1000 .0f ));
10397
10403
10398
10404
m_isTunneling = false ;
10399
- parentCell->releaseInfo ();
10400
10405
cleanOpenAndClosedLists ();
10406
+ parentCell->releaseInfo ();
10401
10407
return NULL ;
10402
10408
}
10403
10409
@@ -10556,8 +10562,8 @@ Path *Pathfinder::patchPath( const Object *obj, const LocomotorSet& locomotorSet
10556
10562
10557
10563
// cleanup the path by checking line of sight
10558
10564
path->optimize (obj, locomotorSet.getValidSurfaces (), blocked);
10559
- parentCell->releaseInfo ();
10560
10565
cleanOpenAndClosedLists ();
10566
+ parentCell->releaseInfo ();
10561
10567
candidateGoal->releaseInfo ();
10562
10568
10563
10569
return path;
@@ -10582,8 +10588,8 @@ Path *Pathfinder::patchPath( const Object *obj, const LocomotorSet& locomotorSet
10582
10588
}
10583
10589
#endif
10584
10590
m_isTunneling = false ;
10585
- parentCell->releaseInfo ();
10586
10591
cleanOpenAndClosedLists ();
10592
+ parentCell->releaseInfo ();
10587
10593
candidateGoal->releaseInfo ();
10588
10594
return NULL ;
10589
10595
}
@@ -10877,8 +10883,8 @@ Path *Pathfinder::findAttackPath( const Object *obj, const LocomotorSet& locomot
10877
10883
}
10878
10884
}
10879
10885
Path *path = buildActualPath ( obj, locomotorSet.getValidSurfaces (), obj->getPosition (), parentCell, centerInCell, false );
10880
- parentCell->releaseInfo ();
10881
10886
cleanOpenAndClosedLists ();
10887
+ parentCell->releaseInfo ();
10882
10888
goalCell->releaseInfo ();
10883
10889
return path;
10884
10890
}
@@ -10936,8 +10942,8 @@ Path *Pathfinder::findAttackPath( const Object *obj, const LocomotorSet& locomot
10936
10942
TheGameLogic->incrementOverallFailedPathfinds ();
10937
10943
#endif
10938
10944
m_isTunneling = false ;
10939
- parentCell->releaseInfo ();
10940
10945
cleanOpenAndClosedLists ();
10946
+ parentCell->releaseInfo ();
10941
10947
goalCell->releaseInfo ();
10942
10948
return NULL ;
10943
10949
}
@@ -11060,8 +11066,8 @@ Path *Pathfinder::findSafePath( const Object *obj, const LocomotorSet& locomotor
11060
11066
#endif
11061
11067
// construct and return path
11062
11068
Path *path = buildActualPath ( obj, locomotorSet.getValidSurfaces (), obj->getPosition (), parentCell, centerInCell, false );
11063
- parentCell->releaseInfo ();
11064
11069
cleanOpenAndClosedLists ();
11070
+ parentCell->releaseInfo ();
11065
11071
return path;
11066
11072
}
11067
11073
@@ -11096,8 +11102,8 @@ Path *Pathfinder::findSafePath( const Object *obj, const LocomotorSet& locomotor
11096
11102
TheGameLogic->incrementOverallFailedPathfinds ();
11097
11103
#endif
11098
11104
m_isTunneling = false ;
11099
- parentCell->releaseInfo ();
11100
11105
cleanOpenAndClosedLists ();
11106
+ parentCell->releaseInfo ();
11101
11107
return NULL ;
11102
11108
}
11103
11109
0 commit comments