[General] Track the client scripts that Object packets originate from

pull/593/head
David Cernat 4 years ago
parent 2cb16e778c
commit 4560267298

@ -232,8 +232,6 @@ public:
/**
* \brief Get the client script that the read object list originated from.
*
* Note: This is not yet implemented.
*
* \return The ID of the client script.
*/
static const char *GetObjectListClientScript() noexcept;

@ -247,11 +247,13 @@ void OMW::Engine::executeLocalScripts()
/*
Start of tes3mp addition
Mark this InterpreterContext as having a SCRIPT_LOCAL context,
so that packets sent by the Interpreter can have their
Mark this InterpreterContext as having a SCRIPT_LOCAL context
and as currently running the script with this name, so that
packets sent by the Interpreter can have their
origin determined by serverside scripts
*/
interpreterContext.trackContextType(Interpreter::Context::SCRIPT_LOCAL);
interpreterContext.trackCurrentScriptName(script.first);
/*
End of tes3mp addition
*/

@ -86,6 +86,7 @@ namespace MWScript
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addObjectAnimPlay(ptr, group, mode);
objectList->sendObjectAnimPlay();
}

@ -140,6 +140,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = packetOrigin;
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->cell = *ptr.getCell()->getCell();
objectList->action = mwmp::BaseObjectList::ADD;
objectList->containerSubAction = mwmp::BaseObjectList::NONE;
@ -267,6 +268,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = packetOrigin;
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->cell = *ptr.getCell()->getCell();
objectList->action = mwmp::BaseObjectList::REMOVE;
objectList->containerSubAction = mwmp::BaseObjectList::NONE;

@ -174,11 +174,13 @@ namespace MWScript
/*
Start of tes3mp addition
Mark this InterpreterContext as having a SCRIPT_GLOBAL context,
so that packets sent by the Interpreter can have their
Mark this InterpreterContext as having a SCRIPT_GLOBAL context
and as currently running the script with this name, so that
packets sent by the Interpreter can have their
origin determined by serverside scripts
*/
context.trackContextType(Interpreter::Context::SCRIPT_GLOBAL);
context.trackCurrentScriptName(script.first);
/*
End of tes3mp addition
*/

@ -45,17 +45,28 @@ namespace MWScript
/*
Start of tes3mp addition
Used for tracking and checking the type of this InterpreterContext
Used for tracking and checking the type of this InterpreterContext, as well as
its current script
*/
unsigned short InterpreterContext::getContextType() const
{
return mContextType;
}
std::string InterpreterContext::getCurrentScriptName() const
{
return mCurrentScriptName;
}
void InterpreterContext::trackContextType(unsigned short contextType)
{
mContextType = contextType;
}
void InterpreterContext::trackCurrentScriptName(const std::string& name)
{
mCurrentScriptName = name;
}
/*
End of tes3mp addition
*/
@ -216,6 +227,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
objectList->originClientScript = getCurrentScriptName();
objectList->addClientScriptLocal(mReference, index, value, mwmp::VARIABLE_TYPE::SHORT);
objectList->sendClientScriptLocal();
}
@ -252,6 +264,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
objectList->originClientScript = getCurrentScriptName();
objectList->addClientScriptLocal(mReference, index, value, mwmp::VARIABLE_TYPE::LONG);
objectList->sendClientScriptLocal();
}
@ -294,6 +307,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
objectList->originClientScript = getCurrentScriptName();
objectList->addClientScriptLocal(mReference, index, value);
objectList->sendClientScriptLocal();
}
@ -683,6 +697,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
objectList->originClientScript = getCurrentScriptName();
objectList->addScriptMemberShort(id, index, value);
objectList->sendScriptMemberShort();
}

@ -71,13 +71,19 @@ namespace MWScript
/*
Start of tes3mp addition
Used for tracking and checking the type of this InterpreterContext
Used for tracking and checking the type of this InterpreterContext, as well as
its current script
*/
unsigned short mContextType;
std::string mCurrentScriptName = "";
virtual unsigned short getContextType() const;
virtual std::string getCurrentScriptName() const;
virtual void trackContextType(unsigned short contextType);
virtual void trackCurrentScriptName(const std::string& name);
/*
End of tes3mp addition
*/

@ -205,6 +205,7 @@ namespace MWScript
mwmp::ObjectList* objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addObjectState(ptr, true);
objectList->sendObjectState();
}
@ -253,6 +254,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addObjectState(ptr, false);
objectList->sendObjectState();
}
@ -309,6 +311,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addVideoPlay(name, allowSkipping);
objectList->sendVideoPlay();
}
@ -422,6 +425,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addObjectLock(ptr, lockLevel);
objectList->sendObjectLock();
}
@ -469,6 +473,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addObjectLock(ptr, 0);
objectList->sendObjectLock();
}
@ -1022,6 +1027,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addObjectGeneric(ptr);
objectList->sendObjectDelete();
}

@ -90,6 +90,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addMusicPlay(sound);
objectList->sendMusicPlay();
/*

@ -150,6 +150,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
objectList->addObjectScale(ptr, scale);
objectList->sendObjectScale();
}
@ -573,6 +574,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
if (placed.getClass().isActor())
{
@ -658,6 +660,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
if (placed.getClass().isActor())
{
@ -736,6 +739,7 @@ namespace MWScript
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
objectList->reset();
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
if (ptr.getClass().isActor())
{

@ -109,10 +109,13 @@ namespace Interpreter
/*
Start of tes3mp addition
Used for tracking and checking the type of this Context
Used for tracking and checking the type of this Context, as well as
its current script
*/
virtual unsigned short getContextType() const = 0;
virtual std::string getCurrentScriptName() const = 0;
virtual void trackContextType(unsigned short interpreterType) = 0;
virtual void trackCurrentScriptName(const std::string& name) = 0;
/*
End of tes3mp addition
*/

@ -50,10 +50,8 @@ bool ObjectPacket::PacketHeader(RakNet::BitStream *newBitstream, bool send)
RW(objectList->packetOrigin, send);
/* Comment this out until it's implemented properly
if (objectList->packetOrigin == mwmp::CLIENT_SCRIPT_LOCAL)
if (objectList->packetOrigin == mwmp::CLIENT_SCRIPT_LOCAL || objectList->packetOrigin == mwmp::CLIENT_SCRIPT_GLOBAL)
RW(objectList->originClientScript, send, true);
*/
if (send)
objectList->baseObjectCount = (unsigned int)(objectList->baseObjects.size());

Loading…
Cancel
Save