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