diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index 803989d3b..d2be068c7 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -28,6 +28,7 @@ void ObjectFunctions::ClearObjectList() noexcept { writeObjectList.cell.blank(); writeObjectList.baseObjects.clear(); + writeObjectList.packetOrigin = mwmp::PACKET_ORIGIN::SERVER_SCRIPT; } void ObjectFunctions::SetObjectListPid(unsigned short pid) noexcept @@ -48,6 +49,16 @@ unsigned int ObjectFunctions::GetObjectListSize() noexcept return readObjectList->baseObjectCount; } +unsigned char ObjectFunctions::GetObjectListOrigin() noexcept +{ + return readObjectList->packetOrigin; +} + +const char *ObjectFunctions::GetObjectListClientScript() noexcept +{ + return readObjectList->originClientScript.c_str(); +} + unsigned char ObjectFunctions::GetObjectListAction() noexcept { return readObjectList->action; diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index 849a93ece..c8aa2dba8 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -10,6 +10,8 @@ {"CopyReceivedObjectListToStore", ObjectFunctions::CopyReceivedObjectListToStore},\ \ {"GetObjectListSize", ObjectFunctions::GetObjectListSize},\ + {"GetObjectListOrigin", ObjectFunctions::GetObjectListOrigin},\ + {"GetObjectListClientScript", ObjectFunctions::GetObjectListClientScript},\ {"GetObjectListAction", ObjectFunctions::GetObjectListAction},\ {"GetObjectListContainerSubAction", ObjectFunctions::GetObjectListContainerSubAction},\ \ @@ -170,6 +172,20 @@ public: */ static unsigned int GetObjectListSize() noexcept; + /** + * \brief Get the origin of the read object list. + * + * \return The origin (0 for GAMEPLAY, 1 for CONSOLE, 2 for CLIENT_SCRIPT). + */ + static unsigned char GetObjectListOrigin() noexcept; + + /** + * \brief Get the client script that the read object list originated from. + * + * \return The ID of the client script. + */ + static const char *GetObjectListClientScript() noexcept; + /** * \brief Get the action type used in the read object list. * diff --git a/components/openmw-mp/Base/BaseObject.hpp b/components/openmw-mp/Base/BaseObject.hpp index 34937e43f..885083b25 100644 --- a/components/openmw-mp/Base/BaseObject.hpp +++ b/components/openmw-mp/Base/BaseObject.hpp @@ -113,6 +113,9 @@ namespace mwmp ESM::Cell cell; std::string consoleCommand; + unsigned char packetOrigin; // 0 - Gameplay, 1 - Console, 2 - Client script, 3 - Server script + std::string originClientScript; + unsigned char action; // 0 - Clear and set in entirety, 1 - Add item, 2 - Remove item, 3 - Request items unsigned char containerSubAction; // 0 - None, 1 - Drag, 2 - Drop, 3 - Take all, 4 - Reply to request diff --git a/components/openmw-mp/Base/BaseStructs.hpp b/components/openmw-mp/Base/BaseStructs.hpp index 89c78c955..e2e27cfff 100644 --- a/components/openmw-mp/Base/BaseStructs.hpp +++ b/components/openmw-mp/Base/BaseStructs.hpp @@ -9,6 +9,14 @@ namespace mwmp { + enum PACKET_ORIGIN + { + GAMEPLAY = 0, + CONSOLE = 1, + CLIENT_SCRIPT = 2, + SERVER_SCRIPT = 3 + }; + struct Item { std::string refId; diff --git a/components/openmw-mp/Packets/Object/ObjectPacket.cpp b/components/openmw-mp/Packets/Object/ObjectPacket.cpp index 3b2dc2f6e..80d3e0291 100644 --- a/components/openmw-mp/Packets/Object/ObjectPacket.cpp +++ b/components/openmw-mp/Packets/Object/ObjectPacket.cpp @@ -48,6 +48,11 @@ bool ObjectPacket::PacketHeader(RakNet::BitStream *bs, bool send) { BasePacket::Packet(bs, send); + RW(objectList->packetOrigin, send); + + if (objectList->packetOrigin == mwmp::CLIENT_SCRIPT) + RW(objectList->originClientScript, true); + if (send) objectList->baseObjectCount = (unsigned int)(objectList->baseObjects.size()); else