mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
fix crash when computer player loses
Changing dwelling's owner to neutral accesses a PlayerState but neutrals don't have a PlayerState and that leads to crash.
This commit is contained in:
parent
9a5bee1eaf
commit
ca12750dc3
@ -1066,10 +1066,13 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, const PlayerColor owne
|
||||
|
||||
if ((obj->ID == Obj::CREATURE_GENERATOR1 || obj->ID == Obj::CREATURE_GENERATOR4))
|
||||
{
|
||||
for (const CGTownInstance * t : getPlayerState(owner)->getTowns())
|
||||
if (owner.isValidPlayer())
|
||||
{
|
||||
if (t->hasBuilt(BuildingSubID::PORTAL_OF_SUMMONING))
|
||||
setPortalDwelling(t);//set initial creatures for all portals of summoning
|
||||
for (const CGTownInstance * t : getPlayerState(owner)->getTowns())
|
||||
{
|
||||
if (t->hasBuilt(BuildingSubID::PORTAL_OF_SUMMONING))
|
||||
setPortalDwelling(t);//set initial creatures for all portals of summoning
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user