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

@@ -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());

View File

@@ -319,6 +319,7 @@ class Map : public GridRefManager<NGridType>
}
void LoadGrid(float x, float y);
void LoadAllCells();
bool UnloadGrid(NGridType& ngrid);
virtual void UnloadAll();

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
};

View File

@@ -203,15 +203,6 @@ SaveRespawnTimeImmediately = 1
MaxOverspeedPings = 2
#
# GridUnload
# Description: Unload grids to save memory. Can be disabled if enough memory is available
# to speed up moving players to new grids.
# Default: 1 - (enable, Unload grids)
# 0 - (disable, Do not unload grids)
GridUnload = 1
#
# CloseIdleConnections
# Description: Automatically close idle connections.
@@ -246,13 +237,6 @@ SocketTimeOutTimeActive = 60000
SessionAddDelay = 10000
#
# GridCleanUpDelay
# Description: Time (in milliseconds) grid clean up delay.
# Default: 300000 - (5 minutes)
GridCleanUpDelay = 300000
#
# MapUpdateInterval
# Description: Time (milliseconds) for map update interval.
@@ -416,6 +400,18 @@ CleanCharacterDB = 0
PersistentCharacterCleanFlags = 0
#
# PreloadAllNonInstancedMapGrids
# Description: Preload all grids on all non-instanced maps. This will take a great amount
# of additional RAM (ca. 9 GB) and causes the server to take longer to start,
# but can increase performance if used on a server with a high amount of players.
# It will also activate all creatures which are set active (e.g. the Fel Reavers
# in Hellfire Peninsula) on server start.
# Default: 0 - (Disabled)
# 1 - (Enabled)
PreloadAllNonInstancedMapGrids = 0
#
###################################################################################################