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

CGameHandler: fix hero removal code on player loss. Fix issue 2347

This commit is contained in:
ArseniyShestakov 2015-12-10 12:43:55 +03:00
parent 9e6f836b25
commit d900e9bec2

View File

@ -4827,11 +4827,15 @@ void CGameHandler::checkVictoryLossConditionsForPlayer(PlayerColor player)
} }
else else
{ {
//player lost -> all his objects become unflagged (neutral) //copy heroes vector to avoid iterator invalidation as removal change PlayerState
for (auto h : p->heroes) //eliminate heroes auto hlp = p->heroes;
if (h.get()) for(auto h : hlp) //eliminate heroes
{
if(h.get())
removeObject(h); removeObject(h);
}
//player lost -> all his objects become unflagged (neutral)
for (auto obj : gs->map->objects) //unflag objs for (auto obj : gs->map->objects) //unflag objs
{ {
if(obj.get() && obj->tempOwner == player) if(obj.get() && obj->tempOwner == player)