int CScheduler::Check(bool forcecheck){ if (!thePrefs.IsSchedulerEnabled() || theApp.scheduler->GetCount()==0 || !theApp.emuledlg->IsRunning()) return -1; Schedule_Struct* schedule; struct tm tmTemp; CTime tNow = CTime(safe_mktime(CTime::GetCurrentTime().GetLocalTm(&tmTemp))); if (!forcecheck && tNow.GetMinute()==m_iLastCheckedMinute) return -1; m_iLastCheckedMinute=tNow.GetMinute(); theApp.scheduler->RestoreOriginals(); for (uint8 si=0;si<theApp.scheduler->GetCount();si++) { schedule=theApp.scheduler->GetSchedule(si); if (schedule->actions[0]==0 || !schedule->enabled) continue; // check day of week if (schedule->day!=DAY_DAYLY) { int dow=tNow.GetDayOfWeek(); switch (schedule->day) { case DAY_MO : if (dow!=2) continue; break; case DAY_DI : if (dow!=3) continue; break; case DAY_MI : if (dow!=4) continue; break; case DAY_DO : if (dow!=5) continue; break; case DAY_FR : if (dow!=6) continue; break; case DAY_SA : if (dow!=7) continue; break; case DAY_SO : if (dow!=1) continue; break; case DAY_MO_FR : if (dow==7 || dow==1 ) continue; break; case DAY_MO_SA : if (dow==1) continue; break; case DAY_SA_SO : if (dow>=2 && dow<=6) continue; } } //check time UINT h1,h2,m1,m2; CTime t1=CTime(schedule->time); CTime t2=CTime(schedule->time2); h1=t1.GetHour(); h2=t2.GetHour(); m1=t1.GetMinute(); m2=t2.GetMinute(); int it1,it2, itn; it1=h1*60 + m1; it2=h2*60 + m2; itn=tNow.GetHour()*60 + tNow.GetMinute(); if (it1<=it2) { // normal timespan if ( !(itn>=it1 && itn<it2) ) continue; } else { // reversed timespan (23:30 to 5:10) now 10 if ( !(itn>=it1 || itn<it2)) continue; } // ok, lets do the actions of this schedule ActivateSchedule(si,schedule->time2==0); } return -1; }
void OnTimer( WORD wTimerID ) { if( wTimerID == TIMER_ID_DEFAULT ) { g_GameTimer.Compute(); #ifdef __EVE_NEWYEAR static BOOL s_bCountdown = FALSE; CTime tmCur = CTime::GetCurrentTime(); if( ::GetLanguage() == LANG_GER || ::GetLanguage() == LANG_FRE ) { if( !s_bCountdown && tmCur > CTime( 2009, 12, 31, 22, 58, 59 ) && tmCur < CTime( 2009, 12, 31, 23, 0, 0 ) ) { s_bCountdown = TRUE; g_DPCacheSrvr.SendHdr( PACKETTYPE_NEWYEAR, DPID_ALLPLAYERS, DPID_ALLPLAYERS ); } if( tmCur > CTime( 2009, 12, 31, 23, 0, 0 ) ) s_bCountdown = FALSE; } else { if( !s_bCountdown && tmCur > CTime( 2009, 12, 31, 23, 58, 59 ) && tmCur < CTime( 2010, 1, 1, 0, 0, 0 ) ) { s_bCountdown = TRUE; g_DPCacheSrvr.SendHdr( PACKETTYPE_NEWYEAR, DPID_ALLPLAYERS, DPID_ALLPLAYERS ); } if( tmCur > CTime( 2010, 1, 1, 0, 0, 0 ) ) s_bCountdown = FALSE; } #endif // __EVE_NEWYEAR return; } #if !defined(__INTERNALSERVER) if( wTimerID == TIMER_ID_WANTED ) // 현상금 처리 { g_dpCoreSrvr.SendCWWantedList(); // 현상금 리스트를 보낸다. return; } #endif // __INTERNALSERVER #ifdef __EVENT0913 if( wTimerID == TIMER_ID_EVENT0913 ) { CTime tmCurr = CTime::GetCurrentTime(); BOOL bEventTime = ( tmCurr.GetHour() >= 17 && tmCurr.GetHour() < 18 ) || ( tmCurr.GetHour() >= 22 && tmCurr.GetHour() < 23 ); if( bEventTime && !s_bEvent0913 ) // 이벤트 시간 - 이벤트 설정되어 있지 않으면, { g_dpCoreSrvr.SendEvent0913( s_bEvent0913 = TRUE ); } else if( !bEventTime && s_bEvent0913 ) // 이벤트 시간이 아닌데 이벤트 설정되어 있으면, { g_dpCoreSrvr.SendEvent0913( s_bEvent0913 = FALSE ); } } #endif // __EVENT0913 #ifdef __EVENT1206 if( wTimerID == TIMER_ID_EVENT1206 ) { CTime tmCurr = CTime::GetCurrentTime(); BOOL bEventTime; if( s_bTest ) { bEventTime = ( tmCurr.GetHour() % 2 == 0 ); // even } else { bEventTime = ( tmCurr >= CTime( 2005, 12, 10, 19, 0, 0 ) && tmCurr < CTime( 2005, 12, 10, 22, 0, 0 ) ) || ( tmCurr >= CTime( 2005, 12, 11, 19, 0, 0 ) && tmCurr < CTime( 2005, 12, 11, 22, 0, 0 ) ); } if( bEventTime && !s_bEvent1206 ) // 이벤트 시간 - 이벤트 설정되어 있지 않으면, { g_dpCoreSrvr.SendEvent1206( s_bEvent1206 = TRUE ); } else if( !bEventTime && s_bEvent1206 ) // 이벤트 시간이 아닌데 이벤트 설정되어 있으면, { g_dpCoreSrvr.SendEvent1206( s_bEvent1206 = FALSE ); } } #endif // __EVENT1206 if( wTimerID == TIMER_ID_EVENT ) { BOOL f = FALSE; CTime tmCurr = CTime::GetCurrentTime(); BOOL bXmas; if( s_bTest ) { bXmas = tmCurr < CTime( 2005, 12, 26, 10, 0, 0 ); } else { bXmas = ( tmCurr >= CTime( 2005, 12, 23, 0, 0, 0 ) && tmCurr < CTime( 2005, 12, 27, 9, 0, 0 ) ); } BOOL bNewYear; if( s_bTest ) { bNewYear = tmCurr < CTime( 2006, 1, 31, 10, 0, 0 ); } else { bNewYear = ( tmCurr >= CTime( 2006, 1, 26, 0, 0, 0 ) && tmCurr < CTime( 2006, 1, 31, 10, 0, 0 ) ); } BOOL bValentinesDay; if( s_bTest ) { bValentinesDay = tmCurr < CTime( 2006, 2, 15, 13, 0, 0 ); } else { bValentinesDay = ( tmCurr >= CTime( 2006, 2, 14, 0, 0, 0 ) && tmCurr < CTime( 2006, 2, 15, 13, 0, 0 ) ); } if( bXmas && !( s_dwEvent & EVE_FLAG1219 ) ) { s_dwEvent |= EVE_FLAG1219; f = TRUE; } else if( !bXmas && ( s_dwEvent & EVE_FLAG1219 ) ) { s_dwEvent &= ~EVE_FLAG1219; f = TRUE; } if( bNewYear && !( s_dwEvent & EVE_FLAG0127 ) ) { s_dwEvent |= EVE_FLAG0127; f = TRUE; } else if( !bNewYear && ( s_dwEvent & EVE_FLAG0127 ) ) { s_dwEvent &= ~EVE_FLAG0127; f = TRUE; } if( bValentinesDay && !( s_dwEvent & EVE_FLAG0214 ) ) { s_dwEvent |= EVE_FLAG0214; f = TRUE; } else if( !bValentinesDay && ( s_dwEvent & EVE_FLAG0214 ) ) { s_dwEvent &= ~EVE_FLAG0214; f = TRUE; } if( f ) { g_dpCoreSrvr.SendEvent( s_dwEvent ); } } }