@@ -25,6 +25,15 @@ extern Game g_game;
2525
2626namespace {
2727
28+ std::array<std::string, ConfigManager::LAST_STRING_CONFIG> string = {};
29+ std::array<int32_t , ConfigManager::LAST_INTEGER_CONFIG> integer = {};
30+ std::array<bool , ConfigManager::LAST_BOOLEAN_CONFIG> boolean = {};
31+
32+ using ExperienceStages = std::vector<std::tuple<uint32_t , uint32_t , float >>;
33+ ExperienceStages expStages;
34+
35+ bool loaded = false ;
36+
2837template <typename T>
2938auto getEnv (const char * envVar, T&& defaultValue)
3039{
@@ -81,12 +90,6 @@ bool getGlobalBoolean(lua_State* L, const char* identifier, const bool defaultVa
8190 return val != 0 ;
8291}
8392
84- } // namespace
85-
86- ConfigManager::ConfigManager () { string[CONFIG_FILE] = " config.lua" ; }
87-
88- namespace {
89-
9093ExperienceStages loadLuaStages (lua_State* L)
9194{
9295 ExperienceStages stages;
@@ -161,7 +164,8 @@ bool ConfigManager::load()
161164
162165 luaL_openlibs (L);
163166
164- if (luaL_dofile (L, getString (CONFIG_FILE).c_str ())) {
167+ string[CONFIG_FILE] = " config.lua" ;
168+ if (luaL_dofile (L, string[CONFIG_FILE].data ())) {
165169 std::cout << " [Error - ConfigManager::load] " << lua_tostring (L, -1 ) << std::endl;
166170 lua_close (L);
167171 return false ;
@@ -302,18 +306,17 @@ bool ConfigManager::load()
302306 return true ;
303307}
304308
305- static std::string dummyStr;
306-
307- const std::string& ConfigManager::getString (string_config_t what) const
309+ const std::string& ConfigManager::getString (string_config_t what)
308310{
311+ static std::string dummyStr;
309312 if (what >= LAST_STRING_CONFIG) {
310313 std::cout << " [Warning - ConfigManager::getString] Accessing invalid index: " << what << std::endl;
311314 return dummyStr;
312315 }
313316 return string[what];
314317}
315318
316- int32_t ConfigManager::getNumber (integer_config_t what) const
319+ int32_t ConfigManager::getNumber (integer_config_t what)
317320{
318321 if (what >= LAST_INTEGER_CONFIG) {
319322 std::cout << " [Warning - ConfigManager::getNumber] Accessing invalid index: " << what << std::endl;
@@ -322,7 +325,7 @@ int32_t ConfigManager::getNumber(integer_config_t what) const
322325 return integer[what];
323326}
324327
325- bool ConfigManager::getBoolean (boolean_config_t what) const
328+ bool ConfigManager::getBoolean (boolean_config_t what)
326329{
327330 if (what >= LAST_BOOLEAN_CONFIG) {
328331 std::cout << " [Warning - ConfigManager::getBoolean] Accessing invalid index: " << what << std::endl;
@@ -331,7 +334,7 @@ bool ConfigManager::getBoolean(boolean_config_t what) const
331334 return boolean[what];
332335}
333336
334- float ConfigManager::getExperienceStage (uint32_t level) const
337+ float ConfigManager::getExperienceStage (uint32_t level)
335338{
336339 auto it = std::find_if (expStages.begin (), expStages.end (), [level](auto && stage) {
337340 auto && [minLevel, maxLevel, _] = stage;
0 commit comments