[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.
0.8.0
David Cernat 3 years ago
parent 4e2860f578
commit 1a000bc0a8

@ -2479,24 +2479,24 @@ namespace MWMechanics
void Actors::cleanupSummonedCreature (MWMechanics::CreatureStats& casterStats, int creatureActorId) void Actors::cleanupSummonedCreature (MWMechanics::CreatureStats& casterStats, int creatureActorId)
{ {
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaActorId(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 /*
*/ Start of tes3mp change (major)
if (mwmp::Main::get().getCellController()->hasLocalAuthority(*ptr.getCell()->getCell()))
{ Do a cleanup here and send an ID_OBJECT_DELETE packet every time a summoned creature
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList(); despawns for the local player or for a local actor
objectList->reset(); */
objectList->packetOrigin = mwmp::CLIENT_GAMEPLAY; if (!ptr.isEmpty() &&
objectList->addObjectGeneric(ptr); (casterStats.getActorId() == getPlayer().getClass().getCreatureStats(getPlayer()).getActorId() || mwmp::Main::get().getCellController()->hasLocalAuthority(*ptr.getCell()->getCell())))
objectList->sendObjectDelete(); {
} mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
/* objectList->reset();
End of tes3mp change (major) 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<ESM::Static>() const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get<ESM::Static>()
.search("VFX_Summon_End"); .search("VFX_Summon_End");

Loading…
Cancel
Save