From fff6833950d6131e261189f079794da24511019e Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 27 Oct 2016 02:18:27 +0300 Subject: [PATCH] Send ID_SCRIPT_MEMBER_SHORT from MWScript::InterpreterContext --- apps/openmw/mwmp/Networking.cpp | 3 +-- apps/openmw/mwscript/interpretercontext.cpp | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmp/Networking.cpp b/apps/openmw/mwmp/Networking.cpp index eab4598df..962a4558b 100644 --- a/apps/openmw/mwmp/Networking.cpp +++ b/apps/openmw/mwmp/Networking.cpp @@ -933,13 +933,12 @@ void Networking::ProcessWorldPacket(RakNet::Packet *packet) ptrFound.getCellRef().getRefId().c_str(), ptrFound.getCellRef().getRefNum()); - ptrFound.getRefData().getLocals().mShorts.at(event->index) = event->shortVal; std::string scriptId = ptrFound.getClass().getScript(ptrFound); ptrFound.getRefData().setLocals( *MWBase::Environment::get().getWorld()->getStore().get().find(scriptId)); - ptrFound.getRefData().getLocals().mShorts[event->index] = event->shortVal;; + ptrFound.getRefData().getLocals().mShorts.at(event->index) = event->shortVal;; } break; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index da799f9f9..6165d8981 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -603,7 +603,25 @@ namespace MWScript Locals& locals = getMemberLocals (scriptId, global); - locals.mShorts[findLocalVariableIndex (scriptId, name, 's')] = value; + // Added by tes3mp so it can be reused by it + int index = findLocalVariableIndex(scriptId, name, 's'); + + locals.mShorts[index] = value; + + // Added by tes3mp + if (sendPackets && !global) + { + mwmp::WorldEvent *event = mwmp::Main::get().getNetworking()->createWorldEvent(); + event->cellRef.mRefID = id; + event->varName = name; + event->shortVal = value; + mwmp::Main::get().getNetworking()->GetWorldPacket(ID_SCRIPT_MEMBER_SHORT)->Send(event); + + printf("Sending ID_SCRIPT_MEMBER_SHORT\n- cellRef: %s\n- index: %i\n- shortVal: %i\n", + event->cellRef.mRefID.c_str(), + event->index, + event->shortVal); + } } void InterpreterContext::setMemberLong (const std::string& id, const std::string& name, int value, bool global)