[11126] Rewrite InstanceSaveMgr related code.

* For better fit name to related map type class InstanceMap renamed -> DungeonMap.
  This clarify usage Instanceable()/IsDungeon() because BG/Arenas maps also instanceable maps.

* InstanceSave have many code related to only DungeonMap case, so it replaced by 3 new classes:
   - MapPersistentState as base class, used for non-instanceable maps (continents and some other) (!Instenceable())
   - DungeonPersistentState subclass of MapPersistentState, used for DungeonMap states (IsDungoen())
   - BattlegroundPersistentState subclass of MapPersistentState, used for BattlegroundMap states (IsBattleGroundOrArena())

   Now all dungeon resets code moved to subclass and all player/gpoup bound functions/structures also use it.

* Map::GetInstanceSave renamed to Map::GetPersistentState and DungeonMap have specialized version
  return DungeonPersistentState (same pointer in fact with proper subcalss type)

* InstanceResetScheduler renamed to DungeonResetScheduler
This commit is contained in:
VladimirMangos 2011-02-10 03:55:45 +03:00
parent 0d16b0bdc7
commit dde16bc48c
22 changed files with 683 additions and 550 deletions

View file

@ -1270,7 +1270,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
m_isDeadByDefault = data->is_dead;
m_deathState = m_isDeadByDefault ? DEAD : ALIVE;
m_respawnTime = map->GetInstanceSave()->GetCreatureRespawnTime(m_DBTableGuid);
m_respawnTime = map->GetPersistentState()->GetCreatureRespawnTime(m_DBTableGuid);
if(m_respawnTime > time(NULL)) // not ready to respawn
{
@ -1286,7 +1286,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
{
m_respawnTime = 0;
GetMap()->GetInstanceSave()->SaveCreatureRespawnTime(m_DBTableGuid, 0);
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, 0);
}
uint32 curhealth = data->curhealth;
@ -1362,7 +1362,7 @@ void Creature::DeleteFromDB()
}
// FIXME: this not safe for another map copies can be
if (InstanceSave* save = sInstanceSaveMgr.GetInstanceSave(GetMapId(), GetInstanceId()))
if (MapPersistentState* save = sMapPersistentStateMgr.GetPersistentState(GetMapId(), GetInstanceId()))
save->SaveCreatureRespawnTime(m_DBTableGuid, 0);
sObjectMgr.DeleteCreatureData(m_DBTableGuid);
@ -1522,7 +1522,7 @@ void Creature::Respawn()
if (IsDespawned())
{
if (m_DBTableGuid)
GetMap()->GetInstanceSave()->SaveCreatureRespawnTime(m_DBTableGuid, 0);
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, 0);
m_respawnTime = time(NULL); // respawn at next tick
}
}
@ -1821,9 +1821,9 @@ void Creature::SaveRespawnTime()
return;
if(m_respawnTime > time(NULL)) // dead (no corpse)
GetMap()->GetInstanceSave()->SaveCreatureRespawnTime(m_DBTableGuid, m_respawnTime);
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, m_respawnTime);
else if (m_corpseDecayTimer > 0) // dead (corpse)
GetMap()->GetInstanceSave()->SaveCreatureRespawnTime(m_DBTableGuid, time(NULL) + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS);
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, time(NULL) + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS);
}
bool Creature::IsOutOfThreatArea(Unit* pVictim) const