mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[10384] Fixed reset time calculation for some cases.
Most real fix suggested by Schmoozerd and Toinan67 and some my code style part coding ;)
This commit is contained in:
parent
0649b508e4
commit
920a36b3fd
5 changed files with 22 additions and 12 deletions
|
|
@ -1163,8 +1163,8 @@ struct MapDifficultyEntry
|
|||
uint32 Difficulty; // 2 (for arenas: arena slot)
|
||||
//char* areaTriggerText[16]; // 3-18 text showed when transfer to map failed (missing requirements)
|
||||
//uint32 textFlags; // 19
|
||||
uint32 resetTime; // 20
|
||||
uint32 maxPlayers; // 21
|
||||
uint32 resetTime; // 20, in secs, 0 if no fixed reset time
|
||||
uint32 maxPlayers; // 21, some heroic versions have 0 when expected same amount as in normal version
|
||||
//char* difficultyString; // 22
|
||||
};
|
||||
|
||||
|
|
@ -1860,7 +1860,7 @@ struct MapDifficulty
|
|||
MapDifficulty() : resetTime(0), maxPlayers(0) {}
|
||||
MapDifficulty(uint32 _resetTime, uint32 _maxPlayers) : resetTime(_resetTime), maxPlayers(_maxPlayers) {}
|
||||
|
||||
uint32 resetTime;
|
||||
uint32 resetTime; // in secs, 0 if no fixed reset time
|
||||
uint32 maxPlayers; // some heroic dungeons have 0 when expect same value as in normal dificulty case
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,19 @@ bool InstanceSave::UnloadIfEmpty()
|
|||
|
||||
//== InstanceResetScheduler functions ======================
|
||||
|
||||
uint32 InstanceResetScheduler::GetMaxResetTimFor(MapDifficulty const* mapDiff)
|
||||
{
|
||||
if (!mapDiff || !mapDiff->resetTime)
|
||||
return 0;
|
||||
|
||||
uint32 delay = uint32(mapDiff->resetTime / DAY * sWorld.getConfig(CONFIG_FLOAT_RATE_INSTANCE_RESET_TIME)) * DAY;
|
||||
|
||||
if (delay < DAY) // the reset_delay must be at least one day
|
||||
delay = DAY;
|
||||
|
||||
return delay;
|
||||
}
|
||||
|
||||
void InstanceResetScheduler::LoadResetTimes()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
|
|
@ -229,11 +242,7 @@ void InstanceResetScheduler::LoadResetTimes()
|
|||
if (!mapDiff->resetTime)
|
||||
continue;
|
||||
|
||||
// the reset_delay must be at least one day
|
||||
uint32 period = uint32(mapDiff->resetTime / DAY * sWorld.getConfig(CONFIG_FLOAT_RATE_INSTANCE_RESET_TIME)) * DAY;
|
||||
if (period < DAY)
|
||||
period = DAY;
|
||||
|
||||
uint32 period = GetMaxResetTimFor(mapDiff);
|
||||
time_t t = GetResetTimeFor(mapid,difficulty);
|
||||
if(!t)
|
||||
{
|
||||
|
|
@ -637,7 +646,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
|||
|
||||
// calculate the next reset time
|
||||
uint32 diff = sWorld.getConfig(CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR) * HOUR;
|
||||
uint32 period = mapDiff->resetTime * DAY;
|
||||
uint32 period = InstanceResetScheduler::GetMaxResetTimFor(mapDiff);
|
||||
time_t next_reset = ((now + timeLeft + MINUTE) / DAY * DAY) + period + diff;
|
||||
// update it in the DB
|
||||
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d' AND difficulty = '%d'", (uint64)next_reset, mapid, difficulty);
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ class InstanceResetScheduler
|
|||
return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
|
||||
}
|
||||
|
||||
static uint32 GetMaxResetTimFor(MapDifficulty const* mapDiff);
|
||||
|
||||
public: // modifiers
|
||||
void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -996,8 +996,7 @@ uint32 Map::GetMaxPlayers() const
|
|||
|
||||
uint32 Map::GetMaxResetDelay() const
|
||||
{
|
||||
MapDifficulty const* mapDiff = GetMapDifficulty();
|
||||
return mapDiff ? mapDiff->resetTime : 0;
|
||||
return InstanceResetScheduler::GetMaxResetTimFor(GetMapDifficulty());
|
||||
}
|
||||
|
||||
inline GridMap *Map::GetGrid(float x, float y)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10383"
|
||||
#define REVISION_NR "10384"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue