diff --git a/AI/VCAI/AIhelper.cpp b/AI/VCAI/AIhelper.cpp index 190ae2a3c..d74fee4e2 100644 --- a/AI/VCAI/AIhelper.cpp +++ b/AI/VCAI/AIhelper.cpp @@ -152,8 +152,3 @@ void AIhelper::updatePaths(std::vector heroes) { pathfindingManager->updatePaths(heroes); } - -void AIhelper::updatePaths(const HeroPtr & hero) -{ - pathfindingManager->updatePaths(hero); -} diff --git a/AI/VCAI/AIhelper.h b/AI/VCAI/AIhelper.h index 15c5c8bcd..03a3189e3 100644 --- a/AI/VCAI/AIhelper.h +++ b/AI/VCAI/AIhelper.h @@ -61,7 +61,6 @@ public: Goals::TGoalVec howToVisitObj(ObjectIdRef obj) const override; std::vector getPathsToTile(const HeroPtr & hero, const int3 & tile) const override; void updatePaths(std::vector heroes) override; - void updatePaths(const HeroPtr & hero) override; STRONG_INLINE bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const diff --git a/AI/VCAI/Pathfinding/AIPathfinder.cpp b/AI/VCAI/Pathfinding/AIPathfinder.cpp index 4c9e6bfac..878a89892 100644 --- a/AI/VCAI/Pathfinding/AIPathfinder.cpp +++ b/AI/VCAI/Pathfinding/AIPathfinder.cpp @@ -103,36 +103,6 @@ void AIPathfinder::updatePaths(std::vector heroes) } } -void AIPathfinder::updatePaths(const HeroPtr & hero) -{ - std::shared_ptr nodeStorage; - - if(!vstd::contains(storageMap, hero)) - { - if(storageMap.size() < storagePool.size()) - { - nodeStorage = storagePool.at(storageMap.size()); - } - else - { - nodeStorage = std::make_shared(cb->getMapSize()); - storagePool.push_back(nodeStorage); - } - - storageMap[hero] = nodeStorage; - nodeStorage->setHero(hero, ai); - } - else - { - nodeStorage = storageMap.at(hero); - } - - logAi->debug("Recalculate paths for %s", hero->name); - auto config = std::make_shared(cb, ai, nodeStorage); - - cb->calculatePaths(config, hero.get()); -} - std::shared_ptr AIPathfinder::getStorage(const HeroPtr & hero) const { return storageMap.at(hero); diff --git a/AI/VCAI/Pathfinding/AIPathfinder.h b/AI/VCAI/Pathfinding/AIPathfinder.h index 8c7199b15..9fb881c17 100644 --- a/AI/VCAI/Pathfinding/AIPathfinder.h +++ b/AI/VCAI/Pathfinding/AIPathfinder.h @@ -28,6 +28,5 @@ public: std::vector getPathInfo(const HeroPtr & hero, const int3 & tile) const; bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const; void updatePaths(std::vector heroes); - void updatePaths(const HeroPtr & heroes); void init(); }; diff --git a/AI/VCAI/Pathfinding/PathfindingManager.cpp b/AI/VCAI/Pathfinding/PathfindingManager.cpp index e4c7462f6..61e010d50 100644 --- a/AI/VCAI/Pathfinding/PathfindingManager.cpp +++ b/AI/VCAI/Pathfinding/PathfindingManager.cpp @@ -240,8 +240,3 @@ void PathfindingManager::updatePaths(std::vector heroes) logAi->debug("AIPathfinder has been reseted."); pathfinder->updatePaths(heroes); } - -void PathfindingManager::updatePaths(const HeroPtr & hero) -{ - pathfinder->updatePaths(hero); -} diff --git a/AI/VCAI/Pathfinding/PathfindingManager.h b/AI/VCAI/Pathfinding/PathfindingManager.h index 95ec9949b..e6b6cfb1e 100644 --- a/AI/VCAI/Pathfinding/PathfindingManager.h +++ b/AI/VCAI/Pathfinding/PathfindingManager.h @@ -21,7 +21,6 @@ public: virtual void setAI(VCAI * AI) = 0; virtual void updatePaths(std::vector heroes) = 0; - virtual void updatePaths(const HeroPtr & hero) = 0; virtual Goals::TGoalVec howToVisitTile(const HeroPtr & hero, const int3 & tile, bool allowGatherArmy = true) const = 0; virtual Goals::TGoalVec howToVisitObj(const HeroPtr & hero, ObjectIdRef obj, bool allowGatherArmy = true) const = 0; virtual Goals::TGoalVec howToVisitTile(const int3 & tile) const = 0; @@ -48,7 +47,6 @@ public: Goals::TGoalVec howToVisitObj(ObjectIdRef obj) const override; std::vector getPathsToTile(const HeroPtr & hero, const int3 & tile) const override; void updatePaths(std::vector heroes) override; - void updatePaths(const HeroPtr & hero) override; STRONG_INLINE bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index 2dc72a159..40216853f 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -1422,14 +1422,14 @@ void VCAI::wander(HeroPtr h) while(h->movement) { validateVisitableObjs(); - ah->updatePaths(h); + ah->updatePaths(getMyHeroes()); std::vector dests; //also visit our reserved objects - but they are not prioritized to avoid running back and forth vstd::copy_if(reservedHeroesMap[h], std::back_inserter(dests), [&](ObjectIdRef obj) -> bool { - return ah->getPathsToTile(h, obj->visitablePos()).size(); + return ah->isTileAccessible(h, obj->visitablePos()); }); int pass = 0;