Explorar o código

AI crash — do not modify container when iterating it.

Michał W. Urbańczyk %!s(int64=11) %!d(string=hai) anos
pai
achega
93b8d2e59a
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      AI/VCAI/VCAI.cpp

+ 2 - 1
AI/VCAI/VCAI.cpp

@@ -1248,7 +1248,8 @@ bool VCAI::canRecruitAnyHero (const CGTownInstance * t) const
 void VCAI::wander(HeroPtr h)
 {
 	//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()))
 			unreserveObject(h, obj);