-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigmanager.h
167 lines (150 loc) · 4.05 KB
/
configmanager.h
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2019 Mark Samman <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef FS_CONFIGMANAGER_H_6BDD23BD0B8344F4B7C40E8BE6AF6F39
#define FS_CONFIGMANAGER_H_6BDD23BD0B8344F4B7C40E8BE6AF6F39
#include <utility>
#include <vector>
using ExperienceStages = std::vector<std::tuple<uint32_t, uint32_t, float>>;
class ConfigManager
{
public:
ConfigManager();
enum boolean_config_t {
ALLOW_CHANGEOUTFIT,
ONE_PLAYER_ON_ACCOUNT,
AIMBOT_HOTKEY_ENABLED,
REMOVE_RUNE_CHARGES,
REMOVE_WEAPON_AMMO,
REMOVE_WEAPON_CHARGES,
REMOVE_POTION_CHARGES,
EXPERIENCE_FROM_PLAYERS,
FREE_PREMIUM,
REPLACE_KICK_ON_LOGIN,
ALLOW_CLONES,
ALLOW_WALKTHROUGH,
BIND_ONLY_GLOBAL_ADDRESS,
OPTIMIZE_DATABASE,
MARKET_PREMIUM,
EMOTE_SPELLS,
STAMINA_SYSTEM,
WARN_UNSAFE_SCRIPTS,
CONVERT_UNSAFE_SCRIPTS,
CLASSIC_EQUIPMENT_SLOTS,
CLASSIC_ATTACK_SPEED,
SCRIPTS_CONSOLE_LOGS,
SERVER_SAVE_NOTIFY_MESSAGE,
SERVER_SAVE_CLEAN_MAP,
SERVER_SAVE_CLOSE,
SERVER_SAVE_SHUTDOWN,
ONLINE_OFFLINE_CHARLIST,
YELL_ALLOW_PREMIUM,
PREMIUM_TO_SEND_PRIVATE,
FORCE_MONSTERTYPE_LOAD,
DEFAULT_WORLD_LIGHT,
HOUSE_OWNED_BY_ACCOUNT,
LUA_ITEM_DESC,
CLEAN_PROTECTION_ZONES,
HOUSE_DOOR_SHOW_PRICE,
ONLY_INVITED_CAN_MOVE_HOUSE_ITEMS,
REMOVE_ON_DESPAWN,
PLAYER_CONSOLE_LOGS,
MONSTER_OVERSPAWN,
LAST_BOOLEAN_CONFIG /* this must be the last one */
};
enum string_config_t {
MAP_NAME,
HOUSE_RENT_PERIOD,
SERVER_NAME,
OWNER_NAME,
OWNER_EMAIL,
URL,
LOCATION,
IP,
MOTD,
WORLD_TYPE,
MYSQL_HOST,
MYSQL_USER,
MYSQL_PASS,
MYSQL_DB,
MYSQL_SOCK,
DEFAULT_PRIORITY,
MAP_AUTHOR,
CONFIG_FILE,
LAST_STRING_CONFIG /* this must be the last one */
};
enum integer_config_t {
SQL_PORT,
MAX_PLAYERS,
PZ_LOCKED,
DEFAULT_DESPAWNRANGE,
DEFAULT_DESPAWNRADIUS,
DEFAULT_WALKTOSPAWNRADIUS,
RATE_EXPERIENCE,
RATE_SKILL,
RATE_LOOT,
RATE_MAGIC,
RATE_SPAWN,
HOUSE_PRICE,
KILLS_TO_RED,
KILLS_TO_BLACK,
MAX_MESSAGEBUFFER,
ACTIONS_DELAY_INTERVAL,
EX_ACTIONS_DELAY_INTERVAL,
KICK_AFTER_MINUTES,
PROTECTION_LEVEL,
DEATH_LOSE_PERCENT,
STATUSQUERY_TIMEOUT,
FRAG_TIME,
WHITE_SKULL_TIME,
GAME_PORT,
LOGIN_PORT,
STATUS_PORT,
STAIRHOP_DELAY,
MARKET_OFFER_DURATION,
CHECK_EXPIRED_MARKET_OFFERS_EACH_MINUTES,
MAX_MARKET_OFFERS_AT_A_TIME_PER_PLAYER,
EXP_FROM_PLAYERS_LEVEL_RANGE,
MAX_PACKETS_PER_SECOND,
SERVER_SAVE_NOTIFY_DURATION,
YELL_MINIMUM_LEVEL,
MINIMUM_LEVEL_TO_SEND_PRIVATE,
VIP_FREE_LIMIT,
VIP_PREMIUM_LIMIT,
DEPOT_FREE_LIMIT,
DEPOT_PREMIUM_LIMIT,
IP_NUM,
LAST_INTEGER_CONFIG /* this must be the last one */
};
bool load();
bool reload();
const std::string& getString(string_config_t what) const;
int32_t getNumber(integer_config_t what) const;
bool getBoolean(boolean_config_t what) const;
float getExperienceStage(uint32_t level) const;
bool setString(string_config_t what, const std::string& value);
bool setNumber(integer_config_t what, int32_t value);
bool setBoolean(boolean_config_t what, bool value);
private:
std::string string[LAST_STRING_CONFIG] = {};
int32_t integer[LAST_INTEGER_CONFIG] = {};
bool boolean[LAST_BOOLEAN_CONFIG] = {};
ExperienceStages expStages = {};
bool loaded = false;
};
#endif