From 1a7060c5c51b347f0a6b1f97f90133f7f267cffe Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 27 Feb 2020 14:53:03 +0200 Subject: [PATCH] [Server] Add server functions for handling the droppedByPlayer boolean --- apps/openmw-mp/Script/Functions/Objects.cpp | 11 ++++++++++- apps/openmw-mp/Script/Functions/Objects.hpp | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index 81a414b42..9907e4c2d 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -380,6 +380,11 @@ bool ObjectFunctions::DoesObjectHaveContainer(unsigned int index) noexcept return readObjectList->baseObjects.at(index).hasContainer; } +bool ObjectFunctions::IsObjectDroppedByPlayer(unsigned int index) noexcept +{ + return readObjectList->baseObjects.at(index).droppedByPlayer; +} + void ObjectFunctions::SetObjectListCell(const char* cellDescription) noexcept { writeObjectList.cell = Utils::getCellFromDescription(cellDescription); @@ -455,6 +460,11 @@ void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept tempObject.isDisarmed = disarmState; } +void ObjectFunctions::SetObjectDroppedByPlayerState(bool droppedByPlayer) noexcept +{ + tempObject.droppedByPlayer = droppedByPlayer; +} + void ObjectFunctions::SetObjectPosition(double x, double y, double z) noexcept { tempObject.position.pos[0] = x; @@ -598,7 +608,6 @@ void ObjectFunctions::SetContainerItemActionCountByIndex(unsigned int objectInde void ObjectFunctions::AddObject() noexcept { - tempObject.droppedByPlayer = false; writeObjectList.baseObjects.push_back(tempObject); tempObject = emptyObject; diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index ffb219043..c01d41f85 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -80,6 +80,7 @@ {"GetContainerItemActionCount", ObjectFunctions::GetContainerItemActionCount},\ \ {"DoesObjectHaveContainer", ObjectFunctions::DoesObjectHaveContainer},\ + {"IsObjectDroppedByPlayer", ObjectFunctions::IsObjectDroppedByPlayer},\ \ {"SetObjectListCell", ObjectFunctions::SetObjectListCell},\ {"SetObjectListAction", ObjectFunctions::SetObjectListAction},\ @@ -97,6 +98,7 @@ {"SetObjectState", ObjectFunctions::SetObjectState},\ {"SetObjectLockLevel", ObjectFunctions::SetObjectLockLevel},\ {"SetObjectDisarmState", ObjectFunctions::SetObjectDisarmState},\ + {"SetObjectDroppedByPlayerState", ObjectFunctions::SetObjectDroppedByPlayerState},\ {"SetObjectPosition", ObjectFunctions::SetObjectPosition},\ {"SetObjectRotation", ObjectFunctions::SetObjectRotation},\ \ @@ -732,6 +734,17 @@ public: */ static bool DoesObjectHaveContainer(unsigned int index) noexcept; + /** + * \brief Check whether the object at a certain index in the read object list has been + * dropped by a player. + * + * Note: Only ObjectLists from ObjectPlace packets contain this information. + * + * \param index The index of the object. + * \return Whether the object has been dropped by a player. + */ + static bool IsObjectDroppedByPlayer(unsigned int index) noexcept; + /** * \brief Set the cell of the temporary object list stored on the server. * @@ -883,6 +896,14 @@ public: */ static void SetObjectDisarmState(bool disarmState) noexcept; + /** + * \brief Set the droppedByPlayer state of the temporary object stored on the server. + * + * \param droppedByPlayer Whether the object has been dropped by a player or not. + * \return void + */ + static void SetObjectDroppedByPlayerState(bool dropedByPlayerState) noexcept; + /** * \brief Set the position of the temporary object stored on the server. *