Core/Maps: Implement optional pre-loading of maps.
- Option to preload basemaps upon server load (BaseMapLoadAllGrids) - Option to preload instance maps upon map load (InstanceMapLoadAllGrids) - Change default logging to only log mmap errors to server log - Add new public to map to load all cells in map - change debug loadcells to use new function instead (cherry picked from commit 971f4ccab87ba95e584d5761f686cc2a86f5af9d)
This commit is contained in:
@@ -132,9 +132,9 @@ void Map::LoadMMap(int gx, int gy)
|
||||
bool mmapLoadResult = MMAP::MMapFactory::createOrGetMMapManager()->loadMap((sWorld->GetDataPath() + "mmaps").c_str(), GetId(), gx, gy);
|
||||
|
||||
if (mmapLoadResult)
|
||||
TC_LOG_DEBUG("maps", "MMAP loaded name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
TC_LOG_DEBUG("mmaps", "MMAP loaded name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
else
|
||||
TC_LOG_ERROR("maps", "Could not load MMAP name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
TC_LOG_ERROR("mmaps", "Could not load MMAP name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
|
||||
}
|
||||
|
||||
void Map::LoadVMap(int gx, int gy)
|
||||
@@ -208,6 +208,13 @@ void Map::LoadMapAndVMap(int gx, int gy)
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void Map::InitStateMachine()
|
||||
{
|
||||
si_GridStates[GRID_STATE_INVALID] = new InvalidState;
|
||||
|
||||
@@ -313,6 +313,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
bool GetUnloadLock(const GridCoord &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
|
||||
void SetUnloadLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
|
||||
void LoadGrid(float x, float y);
|
||||
void LoadAllCells();
|
||||
bool UnloadGrid(NGridType& ngrid, bool pForce);
|
||||
virtual void UnloadAll();
|
||||
|
||||
|
||||
@@ -238,6 +238,9 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
|
||||
bool load_data = save != NULL;
|
||||
map->CreateInstanceData(load_data);
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_INSTANCEMAP_LOAD_GRIDS))
|
||||
map->LoadAllCells();
|
||||
|
||||
m_InstancedMaps[InstanceId] = map;
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -653,6 +653,18 @@ void World::LoadConfigSettings(bool reload)
|
||||
m_bool_configs[CONFIG_PRESERVE_CUSTOM_CHANNELS] = sConfigMgr->GetBoolDefault("PreserveCustomChannels", false);
|
||||
m_int_configs[CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION] = sConfigMgr->GetIntDefault("PreserveCustomChannelDuration", 14);
|
||||
m_bool_configs[CONFIG_GRID_UNLOAD] = sConfigMgr->GetBoolDefault("GridUnload", true);
|
||||
m_bool_configs[CONFIG_BASEMAP_LOAD_GRIDS] = sConfigMgr->GetBoolDefault("BaseMapLoadAllGrids", false);
|
||||
if (m_bool_configs[CONFIG_BASEMAP_LOAD_GRIDS] && m_bool_configs[CONFIG_GRID_UNLOAD])
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", "BaseMapLoadAllGrids enabled, but GridUnload also enabled. GridUnload must be disabled to enable base map pre-loading. Base map pre-loading disabled");
|
||||
m_bool_configs[CONFIG_BASEMAP_LOAD_GRIDS] = false;
|
||||
}
|
||||
m_bool_configs[CONFIG_INSTANCEMAP_LOAD_GRIDS] = sConfigMgr->GetBoolDefault("InstanceMapLoadAllGrids", false);
|
||||
if (m_bool_configs[CONFIG_INSTANCEMAP_LOAD_GRIDS] && m_bool_configs[CONFIG_GRID_UNLOAD])
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", "InstanceMapLoadAllGrids enabled, but GridUnload also enabled. GridUnload must be disabled to enable instance map pre-loading. Instance map pre-loading disabled");
|
||||
m_bool_configs[CONFIG_INSTANCEMAP_LOAD_GRIDS] = false;
|
||||
}
|
||||
m_int_configs[CONFIG_INTERVAL_SAVE] = sConfigMgr->GetIntDefault("PlayerSaveInterval", 15 * MINUTE * IN_MILLISECONDS);
|
||||
m_int_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE] = sConfigMgr->GetIntDefault("DisconnectToleranceInterval", 0);
|
||||
m_bool_configs[CONFIG_STATS_SAVE_ONLY_ON_LOGOUT] = sConfigMgr->GetBoolDefault("PlayerSave.Stats.SaveOnlyOnLogout", true);
|
||||
@@ -2060,6 +2072,19 @@ void World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("server.loading", "Loading battle pets info...");
|
||||
BattlePetMgr::Initialize();
|
||||
|
||||
// Preload all cells, if required for the base maps
|
||||
if (sWorld->getBoolConfig(CONFIG_BASEMAP_LOAD_GRIDS))
|
||||
{
|
||||
sMapMgr->DoForAllMaps([](Map* map)
|
||||
{
|
||||
if (!map->Instanceable())
|
||||
{
|
||||
TC_LOG_INFO("server.loading", "Pre-loading base map data for map %u", map->GetId());
|
||||
map->LoadAllCells();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
|
||||
|
||||
TC_LOG_INFO("server.worldserver", "World initialized in %u minutes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000));
|
||||
|
||||
@@ -177,6 +177,8 @@ enum WorldBoolConfigs
|
||||
CONFIG_FEATURE_SYSTEM_CHARACTER_UNDELETE_ENABLED,
|
||||
CONFIG_RESET_DUEL_COOLDOWNS,
|
||||
CONFIG_RESET_DUEL_HEALTH_MANA,
|
||||
CONFIG_BASEMAP_LOAD_GRIDS,
|
||||
CONFIG_INSTANCEMAP_LOAD_GRIDS,
|
||||
BOOL_CONFIG_VALUE_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -1414,10 +1414,7 @@ public:
|
||||
if (!map)
|
||||
map = player->GetMap();
|
||||
|
||||
for (uint32 cellX = 0; cellX < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellX++)
|
||||
for (uint32 cellY = 0; cellY < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellY++)
|
||||
map->LoadGrid((cellX + 0.5f - CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL, (cellY + 0.5f - CENTER_GRID_CELL_ID) * SIZE_OF_GRID_CELL);
|
||||
|
||||
map->LoadAllCells();
|
||||
handler->PSendSysMessage("Cells loaded (mapId: %u)", map->GetId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -292,6 +292,25 @@ MaxOverspeedPings = 2
|
||||
|
||||
GridUnload = 1
|
||||
|
||||
#
|
||||
# BaseMapLoadAllGrids
|
||||
# Description: Load all grids for base maps upon load. Requires GridUnload to be 0.
|
||||
# This will take around 5GB of ram upon server load, and will take some time
|
||||
# to initially load the server.
|
||||
# Default: 0 - (Don't pre-load all base maps, dynamically load as used)
|
||||
# 1 - (Preload all grids in all base maps upon load)
|
||||
|
||||
BaseMapLoadAllGrids = 0
|
||||
|
||||
#
|
||||
# InstanceMapLoadAllGrids
|
||||
# Description: Load all grids for instance maps upon load. Requires GridUnload to be 0.
|
||||
# Upon loading an instance map, all creatures/objects in the map will be pre-loaded
|
||||
# Default: 0 - (Don't pre-load all base maps, dynamically load as used)
|
||||
# 1 - (Preload all grids in the instance upon load)
|
||||
|
||||
InstanceMapLoadAllGrids = 0
|
||||
|
||||
#
|
||||
# SocketTimeOutTime
|
||||
# Description: Time (in milliseconds) after which a connection being idle on the character
|
||||
@@ -3498,6 +3517,7 @@ Logger.server=3,Console Server
|
||||
Logger.commands.gm=3,Console GM
|
||||
Logger.sql.sql=5,Console DBErrors
|
||||
Logger.sql.updates=3,Console Server
|
||||
Logger.mmaps=3,Server
|
||||
|
||||
#Logger.achievement=3,Console Server
|
||||
#Logger.addon=3,Console Server
|
||||
|
||||
Reference in New Issue
Block a user