From 15bfa3007019ffe3cb61d39c0ea6ff3e359d745a Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 27 Jun 2018 02:00:16 +0300 Subject: [PATCH] [Server] Make it possible to resend received worldstates --- apps/openmw-mp/Script/Functions/Worldstate.cpp | 5 +++++ apps/openmw-mp/Script/Functions/Worldstate.hpp | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Worldstate.cpp b/apps/openmw-mp/Script/Functions/Worldstate.cpp index 825dff1f2..db90cea55 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.cpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.cpp @@ -18,6 +18,11 @@ void WorldstateFunctions::ReadLastWorldstate() noexcept readWorldstate = mwmp::Networking::getPtr()->getLastWorldstate(); } +void WorldstateFunctions::CopyLastWorldstateToStore() noexcept +{ + writeWorldstate = *readWorldstate; +} + void WorldstateFunctions::ClearMapChanges() noexcept { writeWorldstate.mapChanges.mapTiles.clear(); diff --git a/apps/openmw-mp/Script/Functions/Worldstate.hpp b/apps/openmw-mp/Script/Functions/Worldstate.hpp index 7f19de142..e14bf5776 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.hpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.hpp @@ -6,6 +6,8 @@ #define WORLDSTATEAPI \ {"ReadLastWorldstate", WorldstateFunctions::ReadLastWorldstate},\ \ + {"CopyLastWorldstateToStore", WorldstateFunctions::CopyLastWorldstateToStore},\ + \ {"ClearMapChanges", WorldstateFunctions::ClearMapChanges},\ \ {"GetMapChangesSize", WorldstateFunctions::GetMapChangesSize},\ @@ -43,6 +45,15 @@ public: */ static void ReadLastWorldstate() noexcept; + /** + * \brief Take the contents of the read-only worldstate last received by the + * server from a player and move its contents to the stored worldstate + * that can be sent by the server. + * + * \return void + */ + static void CopyLastWorldstateToStore() noexcept; + /** * \brief Clear the map changes for the write-only worldstate. *