feat(Core/Config): Add parameter to load all grids of all non-instanced maps on server start (#2283)

This commit is contained in:
Stoabrogga
2019-09-30 17:06:32 +02:00
committed by GitHub
parent 439bcbda19
commit ab55aa4e5a
5 changed files with 45 additions and 16 deletions

View File

@@ -1326,6 +1326,9 @@ void World::LoadConfigSettings(bool reload)
// Prevent players AFK from being logged out
m_int_configs[CONFIG_AFK_PREVENT_LOGOUT] = sConfigMgr->GetIntDefault("PreventAFKLogout", 0);
// Preload all grids of all non-instanced maps
m_bool_configs[CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS] = sConfigMgr->GetIntDefault("PreloadAllNonInstancedMapGrids", false);
// call ScriptMgr if we're reloading the configuration
sScriptMgr->OnAfterConfigLoad(reload);
}
@@ -1958,6 +1961,27 @@ void World::SetInitialWorldSettings()
sEluna->RunScripts();
sEluna->OnConfigLoad(false,false); // Must be done after Eluna is initialized and scripts have run.
#endif
if (sWorld->getBoolConfig(CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS))
{
sLog->outString("Loading all grids for all non-instanced maps...");
for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
{
MapEntry const* mapEntry = sMapStore.LookupEntry(i);
if (mapEntry && !mapEntry->Instanceable())
{
Map* map = sMapMgr->CreateBaseMap(mapEntry->MapID);
if (map)
{
sLog->outString(">> Loading all grids for map %u", map->GetId());
map->LoadAllCells();
}
}
}
}
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
sLog->outString();

View File

@@ -169,6 +169,7 @@ enum WorldBoolConfigs
CONFIG_CHECK_GOBJECT_LOS,
CONFIG_CLOSE_IDLE_CONNECTIONS,
CONFIG_LFG_LOCATION_ALL, // Player can join LFG anywhere
CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS,
BOOL_CONFIG_VALUE_COUNT
};