From d8ca2680679c4694e03819816498606c9b2879b8 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 30 Nov 2018 22:43:10 +0200 Subject: [PATCH] [Server] Move plugin enforcement functions to ServerFunctions --- .../Script/Functions/Miscellaneous.cpp | 10 ---- .../Script/Functions/Miscellaneous.hpp | 22 ------- apps/openmw-mp/Script/Functions/Server.cpp | 10 ++++ apps/openmw-mp/Script/Functions/Server.hpp | 57 +++++++++++++------ 4 files changed, 49 insertions(+), 50 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp index 669f18380..d9e55e4c8 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.cpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.cpp @@ -48,16 +48,6 @@ void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept mwmp::Networking::getPtr()->setCurrentMpNum(mpNum); } -int MiscellaneousFunctions::GetPluginEnforcementState() noexcept -{ - return mwmp::Networking::getPtr()->getPluginEnforcementState(); -} - -void MiscellaneousFunctions::SetPluginEnforcementState(bool state) noexcept -{ - mwmp::Networking::getPtr()->setPluginEnforcementState(state); -} - void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept { LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message); diff --git a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp index 2d5a02b9b..bd3f211c7 100644 --- a/apps/openmw-mp/Script/Functions/Miscellaneous.hpp +++ b/apps/openmw-mp/Script/Functions/Miscellaneous.hpp @@ -12,9 +12,6 @@ {"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\ {"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\ \ - {"GetPluginEnforcementState", MiscellaneousFunctions::GetPluginEnforcementState},\ - {"SetPluginEnforcementState", MiscellaneousFunctions::SetPluginEnforcementState},\ - \ {"LogMessage", MiscellaneousFunctions::LogMessage},\ {"LogAppend", MiscellaneousFunctions::LogAppend} @@ -79,25 +76,6 @@ public: */ static void SetCurrentMpNum(int mpNum) noexcept; - /** - * \brief Get the plugin enforcement state of the server. - * - * If true, clients are required to use the same plugins as set for the server. - * - * \return The enforcement state. - */ - static int GetPluginEnforcementState() noexcept; - - /** - * \brief Set the plugin enforcement state of the server. - * - * If true, clients are required to use the same plugins as set for the server. - * - * \param state The new enforcement state. - * \return void - */ - static void SetPluginEnforcementState(bool state) noexcept; - /** * \brief Write a log message with its own timestamp. * diff --git a/apps/openmw-mp/Script/Functions/Server.cpp b/apps/openmw-mp/Script/Functions/Server.cpp index 30d1b3d4d..a0b1faa8f 100644 --- a/apps/openmw-mp/Script/Functions/Server.cpp +++ b/apps/openmw-mp/Script/Functions/Server.cpp @@ -75,6 +75,11 @@ bool ServerFunctions::HasPassword() noexcept return mwmp::Networking::get().isPassworded(); } +int ServerFunctions::GetPluginEnforcementState() noexcept +{ + return mwmp::Networking::getPtr()->getPluginEnforcementState(); +} + void ServerFunctions::SetGameMode(const char *gameMode) noexcept { if (mwmp::Networking::getPtr()->getMasterClient()) @@ -92,6 +97,11 @@ void ServerFunctions::SetServerPassword(const char *password) noexcept mwmp::Networking::getPtr()->setServerPassword(password); } +void ServerFunctions::SetPluginEnforcementState(bool state) noexcept +{ + mwmp::Networking::getPtr()->setPluginEnforcementState(state); +} + void ServerFunctions::SetRuleString(const char *key, const char *value) noexcept { auto mc = mwmp::Networking::getPtr()->getMasterClient(); diff --git a/apps/openmw-mp/Script/Functions/Server.hpp b/apps/openmw-mp/Script/Functions/Server.hpp index e75e3d39d..a8cfd5abf 100644 --- a/apps/openmw-mp/Script/Functions/Server.hpp +++ b/apps/openmw-mp/Script/Functions/Server.hpp @@ -4,26 +4,28 @@ #include "../Types.hpp" #define SERVERAPI \ - {"StopServer", ServerFunctions::StopServer},\ + {"StopServer", ServerFunctions::StopServer},\ \ - {"Kick", ServerFunctions::Kick},\ - {"BanAddress", ServerFunctions::BanAddress},\ - {"UnbanAddress", ServerFunctions::UnbanAddress},\ + {"Kick", ServerFunctions::Kick},\ + {"BanAddress", ServerFunctions::BanAddress},\ + {"UnbanAddress", ServerFunctions::UnbanAddress},\ \ - {"GetServerVersion", ServerFunctions::GetServerVersion},\ - {"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\ - {"GetAvgPing", ServerFunctions::GetAvgPing},\ - {"GetIP", ServerFunctions::GetIP},\ - {"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\ - {"GetPort", ServerFunctions::GetPort},\ - {"HasPassword", ServerFunctions::HasPassword},\ + {"GetServerVersion", ServerFunctions::GetServerVersion},\ + {"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\ + {"GetAvgPing", ServerFunctions::GetAvgPing},\ + {"GetIP", ServerFunctions::GetIP},\ + {"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\ + {"GetPort", ServerFunctions::GetPort},\ + {"HasPassword", ServerFunctions::HasPassword},\ + {"GetPluginEnforcementState", ServerFunctions::GetPluginEnforcementState},\ \ - {"SetGameMode", ServerFunctions::SetGameMode},\ - {"SetHostname", ServerFunctions::SetHostname},\ - {"SetServerPassword", ServerFunctions::SetServerPassword},\ - {"SetRuleString", ServerFunctions::SetRuleString},\ - {"SetRuleValue", ServerFunctions::SetRuleValue},\ - {"AddPluginHash", ServerFunctions::AddPluginHash} + {"SetGameMode", ServerFunctions::SetGameMode},\ + {"SetHostname", ServerFunctions::SetHostname},\ + {"SetServerPassword", ServerFunctions::SetServerPassword},\ + {"SetPluginEnforcementState", ServerFunctions::SetPluginEnforcementState},\ + {"SetRuleString", ServerFunctions::SetRuleString},\ + {"SetRuleValue", ServerFunctions::SetRuleValue},\ + {"AddPluginHash", ServerFunctions::AddPluginHash} class ServerFunctions { @@ -112,6 +114,15 @@ public: */ static bool HasPassword() noexcept; + /** + * \brief Get the plugin enforcement state of the server. + * + * If true, clients are required to use the same plugins as set for the server. + * + * \return The enforcement state. + */ + static int GetPluginEnforcementState() noexcept; + /** * \brief Set the game mode of the server, as displayed in the server browser. * @@ -134,7 +145,17 @@ public: * \param password The password. * \return void */ - static void SetServerPassword(const char *passw) noexcept; + static void SetServerPassword(const char *password) noexcept; + + /** + * \brief Set the plugin enforcement state of the server. + * + * If true, clients are required to use the same plugins as set for the server. + * + * \param state The new enforcement state. + * \return void + */ + static void SetPluginEnforcementState(bool state) noexcept; /** * \brief Set a rule string for the server details displayed in the server browser.