fix(Core/Grid): Implement missing GridUnload setting (#17569)

* Implement GridUnload setting

* Minor fixes

- Use GetOption instead of deprecated GetBoolDefault.
- Added a missing check for instances in LoadMap
- Replaced some numbers with global defines

* Possible crashfix + minor improvements

- Initialized initialOrientation which I had forgotten (likely cause of crash)
- Readded a previous check in UpdateSplineMovement
- Made i_objectsToRemove and i_worldObjects tos sets as they were previously, instead of unordered_set.

* Update worldserver.conf.dist

* Fix high CPU usage with preload grid enabled.

This should be it.
This commit is contained in:
AG
2023-10-27 00:32:15 +02:00
committed by GitHub
parent 23a620007b
commit 79b39f9655
8 changed files with 52 additions and 29 deletions

View File

@@ -72,6 +72,7 @@ enum WorldBoolConfigs
CONFIG_ADDON_CHANNEL,
CONFIG_ALLOW_PLAYER_COMMANDS,
CONFIG_CLEAN_CHARACTER_DB,
CONFIG_GRID_UNLOAD,
CONFIG_STATS_SAVE_ONLY_ON_LOGOUT,
CONFIG_ALLOW_TWO_SIDE_ACCOUNTS,
CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR,

View File

@@ -1420,8 +1420,16 @@ void World::LoadConfigSettings(bool reload)
// Prevent players AFK from being logged out
_int_configs[CONFIG_AFK_PREVENT_LOGOUT] = sConfigMgr->GetOption<int32>("PreventAFKLogout", 0);
// Unload grids to save memory. Can be disabled if enough memory is available to speed up moving players to new grids.
_bool_configs[CONFIG_GRID_UNLOAD] = sConfigMgr->GetOption<bool>("GridUnload", true);
// Preload all grids of all non-instanced maps
_bool_configs[CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS] = sConfigMgr->GetOption<bool>("PreloadAllNonInstancedMapGrids", false);
if (_bool_configs[CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS] && _bool_configs[CONFIG_GRID_UNLOAD])
{
LOG_ERROR("server.loading", "PreloadAllNonInstancedMapGrids enabled, but GridUnload also enabled. GridUnload must be disabled to enable base map pre-loading. Base map pre-loading disabled");
_bool_configs[CONFIG_PRELOAD_ALL_NON_INSTANCED_MAP_GRIDS] = false;
}
// ICC buff override
_int_configs[CONFIG_ICC_BUFF_HORDE] = sConfigMgr->GetOption<int32>("ICC.Buff.Horde", 73822);
@@ -2164,21 +2172,14 @@ void World::SetInitialWorldSettings()
{
LOG_INFO("server.loading", "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())
sMapMgr->DoForAllMaps([](Map* map)
{
Map* map = sMapMgr->CreateBaseMap(mapEntry->MapID);
if (map)
if (!map->Instanceable())
{
LOG_INFO("server.loading", ">> Loading All Grids For Map {}", map->GetId());
map->LoadAllCells();
}
}
}
});
}
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);