Check if blocking map pointer is valid by comparing game time to a variable that isn't inside the blocking map structure. (Backport from newnet.)
Must have gotten confused when mixing/refactoring/blending/frying data structures, even the comment was weird. Fixes valgrind warning and probably fixes ticket:2016.master
parent
c778cad0f1
commit
c96eda047c
|
@ -112,6 +112,8 @@ struct PathBlockingMap
|
|||
std::vector<bool> 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<PathfindContext> fpathContexts;
|
|||
static std::list<PathBlockingMap> 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<PathBlockingMap> 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
|
||||
|
|
Loading…
Reference in New Issue