mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
NKAI: fix freeze on army gathering
This commit is contained in:
parent
d7cbe4ecde
commit
04fe78d31c
@ -92,15 +92,6 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const CGHeroInstance * her
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool garrisoned = false;
|
|
||||||
|
|
||||||
if(path.turn() == 0 && hero->inTownGarrison)
|
|
||||||
{
|
|
||||||
#if NKAI_TRACE_LEVEL >= 1
|
|
||||||
garrisoned = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if(path.turn() > 0 && ai->nullkiller->dangerHitMap->enemyCanKillOurHeroesAlongThePath(path))
|
if(path.turn() > 0 && ai->nullkiller->dangerHitMap->enemyCanKillOurHeroesAlongThePath(path))
|
||||||
{
|
{
|
||||||
#if NKAI_TRACE_LEVEL >= 2
|
#if NKAI_TRACE_LEVEL >= 2
|
||||||
@ -184,15 +175,22 @@ Goals::TGoalVec GatherArmyBehavior::deliverArmyToHero(const CGHeroInstance * her
|
|||||||
|
|
||||||
composition.addNext(heroExchange);
|
composition.addNext(heroExchange);
|
||||||
|
|
||||||
if(garrisoned && path.turn() == 0)
|
if(hero->inTownGarrison && path.turn() == 0)
|
||||||
{
|
{
|
||||||
auto lockReason = ai->nullkiller->getHeroLockedReason(hero);
|
auto lockReason = ai->nullkiller->getHeroLockedReason(hero);
|
||||||
|
|
||||||
|
if(path.targetHero->visitedTown == hero->visitedTown)
|
||||||
|
{
|
||||||
|
composition.addNextSequence({
|
||||||
|
sptr(ExchangeSwapTownHeroes(hero->visitedTown, hero, lockReason))});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
composition.addNextSequence({
|
composition.addNextSequence({
|
||||||
sptr(ExchangeSwapTownHeroes(hero->visitedTown)),
|
sptr(ExchangeSwapTownHeroes(hero->visitedTown)),
|
||||||
sptr(exchangePath),
|
sptr(exchangePath),
|
||||||
sptr(ExchangeSwapTownHeroes(hero->visitedTown, hero, lockReason))
|
sptr(ExchangeSwapTownHeroes(hero->visitedTown, hero, lockReason))});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -323,6 +323,11 @@ void Nullkiller::makeTurn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
executeTask(bestTask);
|
executeTask(bestTask);
|
||||||
|
|
||||||
|
if(i == MAXPASS)
|
||||||
|
{
|
||||||
|
logAi->error("Goal %s exceeded maxpass. Terminating AI turn.", bestTask->toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1359,7 +1359,7 @@ void VCAI::wander(HeroPtr h)
|
|||||||
|
|
||||||
TimeCheck tc("looking for wander destination");
|
TimeCheck tc("looking for wander destination");
|
||||||
|
|
||||||
while(h->movementPointsRemaining())
|
for(int k = 0; k < 10 && h->movementPointsRemaining(); k++)
|
||||||
{
|
{
|
||||||
validateVisitableObjs();
|
validateVisitableObjs();
|
||||||
ah->updatePaths(getMyHeroes());
|
ah->updatePaths(getMyHeroes());
|
||||||
|
Loading…
Reference in New Issue
Block a user