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

Remove a few more usages of thread shared ai and cb

This commit is contained in:
Andrii Danylchenko
2019-02-16 10:33:24 +02:00
parent 6165954e40
commit f76c6c2300
7 changed files with 24 additions and 22 deletions

View File

@@ -185,10 +185,11 @@ std::vector<CGPathNode *> AINodeStorage::calculateNeighbours(
return neighbours;
}
void AINodeStorage::setHero(HeroPtr heroPtr, const CPlayerSpecificInfoCallback * _cb)
void AINodeStorage::setHero(HeroPtr heroPtr, const VCAI * _ai)
{
hero = heroPtr.get();
cb = _cb;
cb = _ai->myCb.get();
ai = _ai;
}
std::vector<CGPathNode *> AINodeStorage::calculateTeleportations(

View File

@@ -62,6 +62,7 @@ private:
/// 1-3 - position on map, 4 - layer (air, water, land), 5 - chain (normal, battle, spellcast and combinations)
boost::multi_array<AIPathNode, 5> nodes;
const CPlayerSpecificInfoCallback * cb;
const VCAI * ai;
const CGHeroInstance * hero;
std::unique_ptr<FuzzyHelper> dangerEvaluator;
@@ -106,7 +107,7 @@ public:
std::vector<AIPath> getChainInfo(const int3 & pos, bool isOnLand) const;
bool isTileAccessible(const int3 & pos, const EPathfindingLayer layer) const;
void setHero(HeroPtr heroPtr, const CPlayerSpecificInfoCallback * cb);
void setHero(HeroPtr heroPtr, const VCAI * ai);
const CGHeroInstance * getHero() const
{
@@ -115,7 +116,7 @@ public:
uint64_t evaluateDanger(const int3 & tile) const
{
return dangerEvaluator->evaluateDanger(tile, hero, cb);
return dangerEvaluator->evaluateDanger(tile, hero, ai);
}
private:

View File

@@ -62,7 +62,6 @@ void AIPathfinder::updatePaths(std::vector<HeroPtr> heroes)
std::vector<Task> calculationTasks;
// TODO: go parallel?
for(HeroPtr hero : heroes)
{
std::shared_ptr<AINodeStorage> nodeStorage;
@@ -78,7 +77,7 @@ void AIPathfinder::updatePaths(std::vector<HeroPtr> heroes)
}
storageMap[hero] = nodeStorage;
nodeStorage->setHero(hero, cb);
nodeStorage->setHero(hero, ai);
auto config = std::make_shared<AIPathfinding::AIPathfinderConfig>(cb, ai, nodeStorage);
@@ -121,7 +120,7 @@ void AIPathfinder::updatePaths(const HeroPtr & hero)
}
storageMap[hero] = nodeStorage;
nodeStorage->setHero(hero, cb);
nodeStorage->setHero(hero, ai);
}
else
{