-
Notifications
You must be signed in to change notification settings - Fork 442
Expand file tree
/
Copy pathElunaConfig.h
More file actions
82 lines (65 loc) · 2.75 KB
/
ElunaConfig.h
File metadata and controls
82 lines (65 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright (C) 2010 - 2024 Eluna Lua Engine <https://elunaluaengine.github.io/>
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
#ifndef _ELUNACONFIG_H
#define _ELUNACONFIG_H
#include "ElunaUtility.h"
enum ElunaConfigBoolValues
{
CONFIG_ELUNA_ENABLED,
CONFIG_ELUNA_TRACEBACK,
CONFIG_ELUNA_SCRIPT_RELOADER,
CONFIG_ELUNA_ENABLE_UNSAFE,
CONFIG_ELUNA_ENABLE_DEPRECATED,
CONFIG_ELUNA_ENABLE_RELOAD_COMMAND,
CONFIG_ELUNA_BOOL_COUNT
};
enum ElunaConfigStringValues
{
CONFIG_ELUNA_SCRIPT_PATH,
CONFIG_ELUNA_ONLY_ON_MAPS,
CONFIG_ELUNA_REQUIRE_PATH_EXTRA,
CONFIG_ELUNA_REQUIRE_CPATH_EXTRA,
CONFIG_ELUNA_STRING_COUNT
};
enum ElunaConfigUInt32Values
{
CONFIG_ELUNA_RELOAD_SECURITY_LEVEL,
CONFIG_ELUNA_INT_COUNT
};
class ElunaConfig
{
private:
ElunaConfig();
~ElunaConfig();
ElunaConfig(ElunaConfig const&) = delete;
ElunaConfig& operator=(ElunaConfig const&) = delete;
public:
static ElunaConfig* instance();
void Initialize();
bool GetConfig(ElunaConfigBoolValues index) const { return _configBoolValues[index]; }
const std::string& GetConfig(ElunaConfigStringValues index) const { return _configStringValues[index]; }
const uint32& GetConfig(ElunaConfigUInt32Values index) const { return _configUInt32Values[index]; }
bool IsElunaEnabled() { return GetConfig(CONFIG_ELUNA_ENABLED); }
bool UnsafeMethodsEnabled() { return GetConfig(CONFIG_ELUNA_ENABLE_UNSAFE); }
bool DeprecatedMethodsEnabled() { return GetConfig(CONFIG_ELUNA_ENABLE_DEPRECATED); }
bool IsReloadCommandEnabled() { return GetConfig(CONFIG_ELUNA_ENABLE_RELOAD_COMMAND); }
AccountTypes GetReloadSecurityLevel() { return static_cast<AccountTypes>(GetConfig(CONFIG_ELUNA_RELOAD_SECURITY_LEVEL)); }
bool ShouldMapLoadEluna(uint32 mapId);
private:
bool _configBoolValues[CONFIG_ELUNA_BOOL_COUNT];
std::string _configStringValues[CONFIG_ELUNA_STRING_COUNT];
uint32 _configUInt32Values[CONFIG_ELUNA_INT_COUNT];
void SetConfig(ElunaConfigBoolValues index, bool value) { _configBoolValues[index] = value; }
void SetConfig(ElunaConfigStringValues index, std::string value) { _configStringValues[index] = value; }
void SetConfig(ElunaConfigUInt32Values index, uint32 value) { _configUInt32Values[index] = value; }
void SetConfig(ElunaConfigBoolValues index, char const* fieldname, bool defvalue);
void SetConfig(ElunaConfigStringValues index, char const* fieldname, std::string defvalue);
void SetConfig(ElunaConfigUInt32Values index, char const* fieldname, uint32 defvalue);
void TokenizeAllowedMaps();
std::unordered_set<uint32> m_allowedMaps;
};
#define sElunaConfig ElunaConfig::instance()
#endif //_ELUNACONFIG_H