diff --git a/src/astar.cpp b/src/astar.cpp index fb2fa1509..c47ee2702 100644 --- a/src/astar.cpp +++ b/src/astar.cpp @@ -112,6 +112,8 @@ struct PathBlockingMap std::vector map; }; +/// Game time for all blocking maps in fpathBlockingMaps. +static uint32_t fpathCurrentGameTime; // Data structures used for pathfinding, can contain cached results. struct PathfindContext @@ -124,8 +126,8 @@ struct PathfindContext } bool matches(PathBlockingMap const *blockingMap_, PathCoord tileS_) const { - // Must check that myGameTime == blockingMap->type.gameTime, otherwise blockingMap be a deleted pointer which coincidentally compares equal to the valid pointer blockingMap_. - return myGameTime == blockingMap->type.gameTime && blockingMap == blockingMap_ && tileS == tileS_; + // Must check myGameTime == fpathCurrentGameTime, otherwise blockingMap be a deleted pointer which coincidentally compares equal to the valid pointer blockingMap_. + return myGameTime == fpathCurrentGameTime && blockingMap == blockingMap_ && tileS == tileS_; } void assign(PathBlockingMap const *blockingMap_, PathCoord tileS_) { @@ -166,8 +168,6 @@ static std::list fpathContexts; static std::list fpathBlockingMaps; /// Lists of blocking maps from previous tick, will be cleared next tick (since it will be no longer needed after that). static std::list fpathPrevBlockingMaps; -/// Game time for all blocking maps in fpathBlockingMaps. -static uint32_t fpathCurrentGameTime; // Convert a direction into an offset // dir 0 => x = 0, y = -1