mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[11188] Make sure that all WorldPersistentState objects created before pool system start.
Un-instenceable maps shared pool system state, that initilized once. For proper initilized pools in like case need have all mon-instanceable maps states created before it.
This commit is contained in:
parent
972c08a878
commit
01f68f4187
4 changed files with 42 additions and 13 deletions
|
|
@ -160,6 +160,17 @@ void MapPersistentState::RemoveGameobjectFromGrid( uint32 guid, GameObjectData c
|
|||
m_gridObjectGuids[cell_id].gameobjects.erase(guid);
|
||||
}
|
||||
|
||||
void MapPersistentState::InitPools()
|
||||
{
|
||||
// pool system initialized already for persistent state (can be shared by map states)
|
||||
if (!GetSpawnedPoolData().IsInitialized())
|
||||
{
|
||||
GetSpawnedPoolData().SetInitialized();
|
||||
sPoolMgr.Initialize(this); // init pool system data for map persistent state
|
||||
sGameEventMgr.Initialize(this); // init pool system data for map persistent state
|
||||
}
|
||||
}
|
||||
|
||||
//== WorldPersistentState functions ========================
|
||||
SpawnedPoolData WorldPersistentState::m_sharedSpawnedPoolData;
|
||||
|
||||
|
|
@ -167,7 +178,10 @@ bool WorldPersistentState::CanBeUnload() const
|
|||
{
|
||||
// prevent unload if used for loaded map
|
||||
// prevent unload if respawn data still exist (will not prevent reset by scheduler)
|
||||
return MapPersistentState::CanBeUnload() && !HasRespawnTimes();
|
||||
// Note: non instanceable Map never unload until server shutdown and in result for loaded non-instanceable maps map persistent states also not unloaded
|
||||
// but for proper work pool systems with shared pools state for non-instanceable maps need
|
||||
// load persistent map states for any non-instanceable maps before Map loading and make sure that it never unloaded
|
||||
return /*MapPersistentState::CanBeUnload() && !HasRespawnTimes()*/ false;
|
||||
}
|
||||
|
||||
//== DungeonPersistentState functions =====================
|
||||
|
|
@ -519,7 +533,7 @@ MapPersistentStateManager::~MapPersistentStateManager()
|
|||
- adding instance into manager
|
||||
- called from DungeonMap::Add, _LoadBoundInstances, LoadGroups
|
||||
*/
|
||||
MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load)
|
||||
MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load /*=false*/, bool initPools /*= true*/)
|
||||
{
|
||||
if (MapPersistentState *old_save = GetPersistentState(mapEntry->MapID, instanceId))
|
||||
return old_save;
|
||||
|
|
@ -562,13 +576,8 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const
|
|||
else
|
||||
m_instanceSaveByMapId[mapEntry->MapID] = state;
|
||||
|
||||
// pool system initialized already for persistent state (can be shared by map states)
|
||||
if (!state->GetSpawnedPoolData().IsInitialized())
|
||||
{
|
||||
sPoolMgr.Initialize(state); // init pool system data for map persistent state
|
||||
sGameEventMgr.Initialize(state); // init pool system data for map persistent state
|
||||
state->GetSpawnedPoolData().SetInitialized();
|
||||
}
|
||||
if (initPools)
|
||||
state->InitPools();
|
||||
|
||||
return state;
|
||||
}
|
||||
|
|
@ -853,6 +862,19 @@ void MapPersistentStateManager::_CleanupExpiredInstancesAtTime( time_t t )
|
|||
_DelHelper(CharacterDatabase, "id, map, instance.difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map AND instance.difficulty = instance_reset.difficulty WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)t, (uint64)t);
|
||||
}
|
||||
|
||||
|
||||
void MapPersistentStateManager::InitWorldMaps()
|
||||
{
|
||||
MapPersistentState* state = NULL; // need any from created for shared pool state
|
||||
for(uint32 mapid = 0; mapid < sMapStore.GetNumRows(); ++mapid)
|
||||
if (MapEntry const* entry = sMapStore.LookupEntry(mapid))
|
||||
if (!entry->Instanceable())
|
||||
state = AddPersistentState(entry, 0, REGULAR_DIFFICULTY, 0, false, true, false);
|
||||
|
||||
if (state)
|
||||
state->InitPools();
|
||||
}
|
||||
|
||||
void MapPersistentStateManager::LoadCreatureRespawnTimes()
|
||||
{
|
||||
// remove outdated data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue