diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index f3cc912c3..68aa1c102 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -104,6 +104,18 @@ void OMW::Engine::executeLocalScripts() End of tes3mp addition */ + /* + Start of tes3mp addition + + Mark this InterpreterContext as having a CONSOLE context, + so that packets sent by the Interpreter can have their + origin determined by serverside scripts + */ + interpreterContext.setContextType(Interpreter::Context::SCRIPT_LOCAL); + /* + End of tes3mp addition + */ + mEnvironment.getScriptManager()->run (script.first, interpreterContext); } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 8915a6e7e..4949dca4f 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -262,6 +262,19 @@ namespace MWDialogue try { MWScript::InterpreterContext interpreterContext(&actor.getRefData().getLocals(), actor); + + /* + Start of tes3mp addition + + Mark this InterpreterContext as having a CONSOLE context, + so that packets sent by the Interpreter can have their + origin determined by serverside scripts + */ + interpreterContext.setContextType(Interpreter::Context::DIALOGUE); + /* + End of tes3mp addition + */ + Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); interpreter.run (&code[0], code.size(), interpreterContext); diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 22ad992bb..aba87c0ca 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -186,6 +186,19 @@ namespace MWGui try { ConsoleInterpreterContext interpreterContext (*this, mPtr); + + /* + Start of tes3mp addition + + Mark this InterpreterContext as having a CONSOLE context, + so that packets sent by the Interpreter can have their + origin determined by serverside scripts + */ + interpreterContext.setContextType(Interpreter::Context::CONSOLE); + /* + End of tes3mp addition + */ + Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter, mConsoleOnlyScripts); std::vector code; diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 6074a12d0..570d60f20 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -79,6 +79,18 @@ namespace MWScript MWScript::InterpreterContext interpreterContext ( &iter->second.mLocals, MWWorld::Ptr(), iter->second.mId); + /* + Start of tes3mp addition + + Mark this InterpreterContext as having a GLOBAL_SCRIPT context, + so that packets sent by the Interpreter can have their + origin determined by serverside scripts + */ + interpreterContext.setContextType(Interpreter::Context::SCRIPT_GLOBAL); + /* + End of tes3mp addition + */ + MWBase::Environment::get().getScriptManager()->run (iter->first, interpreterContext); } } diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 196e85d55..f26ecec15 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -63,6 +63,24 @@ namespace MWScript } } + /* + Start of tes3mp addition + + Used for setting and checking the type of this InterpreterContext + */ + unsigned short InterpreterContext::getContextType() const + { + return mContextType; + } + + void InterpreterContext::setContextType(unsigned short contextType) + { + mContextType = contextType; + } + /* + End of tes3mp addition + */ + const MWWorld::Ptr InterpreterContext::getReferenceImp ( const std::string& id, bool activeOnly, bool doThrow) const { diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 9219789eb..d46894a5e 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -63,6 +63,20 @@ namespace MWScript End of tes3mp addition */ + /* + Start of tes3mp addition + + Used for setting and checking the type of this InterpreterContext + */ + unsigned short mContextType; + + virtual unsigned short getContextType() const; + + virtual void setContextType(unsigned short contextType); + /* + End of tes3mp addition + */ + virtual int getLocalShort (int index) const; virtual int getLocalLong (int index) const; diff --git a/components/interpreter/context.hpp b/components/interpreter/context.hpp index 881687366..601b81cc6 100644 --- a/components/interpreter/context.hpp +++ b/components/interpreter/context.hpp @@ -10,6 +10,22 @@ namespace Interpreter { public: + /* + Start of tes3mp addition + + Keep an enumeration of the possible context types + */ + enum CONTEXT_TYPE + { + CONSOLE = 0, + DIALOGUE = 1, + SCRIPT_LOCAL = 2, + SCRIPT_GLOBAL = 3 + }; + /* + End of tes3mp addition + */ + virtual ~Context() {} virtual int getLocalShort (int index) const = 0; @@ -110,6 +126,17 @@ namespace Interpreter = 0; virtual std::string getTargetId() const = 0; + + /* + Start of tes3mp addition + + Used for setting and checking the type of this Context + */ + virtual unsigned short getContextType() const = 0; + virtual void setContextType(unsigned short interpreterType) = 0; + /* + End of tes3mp addition + */ }; }