forked from mirror/openmw-tes3mp
[General] Use GameSettings packet to set ability to rest and wait
This commit is contained in:
parent
300ca905fc
commit
3508a16836
8 changed files with 124 additions and 24 deletions
|
@ -9,7 +9,15 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void SettingFunctions::SetConsoleAllow(unsigned short pid, bool state)
|
void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
|
player->difficulty = difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingFunctions::SetConsoleAllowed(unsigned short pid, bool state)
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,);
|
GET_PLAYER(pid, player,);
|
||||||
|
@ -17,12 +25,20 @@ void SettingFunctions::SetConsoleAllow(unsigned short pid, bool state)
|
||||||
player->consoleAllowed = state;
|
player->consoleAllowed = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
|
void SettingFunctions::SetRestAllowed(unsigned short pid, bool state)
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
GET_PLAYER(pid, player,);
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
player->difficulty = difficulty;
|
player->restAllowed = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingFunctions::SetWaitAllowed(unsigned short pid, bool state)
|
||||||
|
{
|
||||||
|
Player *player;
|
||||||
|
GET_PLAYER(pid, player, );
|
||||||
|
|
||||||
|
player->waitAllowed = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingFunctions::SendSettings(unsigned short pid) noexcept
|
void SettingFunctions::SendSettings(unsigned short pid) noexcept
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
#include "../Types.hpp"
|
#include "../Types.hpp"
|
||||||
|
|
||||||
#define SETTINGSAPI \
|
#define SETTINGSAPI \
|
||||||
{"SetConsoleAllow", SettingFunctions::SetConsoleAllow},\
|
|
||||||
{"SetDifficulty", SettingFunctions::SetDifficulty},\
|
{"SetDifficulty", SettingFunctions::SetDifficulty},\
|
||||||
|
{"SetConsoleAllowed", SettingFunctions::SetConsoleAllowed},\
|
||||||
|
{"SetRestAllowed", SettingFunctions::SetRestAllowed},\
|
||||||
|
{"SetWaitAllowed", SettingFunctions::SetWaitAllowed},\
|
||||||
\
|
\
|
||||||
{"SendSettings", SettingFunctions::SendSettings}
|
{"SendSettings", SettingFunctions::SendSettings}
|
||||||
|
|
||||||
|
@ -13,18 +15,6 @@ class SettingFunctions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set whether the console is allowed for a player.
|
|
||||||
*
|
|
||||||
* This changes the console permission for that player in the server memory, but does not
|
|
||||||
* by itself send a packet.
|
|
||||||
*
|
|
||||||
* \param pid The player ID.
|
|
||||||
* \param bool The console permission state.
|
|
||||||
* \return void
|
|
||||||
*/
|
|
||||||
static void SetConsoleAllow(unsigned short pid, bool state);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the difficulty for a player.
|
* \brief Set the difficulty for a player.
|
||||||
*
|
*
|
||||||
|
@ -37,6 +27,42 @@ public:
|
||||||
*/
|
*/
|
||||||
static void SetDifficulty(unsigned short pid, int difficulty);
|
static void SetDifficulty(unsigned short pid, int difficulty);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set whether the console is allowed for a player.
|
||||||
|
*
|
||||||
|
* This changes the console permission for that player in the server memory, but does not
|
||||||
|
* by itself send a packet.
|
||||||
|
*
|
||||||
|
* \param pid The player ID.
|
||||||
|
* \param bool The console permission state.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SetConsoleAllowed(unsigned short pid, bool state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set whether resting 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 SetRestAllowed(unsigned short pid, bool state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set whether waiting is allowed for a player.
|
||||||
|
*
|
||||||
|
* This changes the waiting permission for that player in the server memory, but does not
|
||||||
|
* by itself send a packet.
|
||||||
|
*
|
||||||
|
* \param pid The player ID.
|
||||||
|
* \param bool The waiting permission state.
|
||||||
|
* \return void
|
||||||
|
*/
|
||||||
|
static void SetWaitAllowed(unsigned short pid, bool state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send a PlayerSettings packet to the player affected by it.
|
* \brief Send a PlayerSettings packet to the player affected by it.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1011,6 +1011,28 @@ namespace MWInput
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage2}"); //Nope,
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage2}"); //Nope,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Prevent resting and waiting if they have been disabled by the server for the local player
|
||||||
|
*/
|
||||||
|
int canRest = MWBase::Environment::get().getWorld()->canRest();
|
||||||
|
|
||||||
|
if (canRest == 0 && !mwmp::Main::get().getLocalPlayer()->restAllowed)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to rest.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (canRest == 1 && !mwmp::Main::get().getLocalPlayer()->waitAllowed)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox("You are not allowed to wait.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_Rest); //Open rest GUI
|
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_Rest); //Open rest GUI
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,10 @@ LocalPlayer::LocalPlayer()
|
||||||
charGenStage.current = 0;
|
charGenStage.current = 0;
|
||||||
charGenStage.end = 1;
|
charGenStage.end = 1;
|
||||||
|
|
||||||
consoleAllowed = false;
|
|
||||||
difficulty = 0;
|
difficulty = 0;
|
||||||
|
consoleAllowed = false;
|
||||||
|
restAllowed = true;
|
||||||
|
waitAllowed = true;
|
||||||
|
|
||||||
ignorePosPacket = false;
|
ignorePosPacket = false;
|
||||||
ignoreJailTeleportation = false;
|
ignoreJailTeleportation = false;
|
||||||
|
|
|
@ -26,6 +26,12 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
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))
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
#include "guiextensions.hpp"
|
#include "guiextensions.hpp"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include additional headers for multiplayer purposes
|
||||||
|
*/
|
||||||
|
#include "../mwmp/Main.hpp"
|
||||||
|
#include "../mwmp/LocalPlayer.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#include <components/compiler/extensions.hpp>
|
#include <components/compiler/extensions.hpp>
|
||||||
#include <components/compiler/opcodes.hpp>
|
#include <components/compiler/opcodes.hpp>
|
||||||
|
|
||||||
|
@ -57,8 +68,21 @@ namespace MWScript
|
||||||
|
|
||||||
if (bed.isEmpty() || !MWBase::Environment::get().getMechanicsManager()->sleepInBed(MWMechanics::getPlayer(),
|
if (bed.isEmpty() || !MWBase::Environment::get().getMechanicsManager()->sleepInBed(MWMechanics::getPlayer(),
|
||||||
bed))
|
bed))
|
||||||
|
/*
|
||||||
|
Start of tes3mp change (minor)
|
||||||
|
|
||||||
|
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.");
|
||||||
|
else
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_RestBed);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_RestBed);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
End of tes3mp change (minor)
|
||||||
|
*/
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpShowDialogue : public Interpreter::Opcode0
|
class OpShowDialogue : public Interpreter::Opcode0
|
||||||
|
|
|
@ -246,8 +246,10 @@ namespace mwmp
|
||||||
ESM::ActiveSpells activeSpells;
|
ESM::ActiveSpells activeSpells;
|
||||||
CurrentContainer currentContainer;
|
CurrentContainer currentContainer;
|
||||||
|
|
||||||
bool consoleAllowed;
|
|
||||||
int difficulty;
|
int difficulty;
|
||||||
|
bool consoleAllowed;
|
||||||
|
bool restAllowed;
|
||||||
|
bool waitAllowed;
|
||||||
|
|
||||||
bool ignorePosPacket;
|
bool ignorePosPacket;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ void PacketGameSettings::Packet(RakNet::BitStream *bs, bool send)
|
||||||
{
|
{
|
||||||
PlayerPacket::Packet(bs, send);
|
PlayerPacket::Packet(bs, send);
|
||||||
|
|
||||||
RW(player->consoleAllowed, send);
|
|
||||||
RW(player->difficulty, send);
|
RW(player->difficulty, send);
|
||||||
|
RW(player->consoleAllowed, send);
|
||||||
|
RW(player->restAllowed, send);
|
||||||
|
RW(player->waitAllowed, send);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue