From 2c5cc82f4926c5ead811283aef183c07df888dc4 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 29 Jan 2017 15:29:40 +0200 Subject: [PATCH] [Server] Add script functions for getting world object placement info --- apps/openmw-mp/Script/Functions/World.cpp | 25 +++++++++++++++++++ apps/openmw-mp/Script/Functions/World.hpp | 10 ++++++++ .../Packets/World/PacketObjectPlace.cpp | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp index cbfb51762..b25986319 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -83,6 +83,31 @@ int WorldFunctions::GetObjectRefNumIndex(unsigned int i) noexcept return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].refNumIndex; } +int WorldFunctions::GetObjectCount(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].count; +} + +int WorldFunctions::GetObjectGoldValue(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].goldValue; +} + +double WorldFunctions::GetObjectPosX(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].pos.pos[0]; +} + +double WorldFunctions::GetObjectPosY(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].pos.pos[1]; +} + +double WorldFunctions::GetObjectPosZ(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects[i].pos.pos[2]; +} + 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 701e52516..ed771235c 100644 --- a/apps/openmw-mp/Script/Functions/World.hpp +++ b/apps/openmw-mp/Script/Functions/World.hpp @@ -15,6 +15,11 @@ \ {"GetObjectRefId", WorldFunctions::GetObjectRefId},\ {"GetObjectRefNumIndex", WorldFunctions::GetObjectRefNumIndex},\ + {"GetObjectCount", WorldFunctions::GetObjectCount},\ + {"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\ + {"GetObjectPosX", WorldFunctions::GetObjectPosX},\ + {"GetObjectPosY", WorldFunctions::GetObjectPosY},\ + {"GetObjectPosZ", WorldFunctions::GetObjectPosZ},\ \ {"SendObjectDelete", WorldFunctions::SendObjectDelete},\ {"SendObjectPlace", WorldFunctions::SendObjectPlace},\ @@ -40,6 +45,11 @@ public: static const char *GetObjectRefId(unsigned int i) noexcept; static int GetObjectRefNumIndex(unsigned int i) noexcept; + static int GetObjectCount(unsigned int i) noexcept; + static int GetObjectGoldValue(unsigned int i) noexcept; + static double GetObjectPosX(unsigned int i) noexcept; + static double GetObjectPosY(unsigned int i) noexcept; + static double GetObjectPosZ(unsigned int i) noexcept; static void SendObjectDelete() noexcept; static void SendObjectPlace() noexcept; diff --git a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp index 347064338..44f1ef9fc 100644 --- a/components/openmw-mp/Packets/World/PacketObjectPlace.cpp +++ b/components/openmw-mp/Packets/World/PacketObjectPlace.cpp @@ -35,9 +35,9 @@ void PacketObjectPlace::Packet(RakNet::BitStream *bs, WorldEvent *event, bool se RW(worldObject.refId, send); RW(worldObject.refNumIndex, send); + RW(worldObject.count, send); RW(worldObject.goldValue, send); RW(worldObject.pos, send); - RW(worldObject.count, send); if (!send) {