Пример #1
0
void InstanceSaveManager::Update()
{
    time_t now = time(NULL), t;
    while (!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now)
    {
        InstResetEvent &event = m_resetTimeQueue.begin()->second;
        if (event.type == 0)
        {
            // for individual normal instances, max creature respawn + X hours
            _ResetInstance(event.mapid, event.instanceId);
            m_resetTimeQueue.erase(m_resetTimeQueue.begin());
        }
        else
        {
            // global reset/warning for a certain map
            time_t resetTime = GetResetTimeFor(event.mapid);
            _ResetOrWarnAll(event.mapid, event.type != 4, resetTime - now);
            if (event.type != 4)
            {
                // schedule the next warning/reset
                event.type++;
                static int tim[4] = {3600, 900, 300, 60};
                ScheduleReset(true, resetTime - tim[event.type-1], event);
            }
            m_resetTimeQueue.erase(m_resetTimeQueue.begin());
        }
    }
}
Пример #2
0
void InstanceSaveManager::Update()
{
    time_t now = time(NULL);
    time_t t;

    while (!m_resetTimeQueue.empty())
    {
        t = m_resetTimeQueue.begin()->first;
        if (t >= now)
            break;

        InstResetEvent &event = m_resetTimeQueue.begin()->second;
        if (event.type == 0)
        {
            // for individual normal instances, max creature respawn + X hours
            _ResetInstance(event.mapid, event.instanceId);
            m_resetTimeQueue.erase(m_resetTimeQueue.begin());
        }
        else
        {
            // global reset/warning for a certain map
            time_t resetTime = GetResetTimeFor(event.mapid, event.difficulty);
            _ResetOrWarnAll(event.mapid, event.difficulty, event.type != 4, resetTime);
            if (event.type != 4)
            {
                // schedule the next warning/reset
                ++event.type;
                ScheduleReset(true, resetTime - ResetTimeDelay[event.type-1], event);
            }
            m_resetTimeQueue.erase(m_resetTimeQueue.begin());
        }
    }
}
Пример #3
0
void InstanceSaveManager::Update()
{
    time_t now = time(NULL), t;
    while(!m_resetTimeQueue.empty() && (t = m_resetTimeQueue.begin()->first) < now)
    {
        InstResetEvent &event = m_resetTimeQueue.begin()->second;
        if(event.type == 0)
        {
            // for individual normal instances, max creature respawn + X hours
            _ResetInstance(event.mapid, event.instanceId);
        }
        else
        {
            // global reset/warning for a certain map
            time_t resetTime = GetResetTimeFor(event.mapid,event.difficulty);
            _ResetOrWarnAll(event.mapid, event.difficulty, event.type != RESET_EVENT_INFORM_LAST, uint32(resetTime - now));
            if(event.type != RESET_EVENT_INFORM_LAST)
            {
                // schedule the next warning/reset
                event.type = ResetEventType(event.type+1);
				ScheduleReset(true, resetTime - resetEventTypeDelay[event.type], event);
            }
			else
			{
				// re-schedule the next/new global reset/warning
				// calculate the next reset time
				MapDifficulty const* mapDiff = GetMapDifficultyData(event.mapid,event.difficulty);
				ASSERT(mapDiff);
				time_t next_reset = InstanceSaveManager::CalculateNextResetTime(mapDiff, resetTime);
				
				CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", uint64(next_reset), uint32(event.mapid), uint32(event.difficulty));
				
				SetResetTimeFor(event.mapid, event.difficulty, next_reset);
				ResetEventType type = RESET_EVENT_INFORM_1;
				for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1))
					if (next_reset - resetEventTypeDelay[type] > now)
						break;
				
				// add new scheduler event to the queue
				event.type = type;
				ScheduleReset(true, next_reset - resetEventTypeDelay[event.type], event);
			}
        }
		m_resetTimeQueue.erase(m_resetTimeQueue.begin());
    }
}
Пример #4
0
void InstanceSaveManager::Update()
{
    time_t now = time(NULL);
    time_t t, t2;

    while (!m_resetTimeQueue.empty())
    {
        t = m_resetTimeQueue.begin()->first;
        if (t >= now)
            break;

        // if m_resetTime has new resetTime, then write it to Queue, not delete the active instance.. 
        InstResetEvent &event = m_resetTimeQueue.begin()->second;
        time_t resetTime = GetResetTimeFor(event.mapid, event.difficulty);
        if (InstanceSave* save = GetInstanceSave(event.instanceId))
        {
            if (t2 = save->GetResetTime())
                if (t2 >= t)
                {
                    m_resetTimeQueue.erase(m_resetTimeQueue.begin());
                    m_resetTimeQueue.insert(std::pair<time_t, InstResetEvent>(t2, event));
                    break;
                }
        }
       
        if (event.type == 0)
        {
            // for individual normal instances, max creature respawn + X hours
            _ResetInstance(event.mapid, event.instanceId);
            m_resetTimeQueue.erase(m_resetTimeQueue.begin());
        }
        else
        {
            // global reset/warning for a certain map
            _ResetOrWarnAll(event.mapid, event.difficulty, event.type != 4, resetTime);
            if (event.type != 4)
            {
                // schedule the next warning/reset
                ++event.type;
                ScheduleReset(true, resetTime - ResetTimeDelay[event.type - 1], event);
            }
            m_resetTimeQueue.erase(m_resetTimeQueue.begin());
        }
    }
}