[Client] Record type of each InterpreterContext for later checking

pull/471/head
David Cernat 6 years ago
parent d4a84ac34a
commit 63a86f145d

@ -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);
}
}

@ -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);

@ -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<Interpreter::Type_Code> code;

@ -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);
}
}

@ -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
{

@ -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;

@ -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
*/
};
}

Loading…
Cancel
Save