From 624b85347ae25a0be7aeb1a2280852135e230def Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 27 Jan 2017 20:57:47 +0200 Subject: [PATCH] [Client] Create LocalEvent class and use it instead of WorldEvent --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwgui/hud.cpp | 14 +++----- apps/openmw/mwgui/inventorywindow.cpp | 7 ++-- apps/openmw/mwmechanics/security.cpp | 7 ++-- apps/openmw/mwmp/LocalEvent.cpp | 33 +++++++++++++++++++ apps/openmw/mwmp/LocalEvent.hpp | 27 +++++++++++++++ apps/openmw/mwmp/Networking.cpp | 7 ++-- apps/openmw/mwmp/Networking.hpp | 3 +- apps/openmw/mwscript/animationextensions.cpp | 7 ++-- apps/openmw/mwscript/interpretercontext.cpp | 28 ++++++++-------- apps/openmw/mwscript/miscextensions.cpp | 19 +++++------ apps/openmw/mwscript/soundextensions.cpp | 4 +-- .../mwscript/transformationextensions.cpp | 16 ++++----- apps/openmw/mwworld/actiontake.cpp | 11 +++---- apps/openmw/mwworld/worldimp.cpp | 20 +++++------ 15 files changed, 124 insertions(+), 81 deletions(-) create mode 100644 apps/openmw/mwmp/LocalEvent.cpp create mode 100644 apps/openmw/mwmp/LocalEvent.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index df8df81fb..34cfd516a 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -96,7 +96,7 @@ add_openmw_dir (mwbase inputmanager windowmanager statemanager ) -add_openmw_dir (mwmp DedicatedPlayer LocalPlayer Networking Main GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList WorldController) +add_openmw_dir (mwmp DedicatedPlayer LocalEvent LocalPlayer Networking Main GUIChat GUILogin GUIController PlayerMarkerCollection GUIDialogList WorldController) # Main executable diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 904ae6fbe..38dbd58c4 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -1,8 +1,8 @@ #include "hud.hpp" -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include "../mwworld/cellstore.hpp" #include @@ -66,10 +66,9 @@ namespace MWGui dropped.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex()); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *dropped.getCell()->getCell(); - event->cellRef.mRefID = dropped.getCellRef().getRefId(); - event->cellRef.mRefNum = dropped.getCellRef().getRefNum(); + event->addCellRef(dropped.getCellRef()); // Make sure we send the RefData position instead of the CellRef one, because that's what // we actually see on this client @@ -79,14 +78,11 @@ namespace MWGui // automatically for stacks of gold event->count = dropped.getRefData().getCount(); - // Get the real count of gold in a stack - event->cellRef.mGoldValue = dropped.getCellRef().getGoldValue(); - mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i", - event->cellRef.mRefID.c_str(), - event->cellRef.mRefNum.mIndex, + dropped.getCellRef().getRefId().c_str(), + dropped.getCellRef().getRefNum().mIndex, event->count); return dropped; diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index bc11a77b0..3fa1eb4c7 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -16,9 +16,9 @@ #include -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include "../mwworld/cellstore.hpp" #include "../mwbase/world.hpp" @@ -635,10 +635,9 @@ namespace MWGui MWWorld::Ptr newObject = *player.getClass().getContainerStore (player).add (object, object.getRefData().getCount(), player); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *object.getCell()->getCell(); - event->cellRef.mRefID = object.getCellRef().getRefId(); - event->cellRef.mRefNum = object.getCellRef().getRefNum(); + event->addCellRef(object.getCellRef()); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); // remove from world diff --git a/apps/openmw/mwmechanics/security.cpp b/apps/openmw/mwmechanics/security.cpp index 398b8e5bc..1028a9bee 100644 --- a/apps/openmw/mwmechanics/security.cpp +++ b/apps/openmw/mwmechanics/security.cpp @@ -1,8 +1,8 @@ #include "security.hpp" -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include "../mwworld/cellstore.hpp" @@ -59,10 +59,9 @@ namespace MWMechanics if (Misc::Rng::roll0to99() <= x) { // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *lock.getCell()->getCell(); - event->cellRef.mRefID = lock.getCellRef().getRefId(); - event->cellRef.mRefNum = lock.getCellRef().getRefNum(); + event->addCellRef(lock.getCellRef()); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event); lock.getClass().unlock(lock); diff --git a/apps/openmw/mwmp/LocalEvent.cpp b/apps/openmw/mwmp/LocalEvent.cpp new file mode 100644 index 000000000..ffe9a7e85 --- /dev/null +++ b/apps/openmw/mwmp/LocalEvent.cpp @@ -0,0 +1,33 @@ +#include "LocalEvent.hpp" +#include "Networking.hpp" +#include "Main.hpp" + +using namespace mwmp; +using namespace std; + +LocalEvent::LocalEvent(RakNet::RakNetGUID guid) +{ + this->guid = guid; +} + +LocalEvent::~LocalEvent() +{ + +} + +Networking *LocalEvent::getNetworking() +{ + return mwmp::Main::get().getNetworking(); +} + +void LocalEvent::addCellRef(MWWorld::CellRef worldCellRef) +{ + cellRef.mRefID = worldCellRef.getRefId(); + cellRef.mRefNum = worldCellRef.getRefNum(); + cellRef.mGoldValue = worldCellRef.getGoldValue(); +} + +void LocalEvent::addRefId(std::string refId) +{ + cellRef.mRefID = refId; +} diff --git a/apps/openmw/mwmp/LocalEvent.hpp b/apps/openmw/mwmp/LocalEvent.hpp new file mode 100644 index 000000000..5839ffd17 --- /dev/null +++ b/apps/openmw/mwmp/LocalEvent.hpp @@ -0,0 +1,27 @@ +#ifndef OPENMW_LOCALEVENT_HPP +#define OPENMW_LOCALEVENT_HPP + +#include +#include "../mwworld/cellstore.hpp" +#include + +namespace mwmp +{ + class Networking; + class LocalEvent : public WorldEvent + { + public: + + LocalEvent(RakNet::RakNetGUID guid); + virtual ~LocalEvent(); + + void addCellRef(MWWorld::CellRef worldCellRef); + void addRefId(std::string refId); + + private: + Networking *getNetworking(); + + }; +} + +#endif //OPENMW_LOCALEVENT_HPP diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index bb762a308..bf6d8e8c7 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -26,7 +26,6 @@ #include "../mwstate/statemanagerimp.hpp" #include #include -#include #include "DedicatedPlayer.hpp" #include "LocalPlayer.hpp" #include "GUIController.hpp" @@ -732,7 +731,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet) pl = Players::getPlayer(guid); WorldPacket *myPacket = worldController.GetPacket(packet->data[0]); - WorldEvent *event = new WorldEvent(guid); + LocalEvent *event = new LocalEvent(guid); myPacket->Packet(&bsIn, event, false); switch (packet->data[0]) @@ -1123,9 +1122,9 @@ LocalPlayer *Networking::getLocalPlayer() return mwmp::Main::get().getLocalPlayer(); } -WorldEvent *Networking::createWorldEvent() +LocalEvent *Networking::createLocalEvent() { - return new WorldEvent(getLocalPlayer()->guid); + return new LocalEvent(getLocalPlayer()->guid); } bool Networking::isDedicatedPlayer(const MWWorld::Ptr &ptr) diff --git a/apps/openmw/mwmp/Networking.hpp b/apps/openmw/mwmp/Networking.hpp index 9034ce207..699a75302 100644 --- a/apps/openmw/mwmp/Networking.hpp +++ b/apps/openmw/mwmp/Networking.hpp @@ -9,6 +9,7 @@ #include #include +#include "LocalEvent.hpp" #include #include #include @@ -39,7 +40,7 @@ namespace mwmp bool isConnected(); - WorldEvent *createWorldEvent(); + LocalEvent *createLocalEvent(); private: bool connected; diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index a4142323c..cd56dccfc 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -3,9 +3,9 @@ #include #include -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/class.hpp" @@ -66,10 +66,9 @@ namespace MWScript // Added by tes3mp to check and set whether packets should be sent about this script if (mwmp::Main::isValidPacketScript(ptr.getClass().getScript(ptr))) { - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *ptr.getCell()->getCell(); - event->cellRef.mRefID = ptr.getCellRef().getRefId(); - event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); + event->addCellRef(ptr.getCellRef()); event->animGroup = group; event->animMode = mode; mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_ANIM_PLAY)->Send(event); diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 3ee66c789..95ace5750 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -10,10 +10,10 @@ #include -#include #include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include "../mwworld/esmstore.hpp" @@ -189,17 +189,16 @@ namespace MWScript // Added by tes3mp if (sendPackets) { - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *mReference.getCell()->getCell(); - event->cellRef.mRefID = mReference.getCellRef().getRefId(); - event->cellRef.mRefNum = mReference.getCellRef().getRefNum(); + event->addCellRef(mReference.getCellRef()); event->index = index; event->shortVal = value; mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_SHORT)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_SHORT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- shortVal: %i", - event->cellRef.mRefID.c_str(), - event->cellRef.mRefNum.mIndex, + mReference.getCellRef().getRefId().c_str(), + mReference.getCellRef().getRefNum().mIndex, event->cell.getDescription().c_str(), event->index, event->shortVal); @@ -226,17 +225,16 @@ namespace MWScript // Only send a packet if this float has no decimals (to avoid spam) if (sendPackets && value == (int) value) { - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *mReference.getCell()->getCell(); - event->cellRef.mRefID = mReference.getCellRef().getRefId(); - event->cellRef.mRefNum = mReference.getCellRef().getRefNum(); + event->addCellRef(mReference.getCellRef()); event->index = index; event->floatVal = value; mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_LOCAL_FLOAT)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_LOCAL_FLOAT\n- cellRef: %s, %i\n- cell: %s\n- index: %i\n- floatVal: %f", - event->cellRef.mRefID.c_str(), - event->cellRef.mRefNum.mIndex, + mReference.getCellRef().getRefId().c_str(), + mReference.getCellRef().getRefNum().mIndex, event->cell.getDescription().c_str(), event->index, event->floatVal); @@ -287,7 +285,7 @@ namespace MWScript // Added by tes3mp if (sendPackets) { - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->varName = name; event->shortVal = value; mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_GLOBAL_SHORT)->Send(event); @@ -620,14 +618,14 @@ namespace MWScript // Added by tes3mp if (sendPackets && !global) { - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); - event->cellRef.mRefID = id; + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); + event->addRefId(id); event->index = index; event->shortVal = value; mwmp::Main::get().getNetworking()->getWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i", - event->cellRef.mRefID.c_str(), + id.c_str(), event->index, event->shortVal); } diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 064188d5b..eb2673180 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -2,9 +2,9 @@ #include -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include #include @@ -90,7 +90,7 @@ namespace MWScript runtime.pop(); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->filename = name; event->allowSkipping = allowSkipping; mwmp::Main::get().getNetworking()->getWorldPacket(ID_VIDEO_PLAY)->Send(event); @@ -194,10 +194,9 @@ namespace MWScript } // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *ptr.getCell()->getCell(); - event->cellRef.mRefID = ptr.getCellRef().getRefId(); - event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); + event->addCellRef(ptr.getCellRef()); event->lockLevel = lockLevel; mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_LOCK)->Send(event); @@ -228,10 +227,9 @@ namespace MWScript MWWorld::Ptr ptr = R()(runtime); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *ptr.getCell()->getCell(); - event->cellRef.mRefID = ptr.getCellRef().getRefId(); - event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); + event->addCellRef(ptr.getCellRef()); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_UNLOCK)->Send(event); ptr.getClass().unlock (ptr); @@ -695,10 +693,9 @@ namespace MWScript if (parameter == 1) { // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *ptr.getCell()->getCell(); - event->cellRef.mRefID = ptr.getCellRef().getRefId(); - event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); + event->addCellRef(ptr.getCellRef()); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); MWBase::Environment::get().getWorld()->deleteObject(ptr); diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index aed58b59c..9bb64bf6d 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -1,8 +1,8 @@ #include "extensions.hpp" -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include #include @@ -71,7 +71,7 @@ namespace MWScript runtime.pop(); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->filename = sound; mwmp::Main::get().getNetworking()->getWorldPacket(ID_MUSIC_PLAY)->Send(event); diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 9452c3a30..8d2fdb6c5 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -1,8 +1,8 @@ #include -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include @@ -47,10 +47,9 @@ namespace MWScript runtime.pop(); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *ptr.getCell()->getCell(); - event->cellRef.mRefID = ptr.getCellRef().getRefId(); - event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); + event->addCellRef(ptr.getCellRef()); event->cellRef.mPos = ptr.getCellRef().getPosition(); event->scale = scale; mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_SCALE)->Send(event); @@ -547,10 +546,9 @@ namespace MWScript ptr.getCellRef().setRefNumIndex(cellStore->getLastRefNumIndex()); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *ptr.getCell()->getCell(); - event->cellRef.mRefID = ptr.getCellRef().getRefId(); - event->cellRef.mRefNum = ptr.getCellRef().getRefNum(); + event->addCellRef(ptr.getCellRef()); // Make sure we send the RefData position instead of the CellRef one, because that's what // we actually see on this client @@ -560,8 +558,8 @@ namespace MWScript mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_PLACE)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_PLACE\n- cellRef: %s, %i\n- count: %i", - event->cellRef.mRefID.c_str(), - event->cellRef.mRefNum.mIndex, + ptr.getCellRef().getRefId().c_str(), + ptr.getCellRef().getRefNum().mIndex, event->count); } } diff --git a/apps/openmw/mwworld/actiontake.cpp b/apps/openmw/mwworld/actiontake.cpp index e7aab6da2..e42c54821 100644 --- a/apps/openmw/mwworld/actiontake.cpp +++ b/apps/openmw/mwworld/actiontake.cpp @@ -1,9 +1,9 @@ #include "actiontake.hpp" -#include #include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include "../mwmp/LocalPlayer.hpp" #include "../mwworld/cellstore.hpp" @@ -26,15 +26,14 @@ namespace MWWorld MWWorld::Ptr newitem = *actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor); // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *getTarget().getCell()->getCell(); - event->cellRef.mRefID = getTarget().getCellRef().getRefId(); - event->cellRef.mRefNum = getTarget().getCellRef().getRefNum(); + event->addCellRef(getTarget().getCellRef()); mwmp::Main::get().getNetworking()->getWorldPacket(ID_OBJECT_DELETE)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Sending ID_OBJECT_DELETE about\n- cellRef: %s, %i\n- cell: %s.", - event->cellRef.mRefID.c_str(), - event->cellRef.mRefNum.mIndex, + getTarget().getCellRef().getRefId().c_str(), + getTarget().getCellRef().getRefNum().mIndex, event->cell.getDescription().c_str()); // LocalPlayer's inventory has changed, so send a packet with it diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 4fadcc70d..84719d30b 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -5,9 +5,9 @@ #include #include -#include #include "../mwmp/Main.hpp" #include "../mwmp/Networking.hpp" +#include "../mwmp/LocalEvent.hpp" #include #include @@ -2266,16 +2266,15 @@ namespace MWWorld } // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *door.getCell()->getCell(); - event->cellRef.mRefID = door.getCellRef().getRefId(); - event->cellRef.mRefNum = door.getCellRef().getRefNum(); + event->addCellRef(door.getCellRef()); event->state = state; mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_ACTIVATE)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 1\n- cellRef: %s, %i\n- cell: %s\n- state: %s", - event->cellRef.mRefID.c_str(), - event->cellRef.mRefNum.mIndex, + door.getCellRef().getRefId().c_str(), + door.getCellRef().getRefNum().mIndex, event->cell.getDescription().c_str(), event->state ? "true" : "false"); @@ -2286,16 +2285,15 @@ namespace MWWorld void World::activateDoor(const Ptr &door, int state) { // Added by tes3mp - mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + mwmp::LocalEvent *event = mwmp::Main::get().getNetworking()->createLocalEvent(); event->cell = *door.getCell()->getCell(); - event->cellRef.mRefID = door.getCellRef().getRefId(); - event->cellRef.mRefNum = door.getCellRef().getRefNum(); + event->addCellRef(door.getCellRef()); event->state = state; mwmp::Main::get().getNetworking()->getWorldPacket(ID_DOOR_ACTIVATE)->Send(event); LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "Door activation 2\n- cellRef: %s, %i\n- cell: %s\n- state: %s", - event->cellRef.mRefID.c_str(), - event->cellRef.mRefNum.mIndex, + door.getCellRef().getRefId().c_str(), + door.getCellRef().getRefNum().mIndex, event->cell.getDescription().c_str(), event->state ? "true" : "false");