From d4f268655655c243483cf1a5791499ba903f1902 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 13 Jul 2021 18:11:19 +0200 Subject: [PATCH] [Server] Add script functions that send ObjectMove/ObjectRotate packets --- apps/openmw-mp/Script/Functions/Objects.cpp | 22 +++++++++++++++++++ apps/openmw-mp/Script/Functions/Objects.hpp | 24 +++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index cca9ac7ef..4e5860c99 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -844,6 +844,28 @@ void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool skipAttached packet->Send(true); } +void ObjectFunctions::SendObjectMove(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +{ + mwmp::ObjectPacket* packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_MOVE); + packet->setObjectList(&writeObjectList); + + if (!skipAttachedPlayer) + packet->Send(false); + if (sendToOtherPlayers) + packet->Send(true); +} + +void ObjectFunctions::SendObjectRotate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +{ + mwmp::ObjectPacket* packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_ROTATE); + packet->setObjectList(&writeObjectList); + + if (!skipAttachedPlayer) + packet->Send(false); + if (sendToOtherPlayers) + packet->Send(true); +} + void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_STATE); diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index 82682825b..1c16a4ede 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -161,6 +161,8 @@ {"SendObjectScale", ObjectFunctions::SendObjectScale},\ {"SendObjectSound", ObjectFunctions::SendObjectSound},\ {"SendObjectState", ObjectFunctions::SendObjectState},\ + {"SendObjectMove", ObjectFunctions::SendObjectMove},\ + {"SendObjectRotate", ObjectFunctions::SendObjectRotate},\ {"SendDoorState", ObjectFunctions::SendDoorState},\ {"SendDoorDestination", ObjectFunctions::SendDoorDestination},\ {"SendContainer", ObjectFunctions::SendContainer},\ @@ -1445,6 +1447,28 @@ public: */ static void SendObjectState(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + /** + * \brief Send an ObjectMove packet. + * + * \param sendToOtherPlayers Whether this packet should be sent to players other than the + * player attached to the packet (false by default). + * \param skipAttachedPlayer Whether the packet should skip being sent to the player attached + * to the packet (false by default). + * \return void + */ + static void SendObjectMove(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + + /** + * \brief Send an ObjectRotate packet. + * + * \param sendToOtherPlayers Whether this packet should be sent to players other than the + * player attached to the packet (false by default). + * \param skipAttachedPlayer Whether the packet should skip being sent to the player attached + * to the packet (false by default). + * \return void + */ + static void SendObjectRotate(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + /** * \brief Send a DoorState packet. *