From 97768be14b399349b87e1ba01dea13b2aa738689 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 25 May 2017 01:00:47 +0300 Subject: [PATCH] [Client] Send ObjectPlace packet for random creatures interrupting rest --- apps/openmw/mwgui/hud.cpp | 2 +- .../mwscript/transformationextensions.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index cdcc9751a..4c448f5b2 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -84,7 +84,7 @@ namespace MWGui Start of tes3mp change (major) Instead of actually keeping this object as is, delete it after sending the packet - and wait for the server to send it back with the correct mpNum + and wait for the server to send it back with a unique mpNum of its own */ MWBase::Environment::get().getWorld()->deleteObject(dropped); /* diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index daf92abf8..6c10f90dc 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -569,7 +569,7 @@ namespace MWScript Start of tes3mp change (major) Instead of actually keeping this object as is, delete it after sending the packet - and wait for the server to send it back with the correct mpNum + and wait for the server to send it back with a unique mpNum of its own */ MWBase::Environment::get().getWorld()->deleteObject(ptr); /* diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c1900bacc..784efdbab 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3392,7 +3392,23 @@ namespace MWWorld MWWorld::ManualRef ref(getStore(), selectedCreature, 1); - safePlaceObject(ref.getPtr(), getPlayerPtr(), getPlayerPtr().getCell(), 0, 220.f); + /* + Start of tes3mp change (major) + + Send an ID_OBJECT_PLACE packet every time a random creature is spawned, then delete + the creature and wait for the server to send it back with a unique mpNum of its own + */ + MWWorld::Ptr ptr = safePlaceObject(ref.getPtr(), getPlayerPtr(), getPlayerPtr().getCell(), 0, 220.f); + + mwmp::WorldEvent *worldEvent = mwmp::Main::get().getNetworking()->getWorldEvent(); + worldEvent->reset(); + worldEvent->addObjectPlace(ptr); + worldEvent->sendObjectPlace(); + + MWBase::Environment::get().getWorld()->deleteObject(ptr); + /* + End of tes3mp change (major) + */ } }