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

AI: fix crash in pathfinding

This commit is contained in:
Andrii Danylchenko 2019-01-05 15:28:22 +02:00
parent efc53e8f8b
commit 8b829e1099
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)