void GameEventMgr::StopEvent(uint16 event_id, bool overwrite) { UnApplyEvent(event_id); if (overwrite) { mGameEvent[event_id].start = time(NULL) - mGameEvent[event_id].length * MINUTE; if (mGameEvent[event_id].end <= mGameEvent[event_id].start) { mGameEvent[event_id].end = mGameEvent[event_id].start + mGameEvent[event_id].length; } } #ifdef ENABLE_ELUNA if (!IsActiveEvent(event_id)) sEluna->OnGameEventStop(event_id); #endif }
uint32 GameEvent::Update() // return the next event delay in ms { uint32 nextEventDelay = max_ge_check_delay; // 1 day uint32 calcDelay; for (uint16 itr = 1; itr <= max_event_id; itr++) { //sLog.outErrorDb("Checking event %u",itr); if (CheckOneGameEvent(itr)) { //sLog.outDebug("GameEvent %u is active",itr->first); if (!IsActiveEvent(itr)) { AddActiveEvent(itr); ApplyNewEvent(itr); } } else { //sLog.outDebug("GameEvent %u is not active",itr->first); if (IsActiveEvent(itr)) { RemoveActiveEvent(itr); UnApplyEvent(itr); } else { if (!isSystemInit) { int16 event_nid = (-1) * (itr); // spawn all negative ones for this event GameEventSpawn(event_nid); } } } calcDelay = NextCheck(itr); if (calcDelay < nextEventDelay) nextEventDelay = calcDelay; } sLog.outBasic("Next game event check in %u secondes.", nextEventDelay + 1); return (nextEventDelay + 1) * 1000; // Add 1 seconde to be sure event has started/stopped at next call }