mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 23:35:41 +00:00
Move map declarations in Settings.h into .cpp
This commit is contained in:
parent
04e8d00daa
commit
73ecef1a87
@ -61,6 +61,8 @@ public:
|
|||||||
struct Settings {
|
struct Settings {
|
||||||
using SettingsTypeVariant = std::variant<std::string, bool, int>;
|
using SettingsTypeVariant = std::variant<std::string, bool, int>;
|
||||||
|
|
||||||
|
Settings();
|
||||||
|
|
||||||
enum Key {
|
enum Key {
|
||||||
// Keys that correspond to the keys set in TOML
|
// Keys that correspond to the keys set in TOML
|
||||||
// Keys have their TOML section name as prefix
|
// Keys have their TOML section name as prefix
|
||||||
@ -85,25 +87,7 @@ struct Settings {
|
|||||||
General_Debug
|
General_Debug
|
||||||
};
|
};
|
||||||
|
|
||||||
Sync<std::unordered_map<Key, SettingsTypeVariant>> SettingsMap = std::unordered_map<Key, SettingsTypeVariant> {
|
Sync<std::unordered_map<Key, SettingsTypeVariant>> SettingsMap;
|
||||||
// All entries which contain std::strings must be explicitly constructed, otherwise they become 'bool'
|
|
||||||
{ General_Description, std::string("BeamMP Default Description") },
|
|
||||||
{ General_Tags, std::string("Freeroam") },
|
|
||||||
{ General_MaxPlayers, 8 },
|
|
||||||
{ General_Name, std::string("BeamMP Server") },
|
|
||||||
{ General_Map, std::string("/levels/gridmap_v2/info.json") },
|
|
||||||
{ General_AuthKey, std::string("") },
|
|
||||||
{ General_Private, true },
|
|
||||||
{ General_Port, 30814 },
|
|
||||||
{ General_MaxCars, 1 },
|
|
||||||
{ General_LogChat, true },
|
|
||||||
{ General_ResourceFolder, std::string("Resources") },
|
|
||||||
{ General_Debug, false },
|
|
||||||
{ Misc_SendErrorsShowMessage, true },
|
|
||||||
{ Misc_SendErrors, true },
|
|
||||||
{ Misc_ImScaredOfUpdates, true }
|
|
||||||
};
|
|
||||||
|
|
||||||
enum SettingsAccessMask {
|
enum SettingsAccessMask {
|
||||||
READ_ONLY, // Value can be read from console
|
READ_ONLY, // Value can be read from console
|
||||||
READ_WRITE, // Value can be read and written to from console
|
READ_WRITE, // Value can be read and written to from console
|
||||||
@ -115,24 +99,7 @@ struct Settings {
|
|||||||
SettingsAccessMask // Console read/write permissions
|
SettingsAccessMask // Console read/write permissions
|
||||||
>;
|
>;
|
||||||
|
|
||||||
Sync<std::unordered_map<ComposedKey, SettingsAccessControl>> InputAccessMapping = std::unordered_map<ComposedKey, SettingsAccessControl> {
|
Sync<std::unordered_map<ComposedKey, SettingsAccessControl>> InputAccessMapping;
|
||||||
{ { "General", "Description" }, { General_Description, READ_WRITE } },
|
|
||||||
{ { "General", "Tags" }, { General_Tags, READ_WRITE } },
|
|
||||||
{ { "General", "MaxPlayers" }, { General_MaxPlayers, READ_WRITE } },
|
|
||||||
{ { "General", "Name" }, { General_Name, READ_WRITE } },
|
|
||||||
{ { "General", "Map" }, { General_Map, READ_WRITE } },
|
|
||||||
{ { "General", "AuthKey" }, { General_AuthKey, READ_WRITE } },
|
|
||||||
{ { "General", "Private" }, { General_Private, READ_ONLY } },
|
|
||||||
{ { "General", "Port" }, { General_Port, READ_ONLY } },
|
|
||||||
{ { "General", "MaxCars" }, { General_MaxCars, READ_WRITE } },
|
|
||||||
{ { "General", "LogChat" }, { General_LogChat, READ_ONLY } },
|
|
||||||
{ { "General", "ResourceFolder" }, { General_ResourceFolder, READ_ONLY } },
|
|
||||||
{ { "General", "Debug" }, { General_Debug, READ_WRITE } },
|
|
||||||
{ { "Misc", "SendErrorsShowMessage" }, { Misc_SendErrorsShowMessage, READ_WRITE } },
|
|
||||||
{ { "Misc", "SendErrors" }, { Misc_SendErrors, READ_WRITE } },
|
|
||||||
{ { "Misc", "ImScaredOfUpdates" }, { Misc_ImScaredOfUpdates, READ_WRITE } }
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string getAsString(Key key);
|
std::string getAsString(Key key);
|
||||||
|
|
||||||
int getAsInt(Key key);
|
int getAsInt(Key key);
|
||||||
|
@ -18,6 +18,49 @@
|
|||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Settings::Settings(){
|
||||||
|
SettingsMap = std::unordered_map<Key, SettingsTypeVariant> {
|
||||||
|
// All entries which contain std::strings must be explicitly constructed, otherwise they become 'bool'
|
||||||
|
{ General_Description, std::string("BeamMP Default Description") },
|
||||||
|
{ General_Tags, std::string("Freeroam") },
|
||||||
|
{ General_MaxPlayers, 8 },
|
||||||
|
{ General_Name, std::string("BeamMP Server") },
|
||||||
|
{ General_Map, std::string("/levels/gridmap_v2/info.json") },
|
||||||
|
{ General_AuthKey, std::string("") },
|
||||||
|
{ General_Private, true },
|
||||||
|
{ General_Port, 30814 },
|
||||||
|
{ General_MaxCars, 1 },
|
||||||
|
{ General_LogChat, true },
|
||||||
|
{ General_ResourceFolder, std::string("Resources") },
|
||||||
|
{ General_Debug, false },
|
||||||
|
{ Misc_SendErrorsShowMessage, true },
|
||||||
|
{ Misc_SendErrors, true },
|
||||||
|
{ Misc_ImScaredOfUpdates, true }
|
||||||
|
};
|
||||||
|
|
||||||
|
InputAccessMapping = std::unordered_map<ComposedKey, SettingsAccessControl> {
|
||||||
|
{ { "General", "Description" }, { General_Description, READ_WRITE } },
|
||||||
|
{ { "General", "Tags" }, { General_Tags, READ_WRITE } },
|
||||||
|
{ { "General", "MaxPlayers" }, { General_MaxPlayers, READ_WRITE } },
|
||||||
|
{ { "General", "Name" }, { General_Name, READ_WRITE } },
|
||||||
|
{ { "General", "Map" }, { General_Map, READ_WRITE } },
|
||||||
|
{ { "General", "AuthKey" }, { General_AuthKey, READ_WRITE } },
|
||||||
|
{ { "General", "Private" }, { General_Private, READ_ONLY } },
|
||||||
|
{ { "General", "Port" }, { General_Port, READ_ONLY } },
|
||||||
|
{ { "General", "MaxCars" }, { General_MaxCars, READ_WRITE } },
|
||||||
|
{ { "General", "LogChat" }, { General_LogChat, READ_ONLY } },
|
||||||
|
{ { "General", "ResourceFolder" }, { General_ResourceFolder, READ_ONLY } },
|
||||||
|
{ { "General", "Debug" }, { General_Debug, READ_WRITE } },
|
||||||
|
{ { "Misc", "SendErrorsShowMessage" }, { Misc_SendErrorsShowMessage, READ_WRITE } },
|
||||||
|
{ { "Misc", "SendErrors" }, { Misc_SendErrors, READ_WRITE } },
|
||||||
|
{ { "Misc", "ImScaredOfUpdates" }, { Misc_ImScaredOfUpdates, READ_WRITE } }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::string Settings::getAsString(Key key) {
|
std::string Settings::getAsString(Key key) {
|
||||||
auto map = SettingsMap.synchronize();
|
auto map = SettingsMap.synchronize();
|
||||||
if (!map->contains(key)) {
|
if (!map->contains(key)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user