mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 04:49:54 +00:00
b249162ca1
Certain servers do not want the players to have debug information about the locations and actions of other players, so a client's log level can now be enforced by the server via the GameSettings packet.
54 lines
2 KiB
C++
54 lines
2 KiB
C++
#ifndef OPENMW_PROCESSORGAMESETTINGS_HPP
|
|
#define OPENMW_PROCESSORGAMESETTINGS_HPP
|
|
|
|
#include "apps/openmw/mwbase/environment.hpp"
|
|
#include "apps/openmw/mwworld/worldimp.hpp"
|
|
#include "apps/openmw/mwgui/windowmanagerimp.hpp"
|
|
|
|
#include "../PlayerProcessor.hpp"
|
|
|
|
namespace mwmp
|
|
{
|
|
class ProcessorGameSettings : public PlayerProcessor
|
|
{
|
|
public:
|
|
ProcessorGameSettings()
|
|
{
|
|
BPP_INIT(ID_GAME_SETTINGS)
|
|
}
|
|
|
|
virtual void Do(PlayerPacket &packet, BasePlayer *player)
|
|
{
|
|
static const int initialLogLevel = Log::GetLevel();
|
|
|
|
if (isLocal())
|
|
{
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_GAME_SETTINGS");
|
|
|
|
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 &&
|
|
(!player->bedRestAllowed || !player->wildernessRestAllowed || !player->waitAllowed))
|
|
MWBase::Environment::get().getWindowManager()->popGuiMode();
|
|
}
|
|
|
|
if (player->enforcedLogLevel > -1)
|
|
{
|
|
LOG_APPEND(Log::LOG_INFO, "- server is enforcing log level %i", player->enforcedLogLevel);
|
|
Log::SetLevel(player->enforcedLogLevel);
|
|
}
|
|
else if (initialLogLevel != Log::GetLevel())
|
|
{
|
|
LOG_APPEND(Log::LOG_INFO, "- log level has been reset to initial value %i", initialLogLevel);
|
|
Log::SetLevel(initialLogLevel);
|
|
}
|
|
|
|
MWBase::Environment::get().getWorld()->setPhysicsFramerate(player->physicsFramerate);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif //OPENMW_PROCESSORGAMESETTINGS_HPP
|