Browse Source

ai fix town portal to occupied town

Andrii Danylchenko 4 years ago
parent
commit
e838e70165

+ 0 - 5
AI/Nullkiller/AIhelper.cpp

@@ -152,8 +152,3 @@ void AIhelper::updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain)
 {
 	pathfindingManager->updatePaths(heroes, useHeroChain);
 }
-
-void AIhelper::updatePaths(const HeroPtr & hero)
-{
-	pathfindingManager->updatePaths(hero);
-}

+ 0 - 1
AI/Nullkiller/AIhelper.h

@@ -61,7 +61,6 @@ public:
 	Goals::TGoalVec howToVisitObj(ObjectIdRef obj, bool allowGatherArmy = true) const override;
 	std::vector<AIPath> getPathsToTile(const HeroPtr & hero, const int3 & tile) const override;
 	void updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain = false) override;
-	void updatePaths(const HeroPtr & hero) override;
 
 	STRONG_INLINE
 	bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const

+ 1 - 6
AI/Nullkiller/Pathfinding/AIPathfinder.cpp

@@ -65,9 +65,4 @@ void AIPathfinder::updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain)
 		logAi->trace("Recalculate chain pass %" PRIi32, pass);
 		useHeroChain = useHeroChain && storage->calculateHeroChain();
 	} while(useHeroChain);
-}
-
-void AIPathfinder::updatePaths(const HeroPtr & hero)
-{
-	updatePaths(std::vector<HeroPtr>{hero});
-}
+}

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

@@ -26,6 +26,5 @@ public:
 	std::vector<AIPath> getPathInfo(const HeroPtr & hero, const int3 & tile) const;
 	bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const;
 	void updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain = false);
-	void updatePaths(const HeroPtr & heroes);
 	void init();
 };

+ 0 - 5
AI/Nullkiller/Pathfinding/PathfindingManager.cpp

@@ -258,8 +258,3 @@ void PathfindingManager::updatePaths(std::vector<HeroPtr> heroes, bool useHeroCh
 	logAi->debug("AIPathfinder has been reseted.");
 	pathfinder->updatePaths(heroes, useHeroChain);
 }
-
-void PathfindingManager::updatePaths(const HeroPtr & hero)
-{
-	pathfinder->updatePaths(hero);
-}

+ 0 - 2
AI/Nullkiller/Pathfinding/PathfindingManager.h

@@ -21,7 +21,6 @@ public:
 	virtual void setAI(VCAI * AI) = 0;
 
 	virtual void updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain = false) = 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, bool allowGatherArmy = true) const = 0;
@@ -48,7 +47,6 @@ public:
 	Goals::TGoalVec howToVisitObj(ObjectIdRef obj, bool allowGatherArmy = true) const override;
 	std::vector<AIPath> getPathsToTile(const HeroPtr & hero, const int3 & tile) const override;
 	void updatePaths(std::vector<HeroPtr> heroes, bool useHeroChain = false) override;
-	void updatePaths(const HeroPtr & hero) override;
 
 	STRONG_INLINE
 	bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const

+ 2 - 2
AI/Nullkiller/VCAI.cpp

@@ -1448,14 +1448,14 @@ void VCAI::wander(HeroPtr h)
 	while(h->movement)
 	{
 		validateVisitableObjs();
-		ah->updatePaths(h);
+		ah->updatePaths(getMyHeroes());
 
 		std::vector<ObjectIdRef> 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;