diff --git a/apps/openmw-mp/Script/Functions/Settings.cpp b/apps/openmw-mp/Script/Functions/Settings.cpp index c158a282d..24e914036 100644 --- a/apps/openmw-mp/Script/Functions/Settings.cpp +++ b/apps/openmw-mp/Script/Functions/Settings.cpp @@ -25,12 +25,20 @@ void SettingFunctions::SetConsoleAllowed(unsigned short pid, bool state) player->consoleAllowed = state; } -void SettingFunctions::SetRestAllowed(unsigned short pid, bool state) +void SettingFunctions::SetBedRestAllowed(unsigned short pid, bool state) { Player *player; GET_PLAYER(pid, player, ); - player->restAllowed = state; + player->bedRestAllowed = state; +} + +void SettingFunctions::SetWildernessRestAllowed(unsigned short pid, bool state) +{ + Player *player; + GET_PLAYER(pid, player, ); + + player->wildernessRestAllowed = state; } void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state) diff --git a/apps/openmw-mp/Script/Functions/Settings.hpp b/apps/openmw-mp/Script/Functions/Settings.hpp index 7c4e9a032..e0db786fe 100644 --- a/apps/openmw-mp/Script/Functions/Settings.hpp +++ b/apps/openmw-mp/Script/Functions/Settings.hpp @@ -4,12 +4,13 @@ #include "../Types.hpp" #define SETTINGSAPI \ - {"SetDifficulty", SettingFunctions::SetDifficulty},\ - {"SetConsoleAllowed", SettingFunctions::SetConsoleAllowed},\ - {"SetRestAllowed", SettingFunctions::SetRestAllowed},\ - {"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\ + {"SetDifficulty", SettingFunctions::SetDifficulty},\ + {"SetConsoleAllowed", SettingFunctions::SetConsoleAllowed},\ + {"SetBedRestAllowed", SettingFunctions::SetBedRestAllowed},\ + {"SetWildernessRestAllowed", SettingFunctions::SetWildernessRestAllowed},\ + {"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\ \ - {"SendSettings", SettingFunctions::SendSettings} + {"SendSettings", SettingFunctions::SendSettings} class SettingFunctions { @@ -40,7 +41,7 @@ public: static void SetConsoleAllowed(unsigned short pid, bool state); /** - * \brief Set whether resting is allowed for a player. + * \brief Set whether resting in beds is allowed for a player. * * This changes the resting permission for that player in the server memory, but does not * by itself send a packet. @@ -49,7 +50,19 @@ public: * \param bool The resting permission state. * \return void */ - static void SetRestAllowed(unsigned short pid, bool state); + static void SetBedRestAllowed(unsigned short pid, bool state); + + /** + * \brief Set whether resting in the wilderness is allowed for a player. + * + * This changes the resting permission for that player in the server memory, but does not + * by itself send a packet. + * + * \param pid The player ID. + * \param bool The resting permission state. + * \return void + */ + static void SetWildernessRestAllowed(unsigned short pid, bool state); /** * \brief Set whether waiting is allowed for a player. diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 6e4cd4a97..6ce192559 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1019,9 +1019,9 @@ namespace MWInput */ int canRest = MWBase::Environment::get().getWorld()->canRest(); - if (canRest == 0 && !mwmp::Main::get().getLocalPlayer()->restAllowed) + if (canRest == 0 && !mwmp::Main::get().getLocalPlayer()->wildernessRestAllowed) { - MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to rest."); + MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to rest in the wilderness."); return; } else if (canRest == 1 && !mwmp::Main::get().getLocalPlayer()->waitAllowed) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index ed578035d..3f464958d 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -50,7 +50,8 @@ LocalPlayer::LocalPlayer() difficulty = 0; consoleAllowed = false; - restAllowed = true; + bedRestAllowed = true; + wildernessRestAllowed = true; waitAllowed = true; ignorePosPacket = false; diff --git a/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp b/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp index 3fa2d71b4..c668dc897 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorGameSettings.hpp @@ -23,15 +23,12 @@ namespace mwmp if (MWBase::Environment::get().getWindowManager()->isGuiMode()) { if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console && !player->consoleAllowed) - { MWBase::Environment::get().getWindowManager()->popGuiMode(); - } - else if ((MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Rest || - MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_RestBed) && - (!player->restAllowed || !player->waitAllowed)) - { + else if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Rest && + (!player->wildernessRestAllowed || !player->waitAllowed)) + MWBase::Environment::get().getWindowManager()->popGuiMode(); + else if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_RestBed && !player->bedRestAllowed) MWBase::Environment::get().getWindowManager()->popGuiMode(); - } } } } diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index eeeb102a6..cea502d2e 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -74,8 +74,8 @@ namespace MWScript Prevent resting if it has been disabled by the server for the local player */ { - if (!mwmp::Main::get().getLocalPlayer()->restAllowed) - MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to rest."); + if (!mwmp::Main::get().getLocalPlayer()->bedRestAllowed) + MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to rest in beds."); else MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_RestBed); } diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index 24b3e20cc..480eb9351 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -248,7 +248,8 @@ namespace mwmp int difficulty; bool consoleAllowed; - bool restAllowed; + bool bedRestAllowed; + bool wildernessRestAllowed; bool waitAllowed; bool ignorePosPacket; diff --git a/components/openmw-mp/Packets/Player/PacketGameSettings.cpp b/components/openmw-mp/Packets/Player/PacketGameSettings.cpp index baee27ab2..c02527e8d 100644 --- a/components/openmw-mp/Packets/Player/PacketGameSettings.cpp +++ b/components/openmw-mp/Packets/Player/PacketGameSettings.cpp @@ -15,6 +15,7 @@ void PacketGameSettings::Packet(RakNet::BitStream *bs, bool send) RW(player->difficulty, send); RW(player->consoleAllowed, send); - RW(player->restAllowed, send); + RW(player->bedRestAllowed, send); + RW(player->wildernessRestAllowed, send); RW(player->waitAllowed, send); }