mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-14 16:03:45 +00:00
feat(Core/Config): Add parameter to load all grids of all non-instanced maps on server start (#2283)
This commit is contained in:
@@ -469,6 +469,13 @@ void Map::LoadGrid(float x, float y)
|
||||
EnsureGridLoaded(Cell(x, y));
|
||||
}
|
||||
|
||||
void Map::LoadAllCells()
|
||||
{
|
||||
for (uint32 cellX = 0; cellX < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellX++)
|
||||
for (uint32 cellY = 0; cellY < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellY++)
|
||||
LoadGrid((cellX + 0.5f - CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL, (cellY + 0.5f - CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL);
|
||||
}
|
||||
|
||||
bool Map::AddPlayerToMap(Player* player)
|
||||
{
|
||||
CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
|
||||
|
||||
@@ -319,6 +319,7 @@ class Map : public GridRefManager<NGridType>
|
||||
}
|
||||
|
||||
void LoadGrid(float x, float y);
|
||||
void LoadAllCells();
|
||||
bool UnloadGrid(NGridType& ngrid);
|
||||
virtual void UnloadAll();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user