diff --git a/src/game/MapPersistentStateMgr.cpp b/src/game/MapPersistentStateMgr.cpp index 616e1c6dd..3249ad83e 100644 --- a/src/game/MapPersistentStateMgr.cpp +++ b/src/game/MapPersistentStateMgr.cpp @@ -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 diff --git a/src/game/MapPersistentStateMgr.h b/src/game/MapPersistentStateMgr.h index da3fc31ce..6200eb623 100644 --- a/src/game/MapPersistentStateMgr.h +++ b/src/game/MapPersistentStateMgr.h @@ -102,6 +102,7 @@ class MapPersistentState void SaveGORespawnTime(uint32 loguid, time_t t); // pool system + void InitPools(); virtual SpawnedPoolData& GetSpawnedPoolData() =0; template @@ -327,12 +328,15 @@ class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton>> 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..." ); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 0cd7549c9..1a11963aa 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11187" + #define REVISION_NR "11188" #endif // __REVISION_NR_H__