[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

@ -6227,13 +6227,13 @@ bool ChatHandler::HandleInstanceListBindsCommand(char* /*args*/)
Player::BoundInstancesMap &binds = player->GetBoundInstances(Difficulty(i));
for(Player::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr)
{
InstanceSave *save = itr->second.save;
std::string timeleft = secsToTimeString(save->GetResetTime() - time(NULL), true);
DungeonPersistentState *state = itr->second.state;
std::string timeleft = secsToTimeString(state->GetResetTime() - time(NULL), true);
if (const MapEntry* entry = sMapStore.LookupEntry(itr->first))
{
PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s",
itr->first, entry->name[GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no",
save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
itr->first, entry->name[GetSessionDbcLocale()], state->GetInstanceId(), itr->second.perm ? "yes" : "no",
state->GetDifficulty(), state->CanReset() ? "yes" : "no", timeleft.c_str());
}
else
PSendSysMessage("bound for a nonexistent map %u", itr->first);
@ -6242,21 +6242,21 @@ bool ChatHandler::HandleInstanceListBindsCommand(char* /*args*/)
}
PSendSysMessage("player binds: %d", counter);
counter = 0;
Group *group = player->GetGroup();
if(group)
if (Group *group = player->GetGroup())
{
for(uint8 i = 0; i < MAX_DIFFICULTY; ++i)
{
Group::BoundInstancesMap &binds = group->GetBoundInstances(Difficulty(i));
for(Group::BoundInstancesMap::const_iterator itr = binds.begin(); itr != binds.end(); ++itr)
{
InstanceSave *save = itr->second.save;
std::string timeleft = secsToTimeString(save->GetResetTime() - time(NULL), true);
DungeonPersistentState *state = itr->second.state;
std::string timeleft = secsToTimeString(state->GetResetTime() - time(NULL), true);
if (const MapEntry* entry = sMapStore.LookupEntry(itr->first))
{
PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s",
itr->first, entry->name[GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no",
save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str());
itr->first, entry->name[GetSessionDbcLocale()], state->GetInstanceId(), itr->second.perm ? "yes" : "no",
state->GetDifficulty(), state->CanReset() ? "yes" : "no", timeleft.c_str());
}
else
PSendSysMessage("bound for a nonexistent map %u", itr->first);
@ -6302,7 +6302,7 @@ bool ChatHandler::HandleInstanceUnbindCommand(char* args)
}
if(itr->first != player->GetMapId())
{
InstanceSave *save = itr->second.save;
DungeonPersistentState *save = itr->second.state;
std::string timeleft = secsToTimeString(save->GetResetTime() - time(NULL), true);
if (const MapEntry* entry = sMapStore.LookupEntry(itr->first))
@ -6328,9 +6328,12 @@ bool ChatHandler::HandleInstanceStatsCommand(char* /*args*/)
{
PSendSysMessage("instances loaded: %d", sMapMgr.GetNumInstances());
PSendSysMessage("players in instances: %d", sMapMgr.GetNumPlayersInInstances());
PSendSysMessage("instance saves: %d", sInstanceSaveMgr.GetNumInstanceSaves());
PSendSysMessage("players bound: %d", sInstanceSaveMgr.GetNumBoundPlayersTotal());
PSendSysMessage("groups bound: %d", sInstanceSaveMgr.GetNumBoundGroupsTotal());
uint32 numSaves, numBoundPlayers, numBoundGroups;
sMapPersistentStateMgr.GetStatistics(numSaves, numBoundPlayers, numBoundGroups);
PSendSysMessage("instance saves: %d", numSaves);
PSendSysMessage("players bound: %d", numBoundPlayers);
PSendSysMessage("groups bound: %d", numBoundGroups);
return true;
}