forked from teamnwah/openmw-tes3coop
[Server] Create new Settings category for script functions
This commit is contained in:
parent
ebf7740969
commit
4ad87faac1
6 changed files with 59 additions and 18 deletions
|
@ -80,7 +80,8 @@ set(SERVER
|
|||
Script/Functions/Cells.cpp Script/Functions/CharClass.cpp Script/Functions/Chat.cpp
|
||||
Script/Functions/Dialogue.cpp Script/Functions/Factions.cpp Script/Functions/GUI.cpp
|
||||
Script/Functions/Items.cpp Script/Functions/Positions.cpp Script/Functions/Quests.cpp
|
||||
Script/Functions/Spells.cpp Script/Functions/Stats.cpp Script/Functions/Timer.cpp
|
||||
Script/Functions/Settings.cpp Script/Functions/Spells.cpp Script/Functions/Stats.cpp
|
||||
Script/Functions/Timer.cpp
|
||||
|
||||
ProcessorInitializer.cpp PlayerProcessor.cpp ActorProcessor.cpp WorldProcessor.cpp
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include <apps/openmw-mp/Networking.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
|
||||
|
||||
|
||||
void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -85,14 +83,3 @@ void GUIFunctions::SetMapVisibilityAll(unsigned short targetPID, unsigned short
|
|||
{
|
||||
LOG_MESSAGE(Log::LOG_WARN, "stub");
|
||||
}
|
||||
|
||||
void GUIFunctions::SetConsoleAllow(unsigned short pid, bool state)
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
player->consoleAllowed = state;
|
||||
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->Send(false);
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
{"PasswordDialog", GUIFunctions::PasswordDialog},\
|
||||
{"ListBox", GUIFunctions::ListBox},\
|
||||
{"SetMapVisibility", GUIFunctions::SetMapVisibility},\
|
||||
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll},\
|
||||
{"SetConsoleAllow", GUIFunctions::SetConsoleAllow}\
|
||||
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll}
|
||||
|
||||
class GUIFunctions
|
||||
{
|
||||
|
@ -30,8 +29,6 @@ public:
|
|||
//state 0 - disallow, 1 - allow
|
||||
static void SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept;
|
||||
static void SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept;
|
||||
|
||||
static void SetConsoleAllow(unsigned short pid, bool state);
|
||||
};
|
||||
|
||||
#endif //OPENMW_GUIAPI_HPP
|
||||
|
|
33
apps/openmw-mp/Script/Functions/Settings.cpp
Normal file
33
apps/openmw-mp/Script/Functions/Settings.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "Settings.hpp"
|
||||
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <apps/openmw-mp/Networking.hpp>
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
void SettingFunctions::SetConsoleAllow(unsigned short pid, bool state)
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
player->consoleAllowed = state;
|
||||
}
|
||||
|
||||
void SettingFunctions::SetDifficulty(unsigned short pid, int difficulty)
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
player->difficulty = difficulty;
|
||||
}
|
||||
|
||||
void SettingFunctions::SendSettings(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->Send(false);
|
||||
}
|
21
apps/openmw-mp/Script/Functions/Settings.hpp
Normal file
21
apps/openmw-mp/Script/Functions/Settings.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef OPENMW_SETTINGSAPI_HPP
|
||||
#define OPENMW_SETTINGSAPI_HPP
|
||||
|
||||
#include "../Types.hpp"
|
||||
|
||||
#define SETTINGSAPI \
|
||||
{"SetConsoleAllow", SettingFunctions::SetConsoleAllow},\
|
||||
{"SetDifficulty", SettingFunctions::SetDifficulty},\
|
||||
\
|
||||
{"SendSettings", SettingFunctions::SendSettings}
|
||||
|
||||
class SettingFunctions
|
||||
{
|
||||
public:
|
||||
static void SetConsoleAllow(unsigned short pid, bool state);
|
||||
static void SetDifficulty(unsigned short pid, int difficulty);
|
||||
|
||||
static void SendSettings(unsigned short pid) noexcept;
|
||||
};
|
||||
|
||||
#endif //OPENMW_SETTINGSAPI_HPP
|
|
@ -15,6 +15,7 @@
|
|||
#include <Script/Functions/Miscellaneous.hpp>
|
||||
#include <Script/Functions/Positions.hpp>
|
||||
#include <Script/Functions/Quests.hpp>
|
||||
#include <Script/Functions/Settings.hpp>
|
||||
#include <Script/Functions/Spells.hpp>
|
||||
#include <Script/Functions/Stats.hpp>
|
||||
#include <Script/Functions/World.hpp>
|
||||
|
@ -115,6 +116,7 @@ public:
|
|||
CHARCLASSAPI,
|
||||
WORLDAPI,
|
||||
ACTORAPI,
|
||||
SETTINGSAPI,
|
||||
MISCELLANEOUSAPI
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue