1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

ai fix town portal to occupied town

This commit is contained in:
Andrii Danylchenko
2019-02-24 17:50:11 +02:00
parent 1855af9ed3
commit 5fb5ddfc67
7 changed files with 2 additions and 46 deletions

View File

@@ -103,36 +103,6 @@ void AIPathfinder::updatePaths(std::vector<HeroPtr> heroes)
}
}
void AIPathfinder::updatePaths(const HeroPtr & hero)
{
std::shared_ptr<AINodeStorage> nodeStorage;
if(!vstd::contains(storageMap, hero))
{
if(storageMap.size() < storagePool.size())
{
nodeStorage = storagePool.at(storageMap.size());
}
else
{
nodeStorage = std::make_shared<AINodeStorage>(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<AIPathfinding::AIPathfinderConfig>(cb, ai, nodeStorage);
cb->calculatePaths(config, hero.get());
}
std::shared_ptr<const AINodeStorage> AIPathfinder::getStorage(const HeroPtr & hero) const
{
return storageMap.at(hero);

View File

@@ -28,6 +28,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);
void updatePaths(const HeroPtr & heroes);
void init();
};

View File

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

View File

@@ -21,7 +21,6 @@ public:
virtual void setAI(VCAI * AI) = 0;
virtual void updatePaths(std::vector<HeroPtr> 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<AIPath> getPathsToTile(const HeroPtr & hero, const int3 & tile) const override;
void updatePaths(std::vector<HeroPtr> heroes) override;
void updatePaths(const HeroPtr & hero) override;
STRONG_INLINE
bool isTileAccessible(const HeroPtr & hero, const int3 & tile) const