From 1a000bc0a861a4dc7bcdfb24a907dfa785b1f9f2 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 21 Apr 2022 23:58:50 +0300 Subject: [PATCH] [Client] Fix cleanup of summoned creatures Previously, summoned creatures weren't being deleted in certain situations because they were encountered again before the cell they were in had a local authority. --- apps/openmw/mwmechanics/actors.cpp | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index e02a81c77..0bf28e47d 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -2479,24 +2479,24 @@ namespace MWMechanics void Actors::cleanupSummonedCreature (MWMechanics::CreatureStats& casterStats, int creatureActorId) { MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaActorId(creatureActorId); - if (!ptr.isEmpty()) - { - /* - Start of tes3mp change (major) - Send an ID_OBJECT_DELETE packet every time a summoned creature despawns - */ - if (mwmp::Main::get().getCellController()->hasLocalAuthority(*ptr.getCell()->getCell())) - { - mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList(); - objectList->reset(); - objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY; - objectList->addObjectGeneric(ptr); - objectList->sendObjectDelete(); - } - /* - End of tes3mp change (major) - */ + /* + Start of tes3mp change (major) + + Do a cleanup here and send an ID_OBJECT_DELETE packet every time a summoned creature + despawns for the local player or for a local actor + */ + if (!ptr.isEmpty() && + (casterStats.getActorId() == getPlayer().getClass().getCreatureStats(getPlayer()).getActorId() || mwmp::Main::get().getCellController()->hasLocalAuthority(*ptr.getCell()->getCell()))) + { + mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList(); + objectList->reset(); + objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY; + objectList->addObjectGeneric(ptr); + objectList->sendObjectDelete(); + /* + End of tes3mp change (major) + */ const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get() .search("VFX_Summon_End");