Skip to content

Commit 70e7292

Browse files
MaullerBart Roossien
andauthored
bugfix(pathfinder): Fix various crashes in Pathfinder due to inadequate cleanup of pathfinding resources (#994)
Co-authored-by: Bart Roossien <roossienb@users.noreply.github.com>
1 parent 783bdb7 commit 70e7292

File tree

5 files changed

+1129
-113
lines changed

5 files changed

+1129
-113
lines changed

Core/GameEngine/Include/Common/GameDefines.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
#define RETAIL_COMPATIBLE_XFER_SAVE (1) // Game is expected to be Xfer Save compatible with retail Generals 1.08, Zero Hour 1.04
3636
#endif
3737

38+
// This is here to easily toggle between the retail compatible with fixed pathfinding fallback and pure fixed pathfinding mode
39+
#if RETAIL_COMPATIBLE_CRC
40+
#define RETAIL_COMPATIBLE_PATHFINDING (1)
41+
#else
42+
#define RETAIL_COMPATIBLE_PATHFINDING (0)
43+
#endif
44+
3845
// This is essentially synonymous for RETAIL_COMPATIBLE_CRC. There is a lot wrong with AIGroup, such as use-after-free, double-free, leaks,
3946
// but we cannot touch it much without breaking retail compatibility. Do not shy away from using massive hacks when fixing issues with AIGroup,
4047
// but put them behind this macro.

Generals/Code/GameEngine/Include/GameLogic/AIPathfind.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ class PathfindCellInfo
207207
{
208208
friend class PathfindCell;
209209
public:
210+
#if RETAIL_COMPATIBLE_PATHFINDING
211+
static void forceCleanPathFindCellInfos(void);
212+
#endif
210213
static void allocateCellInfos(void);
211214
static void releaseCellInfos(void);
212215

@@ -691,6 +694,9 @@ class Pathfinder : PathfindServicesInterface, public Snapshot
691694
Path *getDebugPath( void );
692695
void setDebugPath( Path *debugpath );
693696

697+
#if RETAIL_COMPATIBLE_PATHFINDING
698+
void forceCleanCells(void);
699+
#endif
694700
void cleanOpenAndClosedLists(void);
695701

696702
// Adjusts the destination to a spot near dest that is not occupied by other units.

0 commit comments

Comments
 (0)