[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:
VladimirMangos 2011-02-19 03:28:13 +03:00
parent 972c08a878
commit 01f68f4187
4 changed files with 42 additions and 13 deletions

View file

@ -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

View file

@ -102,6 +102,7 @@ class MapPersistentState
void SaveGORespawnTime(uint32 loguid, time_t t);
// pool system
void InitPools();
virtual SpawnedPoolData& GetSpawnedPoolData() =0;
template<typename T>
@ -327,12 +328,15 @@ class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton<MapPe
~MapPersistentStateManager();
public: // common for all MapPersistentState (sub)classes
// For proper work pool systems with shared pools state for non-instanceable maps need
// load persistent map states for any non-instanceable maps before init pool system
void InitWorldMaps();
void LoadCreatureRespawnTimes();
void LoadGameobjectRespawnTimes();
// auto select appropriate MapPersistentState (sub)class by MapEntry, and autoselect appropriate way store (by instance/map id)
// always return != NULL
MapPersistentState* AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load = false);
MapPersistentState* AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load = false, bool initPools = true);
// search stored state, can be NULL in result
MapPersistentState *GetPersistentState(uint32 mapId, uint32 InstanceId);

View file

@ -1058,10 +1058,13 @@ void World::SetInitialWorldSettings()
sLog.outString( ">>> Game Event Data loaded" );
sLog.outString();
sLog.outString( "Loading Creature Respawn Data..." ); // must be after PackInstances(), LoadCreatures(), sPoolMgr.LoadFromDB(), sGameEventMgr.LoadFromDB();
sLog.outString( "Creating map persistent states for non-instanceable maps..." ); // must be after PackInstances(), LoadCreatures(), sPoolMgr.LoadFromDB(), sGameEventMgr.LoadFromDB();
sMapPersistentStateMgr.InitWorldMaps();
sLog.outString( "Loading Creature Respawn Data..." ); // must be after LoadCreatures(), and sMapPersistentStateMgr.InitWorldMaps()
sMapPersistentStateMgr.LoadCreatureRespawnTimes();
sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after PackInstances(), LoadGameobjects(), sPoolMgr.LoadFromDB(), sGameEventMgr.LoadFromDB();
sLog.outString( "Loading Gameobject Respawn Data..." ); // must be after LoadGameobjects(), and sMapPersistentStateMgr.InitWorldMaps()
sMapPersistentStateMgr.LoadGameobjectRespawnTimes();
sLog.outString( "Loading UNIT_NPC_FLAG_SPELLCLICK Data..." );

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11187"
#define REVISION_NR "11188"
#endif // __REVISION_NR_H__