Bläddra i källkod

AI: fix crash in pathfinding

Andrii Danylchenko 6 år sedan
förälder
incheckning
8b829e1099

+ 7 - 0
AI/VCAI/Pathfinding/AIPathfinder.cpp

@@ -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);

+ 1 - 0
AI/VCAI/Pathfinding/AIPathfinder.h

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

+ 1 - 0
AI/VCAI/Pathfinding/PathfindingManager.cpp

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