From 8b829e1099e1a5a47ed8687ed041d0b71eb3f40c Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sat, 5 Jan 2019 15:28:22 +0200 Subject: [PATCH] AI: fix crash in pathfinding --- AI/VCAI/Pathfinding/AIPathfinder.cpp | 7 +++++++ AI/VCAI/Pathfinding/AIPathfinder.h | 1 + AI/VCAI/Pathfinding/PathfindingManager.cpp | 1 + 3 files changed, 9 insertions(+) diff --git a/AI/VCAI/Pathfinding/AIPathfinder.cpp b/AI/VCAI/Pathfinding/AIPathfinder.cpp index 1e3e37eb2..c25a516cb 100644 --- a/AI/VCAI/Pathfinding/AIPathfinder.cpp +++ b/AI/VCAI/Pathfinding/AIPathfinder.cpp @@ -28,6 +28,13 @@ void AIPathfinder::clear() storageMap.clear(); } +void AIPathfinder::init() +{ + boost::unique_lock storageLock(storageMutex); + storagePool.clear(); + storageMap.clear(); +} + std::vector AIPathfinder::getPathInfo(HeroPtr hero, int3 tile) { boost::unique_lock storageLock(storageMutex); diff --git a/AI/VCAI/Pathfinding/AIPathfinder.h b/AI/VCAI/Pathfinding/AIPathfinder.h index e33e3c1db..1240b63ab 100644 --- a/AI/VCAI/Pathfinding/AIPathfinder.h +++ b/AI/VCAI/Pathfinding/AIPathfinder.h @@ -27,4 +27,5 @@ public: AIPathfinder(CPlayerSpecificInfoCallback * cb, VCAI * ai); std::vector getPathInfo(HeroPtr hero, int3 tile); void clear(); + void init(); }; diff --git a/AI/VCAI/Pathfinding/PathfindingManager.cpp b/AI/VCAI/Pathfinding/PathfindingManager.cpp index 7fa158090..e9a9c1ee3 100644 --- a/AI/VCAI/Pathfinding/PathfindingManager.cpp +++ b/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)