openmw-tes3coop/apps/openmw-mp/Settings.cpp
David Cernat 3d5860d6f4 Merge pull request #396 from TES3MP/0.6.3 while resolving conflicts
Conflicts:
	apps/openmw-mp/Player.cpp
	apps/openmw-mp/Script/Functions/Settings.cpp
	apps/openmw-mp/Script/Functions/Settings.hpp
	apps/openmw-mp/Script/Functions/World.cpp
	apps/openmw-mp/Script/Functions/World.hpp
	apps/openmw/mwgui/container.cpp
	apps/openmw/mwmp/LocalActor.cpp
	apps/openmw/mwmp/LocalPlayer.cpp
	apps/openmw/mwmp/WorldEvent.cpp
	apps/openmw/mwmp/processors/world/ProcessorContainer.hpp
	components/openmw-mp/Base/BaseEvent.hpp
	components/openmw-mp/Log.cpp
	components/openmw-mp/Log.hpp
2018-03-30 09:32:43 +03:00

78 lines
2 KiB
C++

//
// Created by koncord on 12.08.17.
//
#include <components/openmw-mp/NetworkMessages.hpp>
#include "Script/LuaState.hpp"
#include "Networking.hpp"
#include "Settings.hpp"
#include "Player.hpp"
void GameSettings::Init(LuaState &lua)
{
lua.getState()->new_usertype<GameSettings>("Settings",
"setDifficulty", &GameSettings::setDifficulty,
"setEnforcedLogLevel", &GameSettings::setEnforcedLogLevel,
"setPhysicsFramerate", &GameSettings::setPhysicsFramerate,
"setConsoleAllowed", &GameSettings::setConsoleAllowed,
"setBedRestAllowed", &GameSettings::setBedRestAllowed,
"setWildernessRestAllowed", &GameSettings::setWildernessRestAllowed,
"setWaitAllowed", &GameSettings::setWaitAllowed
);
}
GameSettings::GameSettings(Player *player) : BaseMgr(player)
{
}
void GameSettings::setConsoleAllowed(bool state)
{
player->consoleAllowed = state;
setChanged();
}
void GameSettings::setDifficulty(int difficulty)
{
player->difficulty = difficulty;
setChanged();
}
void GameSettings::setEnforcedLogLevel(int logLevel)
{
player->enforcedLogLevel = logLevel;
setChanged();
}
void GameSettings::setPhysicsFramerate(double physicsFramerate)
{
player->physicsFramerate = physicsFramerate;
setChanged();
}
void GameSettings::setBedRestAllowed(bool state)
{
player->bedRestAllowed = state;
setChanged();
}
void GameSettings::setWildernessRestAllowed(bool state)
{
player->wildernessRestAllowed = state;
setChanged();
}
void GameSettings::setWaitAllowed(bool state)
{
player->waitAllowed = state;
setChanged();
}
void GameSettings::processUpdate()
{
auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS);
packet->setPlayer(player);
packet->Send(false);
}