From 27ac314cb1c8a3eab44fd72669b170db90bf93f9 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 29 Jan 2017 13:21:41 +0200 Subject: [PATCH] [Server] Add script functions for getting world object refIds & refNums --- apps/openmw-mp/Script/Functions/Cells.hpp | 6 +++--- apps/openmw-mp/Script/Functions/World.cpp | 15 +++++++++++++++ apps/openmw-mp/Script/Functions/World.hpp | 10 ++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Cells.hpp b/apps/openmw-mp/Script/Functions/Cells.hpp index cbefe7df7..a802a0b92 100644 --- a/apps/openmw-mp/Script/Functions/Cells.hpp +++ b/apps/openmw-mp/Script/Functions/Cells.hpp @@ -5,16 +5,16 @@ #define CELLAPI \ {"GetCellStateChangesSize", CellFunctions::GetCellStateChangesSize},\ -\ + \ {"GetCellStateDescription", CellFunctions::GetCellStateDescription},\ -\ + \ {"GetCell", CellFunctions::GetCell},\ {"SetCell", CellFunctions::SetCell},\ {"SetExterior", CellFunctions::SetExterior},\ {"GetExteriorX", CellFunctions::GetExteriorX},\ {"GetExteriorY", CellFunctions::GetExteriorY},\ {"IsInExterior", CellFunctions::IsInExterior},\ -\ + \ {"SendCell", CellFunctions::SendCell} diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp index 701d9d1e5..cbfb51762 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -68,6 +68,21 @@ void WorldFunctions::SetObjectPosition(unsigned int i, double x, double y, doubl worldEvent->objectChanges.objects[i].pos.pos[2] = z; } +unsigned int WorldFunctions::GetObjectChangesSize() noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.count; +} + +const char *WorldFunctions::GetObjectRefId(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].refId.c_str(); +} + +int WorldFunctions::GetObjectRefNumIndex(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].refNumIndex; +} + void WorldFunctions::SendObjectDelete() noexcept { mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(worldEvent, worldEvent->guid); diff --git a/apps/openmw-mp/Script/Functions/World.hpp b/apps/openmw-mp/Script/Functions/World.hpp index 77e56d38d..701e52516 100644 --- a/apps/openmw-mp/Script/Functions/World.hpp +++ b/apps/openmw-mp/Script/Functions/World.hpp @@ -11,6 +11,11 @@ {"SetObjectRefNumIndex", WorldFunctions::SetObjectRefNumIndex},\ {"SetObjectPosition", WorldFunctions::SetObjectPosition},\ \ + {"GetObjectChangesSize", WorldFunctions::GetObjectChangesSize},\ + \ + {"GetObjectRefId", WorldFunctions::GetObjectRefId},\ + {"GetObjectRefNumIndex", WorldFunctions::GetObjectRefNumIndex},\ + \ {"SendObjectDelete", WorldFunctions::SendObjectDelete},\ {"SendObjectPlace", WorldFunctions::SendObjectPlace},\ \ @@ -31,6 +36,11 @@ public: static void SetObjectRefNumIndex(unsigned int i, int refNumIndex) noexcept; static void SetObjectPosition(unsigned int i, double x, double y, double z) noexcept; + static unsigned int GetObjectChangesSize() noexcept; + + static const char *GetObjectRefId(unsigned int i) noexcept; + static int GetObjectRefNumIndex(unsigned int i) noexcept; + static void SendObjectDelete() noexcept; static void SendObjectPlace() noexcept;