From 703f25371269e9775c3a1fd88e08062e97607770 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 31 Jan 2017 09:48:37 +0200 Subject: [PATCH] [Client] Delete new LocalEvents after sending them --- apps/openmw/mwgui/hud.cpp | 3 +++ apps/openmw/mwgui/inventorywindow.cpp | 2 ++ apps/openmw/mwmechanics/security.cpp | 2 ++ apps/openmw/mwscript/animationextensions.cpp | 2 ++ apps/openmw/mwscript/interpretercontext.cpp | 12 ++++++++++++ apps/openmw/mwscript/miscextensions.cpp | 8 ++++++++ apps/openmw/mwscript/soundextensions.cpp | 2 ++ apps/openmw/mwscript/transformationextensions.cpp | 5 +++++ apps/openmw/mwworld/actiontake.cpp | 3 +++ apps/openmw/mwworld/worldimp.cpp | 6 ++++++ 10 files changed, 45 insertions(+) diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index bd1857a6b..38d954e45 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -93,6 +93,9 @@ namespace MWGui worldObject.refNumIndex, worldObject.count); + delete event; + event = nullptr; + return dropped; } diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index c60897efc..145c37a64 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -644,6 +644,8 @@ namespace MWGui event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); + delete event; + event = nullptr; // remove from world MWBase::Environment::get().getWorld()->deleteObject (object); diff --git a/apps/openmw/mwmechanics/security.cpp b/apps/openmw/mwmechanics/security.cpp index 0a2ef7556..054a0924f 100644 --- a/apps/openmw/mwmechanics/security.cpp +++ b/apps/openmw/mwmechanics/security.cpp @@ -68,6 +68,8 @@ namespace MWMechanics event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event); + delete event; + event = nullptr; lock.getClass().unlock(lock); resultMessage = "#{sLockSuccess}"; diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index 8ddc02257..4aa6a66ea 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -77,6 +77,8 @@ namespace MWScript event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(event); + delete event; + event = nullptr; } MWBase::Environment::get().getMechanicsManager()->playAnimationGroup (ptr, group, mode, std::numeric_limits::max(), true); diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 7fafa5d31..016d131ed 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -207,6 +207,9 @@ namespace MWScript event->cell.getDescription().c_str(), worldObject.index, worldObject.shortVal); + + delete event; + event = nullptr; } } @@ -248,6 +251,9 @@ namespace MWScript event->cell.getDescription().c_str(), worldObject.index, worldObject.floatVal); + + delete event; + event = nullptr; } } @@ -307,6 +313,9 @@ namespace MWScript LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_GLOBAL_SHORT\n- varName: %s\n- shortVal: %i", worldObject.varName.c_str(), worldObject.shortVal); + + delete event; + event = nullptr; } MWBase::Environment::get().getWorld()->setGlobalInt (name, value); @@ -646,6 +655,9 @@ namespace MWScript worldObject.refId.c_str(), worldObject.index, worldObject.shortVal); + + delete event; + event = nullptr; } } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 89d7c8b70..431e34fb4 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -98,6 +98,8 @@ namespace MWScript event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(event); + delete event; + event = nullptr; MWBase::Environment::get().getWindowManager()->playVideo (name, allowSkipping); } @@ -208,6 +210,8 @@ namespace MWScript event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(event); + delete event; + event = nullptr; ptr.getClass().lock (ptr, lockLevel); @@ -245,6 +249,8 @@ namespace MWScript event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event); + delete event; + event = nullptr; ptr.getClass().unlock (ptr); } @@ -716,6 +722,8 @@ namespace MWScript event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); + delete event; + event = nullptr; MWBase::Environment::get().getWorld()->deleteObject(ptr); } diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index 28c3d91ca..0c22d477c 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -78,6 +78,8 @@ namespace MWScript event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(event); + delete event; + event = nullptr; MWBase::Environment::get().getSoundManager()->streamMusic (sound); } diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 090a4aef7..6d6d9ec1f 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -57,6 +57,8 @@ namespace MWScript event->addObject(worldObject); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(event); + delete event; + event = nullptr; MWBase::Environment::get().getWorld()->scaleObject(ptr,scale); } @@ -570,6 +572,9 @@ namespace MWScript worldObject.refId.c_str(), worldObject.refNumIndex, worldObject.count); + + delete event; + event = nullptr; } } }; diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index 811407bf0..5bd8a9829 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -41,6 +41,9 @@ namespace MWWorld getTarget().getCellRef().getRefNum().mIndex, event->cell.getDescription().c_str()); + delete event; + event = nullptr; + // LocalPlayer's inventory has changed, so send a packet with it mwmp::Main::get().getLocalPlayer()->sendInventory(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 34a52cffe..cf2caff42 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2283,6 +2283,9 @@ namespace MWWorld event->cell.getDescription().c_str(), worldObject.state ? "true" : "false"); + delete event; + event = nullptr; + door.getClass().setDoorState(door, state); mDoorStates[door] = state; } @@ -2307,6 +2310,9 @@ namespace MWWorld event->cell.getDescription().c_str(), worldObject.state ? "true" : "false"); + delete event; + event = nullptr; + door.getClass().setDoorState(door, state); mDoorStates[door] = state; if (state == 0)