From af35ee38d174b4ecd983e38301f503b166f44ab0 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 23 Feb 2017 08:23:46 +0200 Subject: [PATCH] [Server] Rename ClearScriptEvent into InitScriptEvent with pid argument --- apps/openmw-mp/Script/Functions/World.cpp | 55 ++++++++--------------- apps/openmw-mp/Script/Functions/World.hpp | 18 ++++---- 2 files changed, 28 insertions(+), 45 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp index 443823941..572838e2b 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -15,10 +15,14 @@ ContainerItem tempContainerItem; std::regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$"); -void WorldFunctions::ClearScriptEvent() noexcept +void WorldFunctions::InitScriptEvent(unsigned short pid) noexcept { + Player *player; + GET_PLAYER(pid, player, ); + scriptEvent.cell.blank(); scriptEvent.objectChanges.objects.clear(); + scriptEvent.guid = player->guid; } unsigned int WorldFunctions::GetObjectChangesSize() noexcept @@ -256,60 +260,39 @@ void WorldFunctions::AddContainerItem() noexcept tempWorldObject.containerChanges.items.push_back(containerItem); } -void WorldFunctions::SendObjectDelete(unsigned short pid) noexcept +void WorldFunctions::SendObjectDelete() noexcept { - Player *player; - GET_PLAYER(pid, player, ); - - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(&scriptEvent, player->guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_DELETE)->Send(&scriptEvent, scriptEvent.guid); } -void WorldFunctions::SendObjectPlace(unsigned short pid) noexcept +void WorldFunctions::SendObjectPlace() noexcept { - Player *player; - GET_PLAYER(pid, player, ); - - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_PLACE)->Send(&scriptEvent, player->guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_PLACE)->Send(&scriptEvent, scriptEvent.guid); } -void WorldFunctions::SendObjectScale(unsigned short pid) noexcept +void WorldFunctions::SendObjectScale() noexcept { - Player *player; - GET_PLAYER(pid, player, ); - - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_SCALE)->Send(&scriptEvent, player->guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_SCALE)->Send(&scriptEvent, scriptEvent.guid); } -void WorldFunctions::SendObjectLock(unsigned short pid) noexcept +void WorldFunctions::SendObjectLock() noexcept { - Player *player; - GET_PLAYER(pid, player, ); - - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_LOCK)->Send(&scriptEvent, player->guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_LOCK)->Send(&scriptEvent, scriptEvent.guid); } -void WorldFunctions::SendObjectUnlock(unsigned short pid) noexcept +void WorldFunctions::SendObjectUnlock() noexcept { - Player *player; - GET_PLAYER(pid, player, ); - - mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_UNLOCK)->Send(&scriptEvent, player->guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_UNLOCK)->Send(&scriptEvent, scriptEvent.guid); } -void WorldFunctions::SendDoorState(unsigned short pid) noexcept +void WorldFunctions::SendDoorState() noexcept { - Player *player; - GET_PLAYER(pid, player, ); - - mwmp::Networking::get().getWorldController()->GetPacket(ID_DOOR_STATE)->Send(&scriptEvent, player->guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_DOOR_STATE)->Send(&scriptEvent, scriptEvent.guid); } -void WorldFunctions::SendContainer(unsigned short pid) noexcept +void WorldFunctions::SendContainer() noexcept { - Player *player; - GET_PLAYER(pid, player, ); - - mwmp::Networking::get().getWorldController()->GetPacket(ID_CONTAINER)->Send(&scriptEvent, player->guid); + mwmp::Networking::get().getWorldController()->GetPacket(ID_CONTAINER)->Send(&scriptEvent, scriptEvent.guid); } void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept diff --git a/apps/openmw-mp/Script/Functions/World.hpp b/apps/openmw-mp/Script/Functions/World.hpp index b50a77f5f..30d196b07 100644 --- a/apps/openmw-mp/Script/Functions/World.hpp +++ b/apps/openmw-mp/Script/Functions/World.hpp @@ -2,7 +2,7 @@ #define OPENMW_WORLD_HPP #define WORLDFUNCTIONS \ - {"ClearScriptEvent", WorldFunctions::ClearScriptEvent},\ + {"InitScriptEvent", WorldFunctions::InitScriptEvent},\ \ {"GetObjectChangesSize", WorldFunctions::GetObjectChangesSize},\ {"GetLastEventAction", WorldFunctions::GetLastEventAction},\ @@ -65,7 +65,7 @@ class WorldFunctions { public: - static void ClearScriptEvent() noexcept; + static void InitScriptEvent(unsigned short pid) noexcept; static unsigned int GetObjectChangesSize() noexcept; static unsigned int GetLastEventAction() noexcept; @@ -112,13 +112,13 @@ public: static void AddWorldObject() noexcept; static void AddContainerItem() noexcept; - static void SendObjectDelete(unsigned short pid) noexcept; - static void SendObjectPlace(unsigned short pid) noexcept; - static void SendObjectScale(unsigned short pid) noexcept; - static void SendObjectLock(unsigned short pid) noexcept; - static void SendObjectUnlock(unsigned short pid) noexcept; - static void SendDoorState(unsigned short pid) noexcept; - static void SendContainer(unsigned short pid) noexcept; + static void SendObjectDelete() noexcept; + static void SendObjectPlace() noexcept; + static void SendObjectScale() noexcept; + static void SendObjectLock() noexcept; + static void SendObjectUnlock() noexcept; + static void SendDoorState() noexcept; + static void SendContainer() noexcept; static void SetHour(unsigned short pid, double hour) noexcept; static void SetMonth(unsigned short pid, int month) noexcept;