mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-29 21:56:54 +02:00
Nullkiller: fix crash
This commit is contained in:
parent
ea2931c6ea
commit
02b2f35143
@ -65,7 +65,7 @@ void DefenceBehavior::evaluateDefence(Goals::TGoalVec & tasks, const CGTownInsta
|
||||
{
|
||||
if(!ai->nullkiller->isHeroLocked(town->garrisonHero.get()))
|
||||
{
|
||||
if(!town->visitingHero)
|
||||
if(!town->visitingHero && cb->getHeroesInfo().size() < GameConstants::MAX_HEROES_PER_PLAYER)
|
||||
{
|
||||
tasks.push_back(Goals::sptr(Goals::ExchangeSwapTownHeroes(town, nullptr).setpriority(5)));
|
||||
}
|
||||
|
@ -42,13 +42,22 @@ void ExchangeSwapTownHeroes::accept(AIGateway * ai)
|
||||
{
|
||||
if(!garrisonHero)
|
||||
{
|
||||
if(!town->garrisonHero)
|
||||
auto currentGarrisonHero = town->garrisonHero;
|
||||
|
||||
if(!currentGarrisonHero)
|
||||
throw cannotFulfillGoalException("Invalid configuration. There is no hero in town garrison.");
|
||||
|
||||
cb->swapGarrisonHero(town);
|
||||
|
||||
if(currentGarrisonHero.get() != town->visitingHero.get())
|
||||
{
|
||||
logAi->error("VisitingHero is empty, expected %s", currentGarrisonHero->name);
|
||||
return;
|
||||
}
|
||||
|
||||
ai->buildArmyIn(town);
|
||||
ai->nullkiller->unlockHero(town->visitingHero.get());
|
||||
logAi->debug("Extracted hero %s from garrison of %s", town->visitingHero->name, town->name);
|
||||
ai->nullkiller->unlockHero(currentGarrisonHero.get());
|
||||
logAi->debug("Extracted hero %s from garrison of %s", currentGarrisonHero->name, town->name);
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user