1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

AI crash — do not modify container when iterating it.

This commit is contained in:
Michał W. Urbańczyk 2014-03-01 12:53:09 +00:00
parent 2e04738859
commit 93b8d2e59a

View File

@ -1248,7 +1248,8 @@ bool VCAI::canRecruitAnyHero (const CGTownInstance * t) const
void VCAI::wander(HeroPtr h) void VCAI::wander(HeroPtr h)
{ {
//unclaim objects that are now dangerous for us //unclaim objects that are now dangerous for us
for (auto obj : reservedHeroesMap[h]) auto reservedObjsSetCopy = reservedHeroesMap[h];
for (auto obj : reservedObjsSetCopy)
{ {
if (!isSafeToVisit(h, obj->visitablePos())) if (!isSafeToVisit(h, obj->visitablePos()))
unreserveObject(h, obj); unreserveObject(h, obj);