mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[11129] Added WorldMap/WorldPersistentState subclass for non-instanceable maps.
This let have symmetric Map/MapPersistentState (sub)classes hierarchy.
This commit is contained in:
parent
98aff742c1
commit
6d26ec0e7f
6 changed files with 62 additions and 26 deletions
|
|
@ -1302,6 +1302,13 @@ template void Map::Remove(Creature *,bool);
|
||||||
template void Map::Remove(GameObject *, bool);
|
template void Map::Remove(GameObject *, bool);
|
||||||
template void Map::Remove(DynamicObject *, bool);
|
template void Map::Remove(DynamicObject *, bool);
|
||||||
|
|
||||||
|
/* ******* World Maps ******* */
|
||||||
|
|
||||||
|
WorldPersistentState* WorldMap::GetPersistanceState() const
|
||||||
|
{
|
||||||
|
return (WorldPersistentState*)Map::GetPersistentState();
|
||||||
|
}
|
||||||
|
|
||||||
/* ******* Dungeon Instance Maps ******* */
|
/* ******* Dungeon Instance Maps ******* */
|
||||||
|
|
||||||
DungeonMap::DungeonMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode)
|
DungeonMap::DungeonMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode)
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ class WorldPacket;
|
||||||
class InstanceData;
|
class InstanceData;
|
||||||
class Group;
|
class Group;
|
||||||
class MapPersistentState;
|
class MapPersistentState;
|
||||||
|
class WorldPersistentState;
|
||||||
class DungeonPersistentState;
|
class DungeonPersistentState;
|
||||||
class BattleGroundPersistentState;
|
class BattleGroundPersistentState;
|
||||||
struct ScriptInfo;
|
struct ScriptInfo;
|
||||||
|
|
@ -93,8 +94,10 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
|
||||||
friend class MapReference;
|
friend class MapReference;
|
||||||
friend class ObjectGridLoader;
|
friend class ObjectGridLoader;
|
||||||
friend class ObjectWorldLoader;
|
friend class ObjectWorldLoader;
|
||||||
public:
|
protected:
|
||||||
Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode);
|
Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode);
|
||||||
|
|
||||||
|
public:
|
||||||
virtual ~Map();
|
virtual ~Map();
|
||||||
|
|
||||||
// currently unused for normal maps
|
// currently unused for normal maps
|
||||||
|
|
@ -339,6 +342,18 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
|
||||||
void RemoveFromGrid(T*, NGridType *, Cell const&);
|
void RemoveFromGrid(T*, NGridType *, Cell const&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MANGOS_DLL_SPEC WorldMap : public Map
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
using Map::GetPersistentState; // hide in subclass for overwrite
|
||||||
|
public:
|
||||||
|
WorldMap(uint32 id, time_t expiry) : Map(id, expiry, 0, REGULAR_DIFFICULTY) {}
|
||||||
|
~WorldMap() {}
|
||||||
|
|
||||||
|
// can't be NULL for loaded map
|
||||||
|
WorldPersistentState* GetPersistanceState() const;
|
||||||
|
};
|
||||||
|
|
||||||
class MANGOS_DLL_SPEC DungeonMap : public Map
|
class MANGOS_DLL_SPEC DungeonMap : public Map
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -108,11 +108,11 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//create regular Continent map
|
//create regular non-instanceable map
|
||||||
m = FindMap(id);
|
m = FindMap(id);
|
||||||
if( m == NULL )
|
if( m == NULL )
|
||||||
{
|
{
|
||||||
m = new Map(id, i_gridCleanUpDelay, 0, REGULAR_DIFFICULTY);
|
m = new WorldMap(id, i_gridCleanUpDelay);
|
||||||
//add map into container
|
//add map into container
|
||||||
i_maps[MapID(id)] = m;
|
i_maps[MapID(id)] = m;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,6 @@ MapEntry const* MapPersistentState::GetMapEntry() const
|
||||||
return sMapStore.LookupEntry(m_mapid);
|
return sMapStore.LookupEntry(m_mapid);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MapPersistentState::CanBeUnload() const
|
|
||||||
{
|
|
||||||
// prevent unload if used for loaded map
|
|
||||||
// prevent unload if respawn data still exist (will not prevent reset by scheduler)
|
|
||||||
return !m_usedByMap && m_creatureRespawnTimes.empty() && m_goRespawnTimes.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* true if the instance state is still valid */
|
/* true if the instance state is still valid */
|
||||||
bool MapPersistentState::UnloadIfEmpty()
|
bool MapPersistentState::UnloadIfEmpty()
|
||||||
{
|
{
|
||||||
|
|
@ -135,7 +128,14 @@ void MapPersistentState::ClearRespawnTimes()
|
||||||
UnloadIfEmpty();
|
UnloadIfEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//== WorldPersistentState functions ========================
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
//== DungeonPersistentState functions =====================
|
//== DungeonPersistentState functions =====================
|
||||||
|
|
||||||
|
|
@ -161,7 +161,7 @@ DungeonPersistentState::~DungeonPersistentState()
|
||||||
bool DungeonPersistentState::CanBeUnload() const
|
bool DungeonPersistentState::CanBeUnload() const
|
||||||
{
|
{
|
||||||
// prevent unload if any bounded groups or online bounded player still exists
|
// prevent unload if any bounded groups or online bounded player still exists
|
||||||
return MapPersistentState::CanBeUnload() && m_playerList.empty() && m_groupList.empty();
|
return MapPersistentState::CanBeUnload() && HasBounds() && HasRespawnTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -222,7 +222,7 @@ bool BattleGroundPersistentState::CanBeUnload() const
|
||||||
{
|
{
|
||||||
// prevent unload if used for loaded map
|
// prevent unload if used for loaded map
|
||||||
// BGs/Arenas not locked by respawn data/etc
|
// BGs/Arenas not locked by respawn data/etc
|
||||||
return !IsUsedByMap();
|
return MapPersistentState::CanBeUnload();
|
||||||
}
|
}
|
||||||
|
|
||||||
//== DungeonResetScheduler functions ======================
|
//== DungeonResetScheduler functions ======================
|
||||||
|
|
@ -521,7 +521,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const
|
||||||
else if (mapEntry->IsBattleGroundOrArena())
|
else if (mapEntry->IsBattleGroundOrArena())
|
||||||
state = new BattleGroundPersistentState(mapEntry->MapID, instanceId, difficulty);
|
state = new BattleGroundPersistentState(mapEntry->MapID, instanceId, difficulty);
|
||||||
else
|
else
|
||||||
state = new MapPersistentState(mapEntry->MapID, instanceId, difficulty);
|
state = new WorldPersistentState(mapEntry->MapID);
|
||||||
|
|
||||||
|
|
||||||
if (instanceId)
|
if (instanceId)
|
||||||
|
|
|
||||||
|
|
@ -38,21 +38,14 @@ class Group;
|
||||||
|
|
||||||
class MapPersistentStateManager;
|
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
|
class MapPersistentState
|
||||||
{
|
{
|
||||||
friend class MapPersistentStateManager;
|
friend class MapPersistentStateManager;
|
||||||
public:
|
protected:
|
||||||
/* 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 */
|
|
||||||
MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty);
|
MapPersistentState(uint16 MapId, uint32 InstanceId, Difficulty difficulty);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
/* Unloaded when m_playerList and m_groupList become empty
|
/* Unloaded when m_playerList and m_groupList become empty
|
||||||
or when the instance is reset */
|
or when the instance is reset */
|
||||||
virtual ~MapPersistentState();
|
virtual ~MapPersistentState();
|
||||||
|
|
@ -92,9 +85,15 @@ class MapPersistentState
|
||||||
void SaveGORespawnTime(uint32 loguid, time_t t);
|
void SaveGORespawnTime(uint32 loguid, time_t t);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool CanBeUnload() const;
|
virtual bool CanBeUnload() const =0
|
||||||
|
{
|
||||||
|
// prevent unload if used for loaded map
|
||||||
|
return !m_usedByMap;
|
||||||
|
}
|
||||||
|
|
||||||
bool UnloadIfEmpty();
|
bool UnloadIfEmpty();
|
||||||
void ClearRespawnTimes();
|
void ClearRespawnTimes();
|
||||||
|
bool HasRespawnTimes() const { return m_creatureRespawnTimes.empty() && m_goRespawnTimes.empty(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetCreatureRespawnTime(uint32 loguid, time_t t);
|
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
|
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
|
Holds the information necessary for creating a new map for an existing instance
|
||||||
Is referenced in three cases:
|
Is referenced in three cases:
|
||||||
|
|
@ -167,6 +181,7 @@ class DungeonPersistentState : public MapPersistentState
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CanBeUnload() const; // overwrite MapPersistentState::CanBeUnload
|
bool CanBeUnload() const; // overwrite MapPersistentState::CanBeUnload
|
||||||
|
bool HasBounds() const { return m_playerList.empty() && m_groupList.empty(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::list<Player*> PlayerListType;
|
typedef std::list<Player*> PlayerListType;
|
||||||
|
|
@ -197,7 +212,6 @@ class BattleGroundPersistentState : public MapPersistentState
|
||||||
bool CanBeUnload() const; // overwrite MapPersistentState::CanBeUnload
|
bool CanBeUnload() const; // overwrite MapPersistentState::CanBeUnload
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum ResetEventType
|
enum ResetEventType
|
||||||
{
|
{
|
||||||
RESET_EVENT_NORMAL_DUNGEON = 0, // no fixed reset time
|
RESET_EVENT_NORMAL_DUNGEON = 0, // no fixed reset time
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11128"
|
#define REVISION_NR "11129"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue