From 14e4f6429628871eb5e4c53bdabab28385e66452 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 7 Jul 2018 17:09:57 +0300 Subject: [PATCH] [Server] Add GetVideoFilename() and SendVideoPlay() script functions --- apps/openmw-mp/Script/Functions/Objects.cpp | 15 +++++++++++++++ apps/openmw-mp/Script/Functions/Objects.hpp | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index f55d3fe42..d9d570d20 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -183,6 +183,11 @@ double ObjectFunctions::GetObjectRotZ(unsigned int i) noexcept return readObjectList->baseObjects.at(i).position.rot[2]; } +const char *ObjectFunctions::GetVideoFilename(unsigned int i) noexcept +{ + return readObjectList->baseObjects.at(i).videoFilename.c_str(); +} + unsigned int ObjectFunctions::GetContainerChangesSize(unsigned int objectIndex) noexcept { return readObjectList->baseObjects.at(objectIndex).containerItemCount; @@ -494,6 +499,16 @@ void ObjectFunctions::SendContainer(bool broadcast) noexcept packet->Send(true); } +void ObjectFunctions::SendVideoPlay(bool broadcast) noexcept +{ + mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_VIDEO_PLAY); + packet->setObjectList(&writeObjectList); + packet->Send(false); + + if (broadcast) + packet->Send(true); +} + void ObjectFunctions::SendConsoleCommand(bool broadcast) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONSOLE_COMMAND); diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index d1af735a2..1c33800c4 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -40,6 +40,8 @@ {"GetObjectRotY", ObjectFunctions::GetObjectRotY},\ {"GetObjectRotZ", ObjectFunctions::GetObjectRotZ},\ \ + {"GetVideoFilename", ObjectFunctions::GetVideoFilename},\ + \ {"GetContainerChangesSize", ObjectFunctions::GetContainerChangesSize},\ {"GetContainerItemRefId", ObjectFunctions::GetContainerItemRefId},\ {"GetContainerItemCount", ObjectFunctions::GetContainerItemCount},\ @@ -97,6 +99,7 @@ {"SendDoorState", ObjectFunctions::SendDoorState},\ {"SendDoorDestination", ObjectFunctions::SendDoorDestination},\ {"SendContainer", ObjectFunctions::SendContainer},\ + {"SendVideoPlay", ObjectFunctions::SendVideoPlay},\ {"SendConsoleCommand", ObjectFunctions::SendConsoleCommand},\ \ {"ReadLastEvent", ObjectFunctions::ReadLastEvent},\ @@ -381,6 +384,14 @@ public: */ static double GetObjectRotZ(unsigned int i) noexcept; + /** + * \brief Get the videoFilename of the object at a certain index in the read object list's object + * changes. + * + * \return The videoFilename. + */ + static const char *GetVideoFilename(unsigned int i) noexcept; + /** * \brief Get the number of container item indexes of the object at a certain index in the * read object list's object changes. @@ -865,6 +876,16 @@ public: */ static void SendContainer(bool broadcast = false) noexcept; + /** + * \brief Send a VideoPlay packet. + * + * \param broadcast Whether this packet should be sent only to the player for whom the current + * object list was initialized or to everyone on the server. + * + * \return void + */ + static void SendVideoPlay(bool broadcast = false) noexcept; + /** * \brief Send a ConsoleCommand packet. *