[11810] Fix a bug preventing displaying correct instance reset time

Also do some small style changes in the area

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
Schmoozerd 2011-09-27 05:00:40 +02:00
parent d55e1b3edb
commit 7279c16533
2 changed files with 32 additions and 31 deletions

View file

@ -384,9 +384,11 @@ void DungeonResetScheduler::LoadResetTimes()
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 instance = fields[1].GetUInt32();
time_t resettime = time_t(fields[0].GetUInt64() + 2 * HOUR); time_t resettime = time_t(fields[0].GetUInt64() + 2 * HOUR);
uint32 instance = fields[1].GetUInt32();
InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance); InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
if(itr != instResetTime.end() && itr->second.second != resettime) if(itr != instResetTime.end() && itr->second.second != resettime)
{ {
@ -411,10 +413,11 @@ void DungeonResetScheduler::LoadResetTimes()
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 mapid = fields[0].GetUInt32();
Difficulty difficulty = Difficulty(fields[1].GetUInt32()); uint32 mapid = fields[0].GetUInt32();
uint64 oldresettime = fields[2].GetUInt64(); Difficulty difficulty = Difficulty(fields[1].GetUInt32());
uint64 oldresettime = fields[2].GetUInt64();
MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); MapEntry const* mapEntry = sMapStore.LookupEntry(mapid);
@ -619,7 +622,7 @@ MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const
MapPersistentState *state; MapPersistentState *state;
if (mapEntry->IsDungeon()) if (mapEntry->IsDungeon())
{ {
DungeonPersistentState* dungeonState = new DungeonPersistentState(mapEntry->MapID, instanceId, difficulty, completedEncountersMask, resetTime, canReset); DungeonPersistentState* dungeonState = new DungeonPersistentState(mapEntry->MapID, instanceId, difficulty, resetTime, canReset, completedEncountersMask);
if (!load) if (!load)
dungeonState->SaveToDB(); dungeonState->SaveToDB();
state = dungeonState; state = dungeonState;
@ -941,6 +944,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
uint32 count = 0; uint32 count = 0;
// 0 1 2 3 4 5 6
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id"); QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM creature_respawn LEFT JOIN instance ON instance = id");
if (!result) if (!result)
{ {
@ -957,18 +961,16 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint32 loguid = fields[0].GetUInt32(); uint32 loguid = fields[0].GetUInt32();
uint64 respawn_time = fields[1].GetUInt64(); uint64 respawn_time = fields[1].GetUInt64();
uint32 mapId = fields[2].GetUInt32(); uint32 mapId = fields[2].GetUInt32();
uint32 instanceId = fields[3].GetUInt32(); uint32 instanceId = fields[3].GetUInt32();
uint8 difficulty = fields[4].GetUInt8(); uint8 difficulty = fields[4].GetUInt8();
time_t resetTime = (time_t)fields[5].GetUInt64();
time_t resetTime = (time_t)fields[5].GetUInt64(); uint32 completedEncounters = fields[6].GetUInt32();
uint32 completedEncounters = fields[6].GetUInt32();
CreatureData const* data = sObjectMgr.GetCreatureData(loguid); CreatureData const* data = sObjectMgr.GetCreatureData(loguid);
if (!data) if (!data)
@ -981,7 +983,7 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0))) if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
continue; continue;
if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))) if (difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
continue; continue;
MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters); MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);
@ -1007,6 +1009,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
uint32 count = 0; uint32 count = 0;
// 0 1 2 3 4 5 6
QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM gameobject_respawn LEFT JOIN instance ON instance = id"); QueryResult *result = CharacterDatabase.Query("SELECT guid, respawntime, map, instance, difficulty, resettime, encountersMask FROM gameobject_respawn LEFT JOIN instance ON instance = id");
if (!result) if (!result)
@ -1024,18 +1027,16 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint32 loguid = fields[0].GetUInt32(); uint32 loguid = fields[0].GetUInt32();
uint64 respawn_time = fields[1].GetUInt64(); uint64 respawn_time = fields[1].GetUInt64();
uint32 mapId = fields[2].GetUInt32(); uint32 mapId = fields[2].GetUInt32();
uint32 instanceId = fields[3].GetUInt32(); uint32 instanceId = fields[3].GetUInt32();
uint8 difficulty = fields[4].GetUInt8(); uint8 difficulty = fields[4].GetUInt8();
time_t resetTime = (time_t)fields[5].GetUInt64();
time_t resetTime = (time_t)fields[5].GetUInt64(); uint32 completedEncounters = fields[6].GetUInt32();
uint32 completedEncounters = fields[6].GetUInt32();
GameObjectData const* data = sObjectMgr.GetGOData(loguid); GameObjectData const* data = sObjectMgr.GetGOData(loguid);
if (!data) if (!data)
@ -1048,7 +1049,7 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0))) if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
continue; continue;
if(difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))) if (difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
continue; continue;
MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters); MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11809" #define REVISION_NR "11810"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__