mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[10196] Use enum for instance reset event types, some related cleanup code.
This commit is contained in:
parent
a27ecef96d
commit
f72b8e60a5
4 changed files with 30 additions and 19 deletions
|
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
INSTANTIATE_SINGLETON_1( InstanceSaveManager );
|
INSTANTIATE_SINGLETON_1( InstanceSaveManager );
|
||||||
|
|
||||||
|
static uint32 resetEventTypeDelay[MAX_RESET_EVENT_TYPE] = { 0, 3600, 900, 300, 60 };
|
||||||
|
|
||||||
//== InstanceSave functions ================================
|
//== InstanceSave functions ================================
|
||||||
|
|
||||||
InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset)
|
InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset)
|
||||||
|
|
@ -182,7 +184,7 @@ void InstanceResetScheduler::LoadResetTimes()
|
||||||
// schedule the reset times
|
// schedule the reset times
|
||||||
for(InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr)
|
for(InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr)
|
||||||
if(itr->second.second > now)
|
if(itr->second.second > now)
|
||||||
ScheduleReset(true, itr->second.second, InstanceResetEvent(0, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first));
|
ScheduleReset(true, itr->second.second, InstanceResetEvent(RESET_EVENT_DENGEON, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first));
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the global respawn times for raid/heroic instances
|
// load the global respawn times for raid/heroic instances
|
||||||
|
|
@ -255,16 +257,15 @@ void InstanceResetScheduler::LoadResetTimes()
|
||||||
SetResetTimeFor(mapid,difficulty,t);
|
SetResetTimeFor(mapid,difficulty,t);
|
||||||
|
|
||||||
// schedule the global reset/warning
|
// schedule the global reset/warning
|
||||||
uint8 type = 1;
|
ResetEventType type = RESET_EVENT_INFORM_1;
|
||||||
static int tim[4] = {3600, 900, 300, 60};
|
for(; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1))
|
||||||
for(; type < 4; type++)
|
if(t - resetEventTypeDelay[type] > now)
|
||||||
if(t - tim[type-1] > now)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for(ResetTimeMapDiffInstances::const_iterator in_itr = mapDiffResetInstances.lower_bound(map_diff_pair);
|
for(ResetTimeMapDiffInstances::const_iterator in_itr = mapDiffResetInstances.lower_bound(map_diff_pair);
|
||||||
in_itr != mapDiffResetInstances.upper_bound(map_diff_pair); ++in_itr)
|
in_itr != mapDiffResetInstances.upper_bound(map_diff_pair); ++in_itr)
|
||||||
{
|
{
|
||||||
ScheduleReset(true, t - tim[type-1], InstanceResetEvent(type, mapid, difficulty, in_itr->second));
|
ScheduleReset(true, t - resetEventTypeDelay[type], InstanceResetEvent(type, mapid, difficulty, in_itr->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -321,13 +322,12 @@ void InstanceResetScheduler::Update()
|
||||||
{
|
{
|
||||||
// global reset/warning for a certain map
|
// global reset/warning for a certain map
|
||||||
time_t resetTime = GetResetTimeFor(event.mapid,event.difficulty);
|
time_t resetTime = GetResetTimeFor(event.mapid,event.difficulty);
|
||||||
m_InstanceSaves._ResetOrWarnAll(event.mapid, event.difficulty, event.type != 4, uint32(resetTime - now));
|
m_InstanceSaves._ResetOrWarnAll(event.mapid, event.difficulty, event.type != RESET_EVENT_INFORM_LAST, uint32(resetTime - now));
|
||||||
if(event.type != 4)
|
if(event.type != RESET_EVENT_INFORM_LAST)
|
||||||
{
|
{
|
||||||
// schedule the next warning/reset
|
// schedule the next warning/reset
|
||||||
event.type++;
|
event.type = ResetEventType(event.type+1);
|
||||||
static int tim[4] = {3600, 900, 300, 60};
|
ScheduleReset(true, resetTime - resetEventTypeDelay[event.type], event);
|
||||||
ScheduleReset(true, resetTime - tim[event.type-1], event);
|
|
||||||
}
|
}
|
||||||
m_resetTimeQueue.erase(m_resetTimeQueue.begin());
|
m_resetTimeQueue.erase(m_resetTimeQueue.begin());
|
||||||
}
|
}
|
||||||
|
|
@ -387,7 +387,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance
|
||||||
{
|
{
|
||||||
resetTime = time(NULL) + 2 * HOUR;
|
resetTime = time(NULL) + 2 * HOUR;
|
||||||
// normally this will be removed soon after in InstanceMap::Add, prevent error
|
// normally this will be removed soon after in InstanceMap::Add, prevent error
|
||||||
m_Scheduler.ScheduleReset(true, resetTime, InstanceResetEvent(0, mapId, difficulty, instanceId));
|
m_Scheduler.ScheduleReset(true, resetTime, InstanceResetEvent(RESET_EVENT_DENGEON, mapId, difficulty, instanceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,17 +120,28 @@ class InstanceSave
|
||||||
bool m_usedByMap; // true when instance map loaded
|
bool m_usedByMap; // true when instance map loaded
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ResetEventType
|
||||||
|
{
|
||||||
|
RESET_EVENT_DENGEON = 0, // no fixed reset time
|
||||||
|
RESET_EVENT_INFORM_1 = 1, // raid/heroic warnings
|
||||||
|
RESET_EVENT_INFORM_2 = 2,
|
||||||
|
RESET_EVENT_INFORM_3 = 3,
|
||||||
|
RESET_EVENT_INFORM_LAST = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAX_RESET_EVENT_TYPE 5
|
||||||
|
|
||||||
/* resetTime is a global propery of each (raid/heroic) map
|
/* resetTime is a global propery of each (raid/heroic) map
|
||||||
all instances of that map reset at the same time */
|
all instances of that map reset at the same time */
|
||||||
struct InstanceResetEvent
|
struct InstanceResetEvent
|
||||||
{
|
{
|
||||||
uint8 type;
|
ResetEventType type :8;
|
||||||
Difficulty difficulty :8;
|
Difficulty difficulty :8;
|
||||||
uint16 mapid;
|
uint16 mapid;
|
||||||
uint16 instanceId;
|
uint32 instanceId;
|
||||||
|
|
||||||
InstanceResetEvent() : type(0), difficulty(DUNGEON_DIFFICULTY_NORMAL), mapid(0), instanceId(0) {}
|
InstanceResetEvent() : type(RESET_EVENT_DENGEON), difficulty(DUNGEON_DIFFICULTY_NORMAL), mapid(0), instanceId(0) {}
|
||||||
InstanceResetEvent(uint8 t, uint32 _mapid, Difficulty d, uint16 _instanceid)
|
InstanceResetEvent(ResetEventType t, uint32 _mapid, Difficulty d, uint32 _instanceid)
|
||||||
: type(t), difficulty(d), mapid(_mapid), instanceId(_instanceid) {}
|
: type(t), difficulty(d), mapid(_mapid), instanceId(_instanceid) {}
|
||||||
bool operator == (const InstanceResetEvent& e) { return e.instanceId == instanceId; }
|
bool operator == (const InstanceResetEvent& e) { return e.instanceId == instanceId; }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1968,7 +1968,7 @@ void InstanceMap::SetResetSchedule(bool on)
|
||||||
// the reset time is only scheduled when there are no payers inside
|
// the reset time is only scheduled when there are no payers inside
|
||||||
// it is assumed that the reset time will rarely (if ever) change while the reset is scheduled
|
// it is assumed that the reset time will rarely (if ever) change while the reset is scheduled
|
||||||
if(IsDungeon() && !HavePlayers() && !IsRaidOrHeroicDungeon())
|
if(IsDungeon() && !HavePlayers() && !IsRaidOrHeroicDungeon())
|
||||||
sInstanceSaveMgr.GetScheduler().ScheduleReset(on, GetInstanceSave()->GetResetTime(), InstanceResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId()));
|
sInstanceSaveMgr.GetScheduler().ScheduleReset(on, GetInstanceSave()->GetResetTime(), InstanceResetEvent(RESET_EVENT_DENGEON, GetId(), Difficulty(GetSpawnMode()), GetInstanceId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ******* Battleground Instance Maps ******* */
|
/* ******* Battleground Instance Maps ******* */
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10195"
|
#define REVISION_NR "10196"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue