1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-09-16 09:26:28 +02:00

Merge pull request #16 from Haryaalcar/develop

crash in VCAI::completeGoal() fixed
This commit is contained in:
DjWarmonger
2014-06-09 15:43:49 +02:00

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;
});
}
}