mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:53:50 +00:00
[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/Cells.cpp Script/Functions/CharClass.cpp Script/Functions/Chat.cpp
|
||||||
Script/Functions/Dialogue.cpp Script/Functions/Factions.cpp Script/Functions/GUI.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/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
|
ProcessorInitializer.cpp PlayerProcessor.cpp ActorProcessor.cpp WorldProcessor.cpp
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#include <apps/openmw-mp/Networking.hpp>
|
#include <apps/openmw-mp/Networking.hpp>
|
||||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept
|
void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
@ -85,14 +83,3 @@ void GUIFunctions::SetMapVisibilityAll(unsigned short targetPID, unsigned short
|
||||||
{
|
{
|
||||||
LOG_MESSAGE(Log::LOG_WARN, "stub");
|
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},\
|
{"PasswordDialog", GUIFunctions::PasswordDialog},\
|
||||||
{"ListBox", GUIFunctions::ListBox},\
|
{"ListBox", GUIFunctions::ListBox},\
|
||||||
{"SetMapVisibility", GUIFunctions::SetMapVisibility},\
|
{"SetMapVisibility", GUIFunctions::SetMapVisibility},\
|
||||||
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll},\
|
{"SetMapVisibilityAll", GUIFunctions::SetMapVisibilityAll}
|
||||||
{"SetConsoleAllow", GUIFunctions::SetConsoleAllow}\
|
|
||||||
|
|
||||||
class GUIFunctions
|
class GUIFunctions
|
||||||
{
|
{
|
||||||
|
@ -30,8 +29,6 @@ public:
|
||||||
//state 0 - disallow, 1 - allow
|
//state 0 - disallow, 1 - allow
|
||||||
static void SetMapVisibility(unsigned short targetPID, unsigned short affectedPID, unsigned short state) noexcept;
|
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 SetMapVisibilityAll(unsigned short targetPID, unsigned short state) noexcept;
|
||||||
|
|
||||||
static void SetConsoleAllow(unsigned short pid, bool state);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENMW_GUIAPI_HPP
|
#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/Miscellaneous.hpp>
|
||||||
#include <Script/Functions/Positions.hpp>
|
#include <Script/Functions/Positions.hpp>
|
||||||
#include <Script/Functions/Quests.hpp>
|
#include <Script/Functions/Quests.hpp>
|
||||||
|
#include <Script/Functions/Settings.hpp>
|
||||||
#include <Script/Functions/Spells.hpp>
|
#include <Script/Functions/Spells.hpp>
|
||||||
#include <Script/Functions/Stats.hpp>
|
#include <Script/Functions/Stats.hpp>
|
||||||
#include <Script/Functions/World.hpp>
|
#include <Script/Functions/World.hpp>
|
||||||
|
@ -115,6 +116,7 @@ public:
|
||||||
CHARCLASSAPI,
|
CHARCLASSAPI,
|
||||||
WORLDAPI,
|
WORLDAPI,
|
||||||
ACTORAPI,
|
ACTORAPI,
|
||||||
|
SETTINGSAPI,
|
||||||
MISCELLANEOUSAPI
|
MISCELLANEOUSAPI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue