2017-08-27 16:15:56 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 12.08.17.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-11-23 06:11:37 +00:00
|
|
|
|
2017-08-27 16:15:56 +00:00
|
|
|
#include "Script/LuaState.hpp"
|
|
|
|
#include "Networking.hpp"
|
|
|
|
|
2017-11-23 06:11:37 +00:00
|
|
|
#include "Settings.hpp"
|
|
|
|
#include "Player.hpp"
|
2017-08-27 16:15:56 +00:00
|
|
|
|
|
|
|
void GameSettings::Init(LuaState &lua)
|
|
|
|
{
|
|
|
|
lua.getState()->new_usertype<GameSettings>("Settings",
|
2017-08-30 05:56:53 +00:00
|
|
|
"setConsoleAllow", &GameSettings::SetConsoleAllow,
|
|
|
|
"setDifficulty", &GameSettings::SetDifficulty
|
2017-08-27 16:15:56 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
GameSettings::GameSettings(Player *player) : player(player), changed(false)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GameSettings::~GameSettings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameSettings::SetConsoleAllow(bool state)
|
|
|
|
{
|
|
|
|
player->consoleAllowed = state;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameSettings::SetDifficulty(int difficulty)
|
|
|
|
{
|
|
|
|
player->difficulty = difficulty;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameSettings::update()
|
|
|
|
{
|
|
|
|
if (!changed)
|
|
|
|
return;
|
|
|
|
changed = false;
|
|
|
|
|
|
|
|
auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
packet->Send(false);
|
|
|
|
}
|