[General] Allow GameSettings to set bed & wilderness resting separately

0.6.2
David Cernat 7 years ago
parent 3508a16836
commit c9c363ebef

@ -25,12 +25,20 @@ void SettingFunctions::SetConsoleAllowed(unsigned short pid, bool state)
player->consoleAllowed = state; player->consoleAllowed = state;
} }
void SettingFunctions::SetRestAllowed(unsigned short pid, bool state) void SettingFunctions::SetBedRestAllowed(unsigned short pid, bool state)
{ {
Player *player; Player *player;
GET_PLAYER(pid, 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) void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)

@ -4,12 +4,13 @@
#include "../Types.hpp" #include "../Types.hpp"
#define SETTINGSAPI \ #define SETTINGSAPI \
{"SetDifficulty", SettingFunctions::SetDifficulty},\ {"SetDifficulty", SettingFunctions::SetDifficulty},\
{"SetConsoleAllowed", SettingFunctions::SetConsoleAllowed},\ {"SetConsoleAllowed", SettingFunctions::SetConsoleAllowed},\
{"SetRestAllowed", SettingFunctions::SetRestAllowed},\ {"SetBedRestAllowed", SettingFunctions::SetBedRestAllowed},\
{"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\ {"SetWildernessRestAllowed", SettingFunctions::SetWildernessRestAllowed},\
{"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\
\ \
{"SendSettings", SettingFunctions::SendSettings} {"SendSettings", SettingFunctions::SendSettings}
class SettingFunctions class SettingFunctions
{ {
@ -40,7 +41,7 @@ public:
static void SetConsoleAllowed(unsigned short pid, bool state); 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 * This changes the resting permission for that player in the server memory, but does not
* by itself send a packet. * by itself send a packet.
@ -49,7 +50,19 @@ public:
* \param bool The resting permission state. * \param bool The resting permission state.
* \return void * \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. * \brief Set whether waiting is allowed for a player.

@ -1019,9 +1019,9 @@ namespace MWInput
*/ */
int canRest = MWBase::Environment::get().getWorld()->canRest(); 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; return;
} }
else if (canRest == 1 && !mwmp::Main::get().getLocalPlayer()->waitAllowed) else if (canRest == 1 && !mwmp::Main::get().getLocalPlayer()->waitAllowed)

@ -50,7 +50,8 @@ LocalPlayer::LocalPlayer()
difficulty = 0; difficulty = 0;
consoleAllowed = false; consoleAllowed = false;
restAllowed = true; bedRestAllowed = true;
wildernessRestAllowed = true;
waitAllowed = true; waitAllowed = true;
ignorePosPacket = false; ignorePosPacket = false;

@ -23,15 +23,12 @@ namespace mwmp
if (MWBase::Environment::get().getWindowManager()->isGuiMode()) if (MWBase::Environment::get().getWindowManager()->isGuiMode())
{ {
if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console && !player->consoleAllowed) if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console && !player->consoleAllowed)
{
MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->popGuiMode();
} else if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Rest &&
else if ((MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Rest || (!player->wildernessRestAllowed || !player->waitAllowed))
MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_RestBed) && MWBase::Environment::get().getWindowManager()->popGuiMode();
(!player->restAllowed || !player->waitAllowed)) else if (MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_RestBed && !player->bedRestAllowed)
{
MWBase::Environment::get().getWindowManager()->popGuiMode(); MWBase::Environment::get().getWindowManager()->popGuiMode();
}
} }
} }
} }

@ -74,8 +74,8 @@ namespace MWScript
Prevent resting if it has been disabled by the server for the local player Prevent resting if it has been disabled by the server for the local player
*/ */
{ {
if (!mwmp::Main::get().getLocalPlayer()->restAllowed) if (!mwmp::Main::get().getLocalPlayer()->bedRestAllowed)
MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to rest."); MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to rest in beds.");
else else
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_RestBed); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_RestBed);
} }

@ -248,7 +248,8 @@ namespace mwmp
int difficulty; int difficulty;
bool consoleAllowed; bool consoleAllowed;
bool restAllowed; bool bedRestAllowed;
bool wildernessRestAllowed;
bool waitAllowed; bool waitAllowed;
bool ignorePosPacket; bool ignorePosPacket;

@ -15,6 +15,7 @@ void PacketGameSettings::Packet(RakNet::BitStream *bs, bool send)
RW(player->difficulty, send); RW(player->difficulty, send);
RW(player->consoleAllowed, send); RW(player->consoleAllowed, send);
RW(player->restAllowed, send); RW(player->bedRestAllowed, send);
RW(player->wildernessRestAllowed, send);
RW(player->waitAllowed, send); RW(player->waitAllowed, send);
} }

Loading…
Cancel
Save