diff --git a/ElunaConfig.cpp b/ElunaConfig.cpp index 3f7c9d03b6..b0db965c5f 100644 --- a/ElunaConfig.cpp +++ b/ElunaConfig.cpp @@ -38,6 +38,24 @@ void ElunaConfig::Initialize() SetConfig(CONFIG_ELUNA_ONLY_ON_MAPS, "Eluna.OnlyOnMaps", ""); SetConfig(CONFIG_ELUNA_REQUIRE_PATH_EXTRA, "Eluna.RequirePaths", ""); SetConfig(CONFIG_ELUNA_REQUIRE_CPATH_EXTRA, "Eluna.RequireCPaths", ""); + + // tokenize OnlyOnMaps + m_requiredMaps.clear(); + std::istringstream maps(GetConfig(CONFIG_ELUNA_ONLY_ON_MAPS)); + while (maps.good()) + { + std::string mapIdStr; + std::getline(maps, mapIdStr, ','); + if (maps.fail() || maps.bad()) + break; + try { + uint32 mapId = std::stoul(mapIdStr); + m_requiredMaps.emplace_back(mapId); + } + catch (std::exception&) { + ELUNA_LOG_ERROR("[Eluna]: Error tokenizing Eluna.OnlyOnMaps, invalid config value '%s'", mapIdStr.c_str()); + } + } } void ElunaConfig::SetConfig(ElunaConfigBoolValues index, char const* fieldname, bool defvalue) @@ -69,3 +87,11 @@ bool ElunaConfig::IsElunaCompatibilityMode() { return GetConfig(CONFIG_ELUNA_COMPATIBILITY_MODE); } + +bool ElunaConfig::ShouldMapLoadEluna(uint32 id) +{ + if (!m_requiredMaps.size()) + return true; + + return (std::find(m_requiredMaps.begin(), m_requiredMaps.end(), id) != m_requiredMaps.end()); +} diff --git a/ElunaConfig.h b/ElunaConfig.h index 398f039a7e..8421d9d864 100644 --- a/ElunaConfig.h +++ b/ElunaConfig.h @@ -47,6 +47,7 @@ class ElunaConfig bool IsElunaEnabled(); bool IsElunaCompatibilityMode(); + bool ShouldMapLoadEluna(uint32 mapId); private: bool _configBoolValues[CONFIG_ELUNA_BOOL_COUNT]; @@ -54,6 +55,8 @@ class ElunaConfig void SetConfig(ElunaConfigBoolValues index, char const* fieldname, bool defvalue); void SetConfig(ElunaConfigStringValues index, char const* fieldname, std::string defvalue); + + std::list m_requiredMaps; }; #define sElunaConfig ElunaConfig::instance() diff --git a/ElunaLoader.cpp b/ElunaLoader.cpp index 5b41c66d0d..8e1106bff3 100644 --- a/ElunaLoader.cpp +++ b/ElunaLoader.cpp @@ -157,23 +157,6 @@ void ElunaLoader::LoadScripts() if (!m_requirecPath.empty()) m_requirecPath.erase(m_requirecPath.end() - 1); - m_requiredMaps.clear(); - std::istringstream maps(sElunaConfig->GetConfig(CONFIG_ELUNA_ONLY_ON_MAPS)); - while (maps.good()) - { - std::string mapIdStr; - std::getline(maps, mapIdStr, ','); - if (maps.fail() || maps.bad()) - break; - try { - uint32 mapId = std::stoul(mapIdStr); - m_requiredMaps.emplace_back(mapId); - } - catch (std::exception&) { - ELUNA_LOG_ERROR("[Eluna]: Error tokenizing Eluna.OnlyOnMaps, invalid config value '%s'", mapIdStr.c_str()); - } - } - ELUNA_LOG_INFO("[Eluna]: Loaded and precompiled %u scripts in %u ms", uint32(m_scriptCache.size()), ElunaUtil::GetTimeDiff(oldMSTime)); // set the cache state to ready @@ -368,14 +351,6 @@ void ElunaLoader::CombineLists() m_scripts.clear(); } -bool ElunaLoader::ShouldMapLoadEluna(uint32 id) -{ - if (!m_requiredMaps.size()) - return true; - - return (std::find(m_requiredMaps.begin(), m_requiredMaps.end(), id) != m_requiredMaps.end()); -} - void ElunaLoader::ReloadElunaForMap(int mapId) { // reload the script cache asynchronously diff --git a/ElunaLoader.h b/ElunaLoader.h index 426dab8192..0600692379 100644 --- a/ElunaLoader.h +++ b/ElunaLoader.h @@ -51,7 +51,6 @@ class ElunaLoader static ElunaLoader* instance(); void LoadScripts(); - bool ShouldMapLoadEluna(uint32 mapId); void ReloadElunaForMap(int mapId); uint8 GetCacheState() const { return m_cacheState; } @@ -80,7 +79,6 @@ class ElunaLoader std::string m_requirecPath; std::list m_scripts; std::list m_extensions; - std::list m_requiredMaps; std::thread m_reloadThread; };