[11129] Added WorldMap/WorldPersistentState subclass for non-instanceable maps.

This let have symmetric Map/MapPersistentState (sub)classes hierarchy.
This commit is contained in:
VladimirMangos 2011-02-10 18:06:39 +03:00
parent 98aff742c1
commit 6d26ec0e7f
6 changed files with 62 additions and 26 deletions

View file

@ -38,21 +38,14 @@ class Group;
class MapPersistentStateManager;
/*
Holds the information necessary for creating a new map for non-instanceable maps
As object Used for non-instanceable Map only
*/
class MapPersistentState
{
friend class MapPersistentStateManager;
public:
/* Created either when:
- any new instance is being generated
- the first time a player bound to InstanceId logs in
- when a group bound to the instance is loaded */
protected:
MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty);
public:
/* Unloaded when m_playerList and m_groupList become empty
or when the instance is reset */
virtual ~MapPersistentState();
@ -92,9 +85,15 @@ class MapPersistentState
void SaveGORespawnTime(uint32 loguid, time_t t);
protected:
virtual bool CanBeUnload() const;
virtual bool CanBeUnload() const =0
{
// prevent unload if used for loaded map
return !m_usedByMap;
}
bool UnloadIfEmpty();
void ClearRespawnTimes();
bool HasRespawnTimes() const { return m_creatureRespawnTimes.empty() && m_goRespawnTimes.empty(); }
private:
void SetCreatureRespawnTime(uint32 loguid, time_t t);
@ -113,6 +112,21 @@ class MapPersistentState
RespawnTimes m_goRespawnTimes; // lock MapPersistentState from unload, for example for temporary bound dungeon unload delay
};
class WorldPersistentState : public MapPersistentState
{
public:
/* Created either when:
- any new non-instanceable map created
- respawn data loading for non-instanceable map
*/
explicit WorldPersistentState(uint16 MapId) : MapPersistentState(MapId, 0, REGULAR_DIFFICULTY) {}
~WorldPersistentState() {}
protected:
bool CanBeUnload() const; // overwrite MapPersistentState::CanBeUnload
};
/*
Holds the information necessary for creating a new map for an existing instance
Is referenced in three cases:
@ -167,6 +181,7 @@ class DungeonPersistentState : public MapPersistentState
protected:
bool CanBeUnload() const; // overwrite MapPersistentState::CanBeUnload
bool HasBounds() const { return m_playerList.empty() && m_groupList.empty(); }
private:
typedef std::list<Player*> PlayerListType;
@ -197,7 +212,6 @@ class BattleGroundPersistentState : public MapPersistentState
bool CanBeUnload() const; // overwrite MapPersistentState::CanBeUnload
};
enum ResetEventType
{
RESET_EVENT_NORMAL_DUNGEON = 0, // no fixed reset time