1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #534 from nullkiller/ai-fix-crash-in-pathfinding-static-storage

AI: fix crash in pathfinding
This commit is contained in:
Alexander Shishkin 2019-01-08 00:15:46 +03:00 committed by GitHub
commit 05c9b3e2f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -28,6 +28,13 @@ void AIPathfinder::clear()
storageMap.clear();
}
void AIPathfinder::init()
{
boost::unique_lock<boost::mutex> storageLock(storageMutex);
storagePool.clear();
storageMap.clear();
}
std::vector<AIPath> AIPathfinder::getPathInfo(HeroPtr hero, int3 tile)
{
boost::unique_lock<boost::mutex> storageLock(storageMutex);

View File

@ -27,4 +27,5 @@ public:
AIPathfinder(CPlayerSpecificInfoCallback * cb, VCAI * ai);
std::vector<AIPath> getPathInfo(HeroPtr hero, int3 tile);
void clear();
void init();
};

View File

@ -24,6 +24,7 @@ void PathfindingManager::init(CPlayerSpecificInfoCallback * CB)
{
cb = CB;
pathfinder.reset(new AIPathfinder(cb, ai));
pathfinder->init();
}
void PathfindingManager::setAI(VCAI * AI)