1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

crash in VCAI::completeGoal() fixed

This commit is contained in:
Haryaalcar 2014-06-08 20:12:16 +03:00
parent 145df56126
commit 2ee139977f

View File

@ -1415,14 +1415,15 @@ void VCAI::completeGoal (Goals::TSubgoal goal)
}
else //complete goal for all heroes maybe?
{
for (auto p : lockedHeroes)
vstd::erase_if(lockedHeroes, [goal](std::pair<HeroPtr, Goals::TSubgoal> p)
{
if (*(p.second) == *goal || p.second->fulfillsMe(goal)) //we could have fulfilled goals of other heroes by chance
{
logAi->debugStream() << boost::format("%s") % p.second->completeMessage();
lockedHeroes.erase (lockedHeroes.find(p.first)); //is it safe?
return true;
}
}
return false;
});
}
}