diff options
author | Trazom62 <none@none> | 2010-02-04 22:03:09 +0100 |
---|---|---|
committer | Trazom62 <none@none> | 2010-02-04 22:03:09 +0100 |
commit | 646fc8276a9341c9266a31a060bec4a538f348ed (patch) | |
tree | dcfd5591927e8cfd5bdcb47b21d4997e2fd500a2 /src | |
parent | b0b261585f4c410736548cd536642cb104cb7023 (diff) |
Fix ResetInstance.
Fixes issue #70.
Reset Instance was removed during the merge to 3.2.2, then fixed again, then backed-out due to bug. This latter is now fixed.
Thanks to the original authors (already credited in old rev).
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/InstanceSaveMgr.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index 9e8cd3eb694..b94dbe38377 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -501,7 +501,9 @@ void InstanceSaveManager::LoadResetTimes() continue; // the reset_delay must be at least one day - uint32 period = (mapDiff->resetTime / DAY * sWorld.getRate(RATE_INSTANCE_RESET_TIME)) * DAY; + uint32 period = ((mapDiff->resetTime * sWorld.getRate(RATE_INSTANCE_RESET_TIME))/DAY) * DAY; + if (period < DAY) + period = DAY; time_t t = GetResetTimeFor(mapid,difficulty); if(!t) @@ -529,6 +531,8 @@ void InstanceSaveManager::LoadResetTimes() if(t - tim[type-1] > now) break; + ScheduleReset(true, t - tim[type-1], InstResetEvent(type, mapid, difficulty, -1)); + for(ResetTimeMapDiffInstances::const_iterator in_itr = mapDiffResetInstances.lower_bound(map_diff_pair); in_itr != mapDiffResetInstances.upper_bound(map_diff_pair); ++in_itr) { @@ -662,8 +666,16 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b // calculate the next reset time uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR; - uint32 period = mapDiff->resetTime * DAY; + + uint32 period = ((mapDiff->resetTime * sWorld.getRate(RATE_INSTANCE_RESET_TIME))/DAY) * DAY; + if (period < DAY) + period = DAY; + uint64 next_reset = ((now + timeLeft + MINUTE) / DAY * DAY) + period + diff; + + SetResetTimeFor(mapid, difficulty, next_reset); + ScheduleReset(true, time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty, -1)); + // update it in the DB CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d' AND difficulty = '%d'", next_reset, mapid, difficulty); } |