mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-12-13 01:53:09 +00:00
[General] Track the client scripts that Object packets originate from
This commit is contained in:
parent
2cb16e778c
commit
4560267298
12 changed files with 50 additions and 12 deletions
|
|
@ -232,8 +232,6 @@ public:
|
||||||
/**
|
/**
|
||||||
* \brief Get the client script that the read object list originated from.
|
* \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.
|
* \return The ID of the client script.
|
||||||
*/
|
*/
|
||||||
static const char *GetObjectListClientScript() noexcept;
|
static const char *GetObjectListClientScript() noexcept;
|
||||||
|
|
|
||||||
|
|
@ -247,11 +247,13 @@ void OMW::Engine::executeLocalScripts()
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
Start of tes3mp addition
|
||||||
|
|
||||||
Mark this InterpreterContext as having a SCRIPT_LOCAL context,
|
Mark this InterpreterContext as having a SCRIPT_LOCAL context
|
||||||
so that packets sent by the Interpreter can have their
|
and as currently running the script with this name, so that
|
||||||
|
packets sent by the Interpreter can have their
|
||||||
origin determined by serverside scripts
|
origin determined by serverside scripts
|
||||||
*/
|
*/
|
||||||
interpreterContext.trackContextType(Interpreter::Context::SCRIPT_LOCAL);
|
interpreterContext.trackContextType(Interpreter::Context::SCRIPT_LOCAL);
|
||||||
|
interpreterContext.trackCurrentScriptName(script.first);
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ namespace MWScript
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
|
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addObjectAnimPlay(ptr, group, mode);
|
objectList->addObjectAnimPlay(ptr, group, mode);
|
||||||
objectList->sendObjectAnimPlay();
|
objectList->sendObjectAnimPlay();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = packetOrigin;
|
objectList->packetOrigin = packetOrigin;
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->cell = *ptr.getCell()->getCell();
|
objectList->cell = *ptr.getCell()->getCell();
|
||||||
objectList->action = mwmp::BaseObjectList::ADD;
|
objectList->action = mwmp::BaseObjectList::ADD;
|
||||||
objectList->containerSubAction = mwmp::BaseObjectList::NONE;
|
objectList->containerSubAction = mwmp::BaseObjectList::NONE;
|
||||||
|
|
@ -267,6 +268,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = packetOrigin;
|
objectList->packetOrigin = packetOrigin;
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->cell = *ptr.getCell()->getCell();
|
objectList->cell = *ptr.getCell()->getCell();
|
||||||
objectList->action = mwmp::BaseObjectList::REMOVE;
|
objectList->action = mwmp::BaseObjectList::REMOVE;
|
||||||
objectList->containerSubAction = mwmp::BaseObjectList::NONE;
|
objectList->containerSubAction = mwmp::BaseObjectList::NONE;
|
||||||
|
|
|
||||||
|
|
@ -174,11 +174,13 @@ namespace MWScript
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
Start of tes3mp addition
|
||||||
|
|
||||||
Mark this InterpreterContext as having a SCRIPT_GLOBAL context,
|
Mark this InterpreterContext as having a SCRIPT_GLOBAL context
|
||||||
so that packets sent by the Interpreter can have their
|
and as currently running the script with this name, so that
|
||||||
|
packets sent by the Interpreter can have their
|
||||||
origin determined by serverside scripts
|
origin determined by serverside scripts
|
||||||
*/
|
*/
|
||||||
context.trackContextType(Interpreter::Context::SCRIPT_GLOBAL);
|
context.trackContextType(Interpreter::Context::SCRIPT_GLOBAL);
|
||||||
|
context.trackCurrentScriptName(script.first);
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -45,17 +45,28 @@ namespace MWScript
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
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
|
unsigned short InterpreterContext::getContextType() const
|
||||||
{
|
{
|
||||||
return mContextType;
|
return mContextType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string InterpreterContext::getCurrentScriptName() const
|
||||||
|
{
|
||||||
|
return mCurrentScriptName;
|
||||||
|
}
|
||||||
|
|
||||||
void InterpreterContext::trackContextType(unsigned short contextType)
|
void InterpreterContext::trackContextType(unsigned short contextType)
|
||||||
{
|
{
|
||||||
mContextType = contextType;
|
mContextType = contextType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterpreterContext::trackCurrentScriptName(const std::string& name)
|
||||||
|
{
|
||||||
|
mCurrentScriptName = name;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
@ -216,6 +227,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
||||||
|
objectList->originClientScript = getCurrentScriptName();
|
||||||
objectList->addClientScriptLocal(mReference, index, value, mwmp::VARIABLE_TYPE::SHORT);
|
objectList->addClientScriptLocal(mReference, index, value, mwmp::VARIABLE_TYPE::SHORT);
|
||||||
objectList->sendClientScriptLocal();
|
objectList->sendClientScriptLocal();
|
||||||
}
|
}
|
||||||
|
|
@ -252,6 +264,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
||||||
|
objectList->originClientScript = getCurrentScriptName();
|
||||||
objectList->addClientScriptLocal(mReference, index, value, mwmp::VARIABLE_TYPE::LONG);
|
objectList->addClientScriptLocal(mReference, index, value, mwmp::VARIABLE_TYPE::LONG);
|
||||||
objectList->sendClientScriptLocal();
|
objectList->sendClientScriptLocal();
|
||||||
}
|
}
|
||||||
|
|
@ -294,6 +307,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
||||||
|
objectList->originClientScript = getCurrentScriptName();
|
||||||
objectList->addClientScriptLocal(mReference, index, value);
|
objectList->addClientScriptLocal(mReference, index, value);
|
||||||
objectList->sendClientScriptLocal();
|
objectList->sendClientScriptLocal();
|
||||||
}
|
}
|
||||||
|
|
@ -683,6 +697,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(getContextType());
|
||||||
|
objectList->originClientScript = getCurrentScriptName();
|
||||||
objectList->addScriptMemberShort(id, index, value);
|
objectList->addScriptMemberShort(id, index, value);
|
||||||
objectList->sendScriptMemberShort();
|
objectList->sendScriptMemberShort();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,19 @@ namespace MWScript
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
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;
|
unsigned short mContextType;
|
||||||
|
std::string mCurrentScriptName = "";
|
||||||
|
|
||||||
virtual unsigned short getContextType() const;
|
virtual unsigned short getContextType() const;
|
||||||
|
|
||||||
|
virtual std::string getCurrentScriptName() const;
|
||||||
|
|
||||||
virtual void trackContextType(unsigned short contextType);
|
virtual void trackContextType(unsigned short contextType);
|
||||||
|
|
||||||
|
virtual void trackCurrentScriptName(const std::string& name);
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList* objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList* objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addObjectState(ptr, true);
|
objectList->addObjectState(ptr, true);
|
||||||
objectList->sendObjectState();
|
objectList->sendObjectState();
|
||||||
}
|
}
|
||||||
|
|
@ -253,6 +254,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addObjectState(ptr, false);
|
objectList->addObjectState(ptr, false);
|
||||||
objectList->sendObjectState();
|
objectList->sendObjectState();
|
||||||
}
|
}
|
||||||
|
|
@ -309,6 +311,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addVideoPlay(name, allowSkipping);
|
objectList->addVideoPlay(name, allowSkipping);
|
||||||
objectList->sendVideoPlay();
|
objectList->sendVideoPlay();
|
||||||
}
|
}
|
||||||
|
|
@ -422,6 +425,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addObjectLock(ptr, lockLevel);
|
objectList->addObjectLock(ptr, lockLevel);
|
||||||
objectList->sendObjectLock();
|
objectList->sendObjectLock();
|
||||||
}
|
}
|
||||||
|
|
@ -469,6 +473,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addObjectLock(ptr, 0);
|
objectList->addObjectLock(ptr, 0);
|
||||||
objectList->sendObjectLock();
|
objectList->sendObjectLock();
|
||||||
}
|
}
|
||||||
|
|
@ -1022,6 +1027,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addObjectGeneric(ptr);
|
objectList->addObjectGeneric(ptr);
|
||||||
objectList->sendObjectDelete();
|
objectList->sendObjectDelete();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addMusicPlay(sound);
|
objectList->addMusicPlay(sound);
|
||||||
objectList->sendMusicPlay();
|
objectList->sendMusicPlay();
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
objectList->addObjectScale(ptr, scale);
|
objectList->addObjectScale(ptr, scale);
|
||||||
objectList->sendObjectScale();
|
objectList->sendObjectScale();
|
||||||
}
|
}
|
||||||
|
|
@ -573,6 +574,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
|
|
||||||
if (placed.getClass().isActor())
|
if (placed.getClass().isActor())
|
||||||
{
|
{
|
||||||
|
|
@ -658,6 +660,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
|
|
||||||
if (placed.getClass().isActor())
|
if (placed.getClass().isActor())
|
||||||
{
|
{
|
||||||
|
|
@ -736,6 +739,7 @@ namespace MWScript
|
||||||
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
mwmp::ObjectList *objectList = mwmp::Main::get().getNetworking()->getObjectList();
|
||||||
objectList->reset();
|
objectList->reset();
|
||||||
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
objectList->packetOrigin = ScriptController::getPacketOriginFromContextType(runtime.getContext().getContextType());
|
||||||
|
objectList->originClientScript = runtime.getContext().getCurrentScriptName();
|
||||||
|
|
||||||
if (ptr.getClass().isActor())
|
if (ptr.getClass().isActor())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -109,10 +109,13 @@ namespace Interpreter
|
||||||
/*
|
/*
|
||||||
Start of tes3mp addition
|
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 unsigned short getContextType() const = 0;
|
||||||
|
virtual std::string getCurrentScriptName() const = 0;
|
||||||
virtual void trackContextType(unsigned short interpreterType) = 0;
|
virtual void trackContextType(unsigned short interpreterType) = 0;
|
||||||
|
virtual void trackCurrentScriptName(const std::string& name) = 0;
|
||||||
/*
|
/*
|
||||||
End of tes3mp addition
|
End of tes3mp addition
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,8 @@ bool ObjectPacket::PacketHeader(RakNet::BitStream *newBitstream, bool send)
|
||||||
|
|
||||||
RW(objectList->packetOrigin, send);
|
RW(objectList->packetOrigin, send);
|
||||||
|
|
||||||
/* Comment this out until it's implemented properly
|
if (objectList->packetOrigin == mwmp::CLIENT_SCRIPT_LOCAL || objectList->packetOrigin == mwmp::CLIENT_SCRIPT_GLOBAL)
|
||||||
if (objectList->packetOrigin == mwmp::CLIENT_SCRIPT_LOCAL)
|
|
||||||
RW(objectList->originClientScript, send, true);
|
RW(objectList->originClientScript, send, true);
|
||||||
*/
|
|
||||||
|
|
||||||
if (send)
|
if (send)
|
||||||
objectList->baseObjectCount = (unsigned int)(objectList->baseObjects.size());
|
objectList->baseObjectCount = (unsigned int)(objectList->baseObjects.size());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue