mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 09:49:40 +00:00
[General] Allow GameSettings to set bed & wilderness resting separately
This commit is contained in:
parent
3508a16836
commit
c9c363ebef
8 changed files with 44 additions and 23 deletions
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -50,7 +50,8 @@ LocalPlayer::LocalPlayer()
|
|||
|
||||
difficulty = 0;
|
||||
consoleAllowed = false;
|
||||
restAllowed = true;
|
||||
bedRestAllowed = true;
|
||||
wildernessRestAllowed = true;
|
||||
waitAllowed = true;
|
||||
|
||||
ignorePosPacket = false;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -248,7 +248,8 @@ namespace mwmp
|
|||
|
||||
int difficulty;
|
||||
bool consoleAllowed;
|
||||
bool restAllowed;
|
||||
bool bedRestAllowed;
|
||||
bool wildernessRestAllowed;
|
||||
bool waitAllowed;
|
||||
|
||||
bool ignorePosPacket;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue