mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
Remove object from owned objects before resetting owner
This commit is contained in:
parent
543ce94132
commit
970d7d795f
@ -1193,6 +1193,17 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
if (initiator.isValidPlayer())
|
||||
gs->getPlayerState(initiator)->destroyedObjects.insert(objectID);
|
||||
|
||||
if(obj->getOwner().isValidPlayer())
|
||||
{
|
||||
gs->getPlayerState(obj->getOwner())->removeOwnedObject(obj); //object removed via map event or hero got beaten
|
||||
|
||||
FlaggableMapObject* flaggableObject = dynamic_cast<FlaggableMapObject*>(obj);
|
||||
if(flaggableObject)
|
||||
{
|
||||
flaggableObject->markAsDeleted();
|
||||
}
|
||||
}
|
||||
|
||||
if(obj->ID == Obj::HERO) //remove beaten hero
|
||||
{
|
||||
auto * beatenHero = dynamic_cast<CGHeroInstance *>(obj);
|
||||
@ -1251,18 +1262,6 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
|
||||
if(obj->getOwner().isValidPlayer())
|
||||
{
|
||||
gs->getPlayerState(obj->getOwner())->removeOwnedObject(obj); //object removed via map event or hero got beaten
|
||||
|
||||
FlaggableMapObject* flaggableObject = dynamic_cast<FlaggableMapObject*>(obj);
|
||||
if(flaggableObject)
|
||||
{
|
||||
flaggableObject->markAsDeleted();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gs->map->instanceNames.erase(obj->instanceName);
|
||||
gs->map->objects[objectID.getNum()].dellNull();
|
||||
gs->map->calculateGuardingGreaturePositions();//FIXME: excessive, update only affected tiles
|
||||
|
Loading…
Reference in New Issue
Block a user