diff --git a/core/TimerSys.cpp b/core/TimerSys.cpp index 3f4b8065..7908ed7d 100644 --- a/core/TimerSys.cpp +++ b/core/TimerSys.cpp @@ -158,6 +158,12 @@ ITimer *TimerSystem::CreateTimer(ITimedEvent *pCallbacks, float fInterval, void TimerIter iter; float to_exec = GetSimulatedTime() + fInterval; + if ((flags & TIMER_FLAG_BEFORE_MAP_END) + && m_fnTimeLeft == NULL) + { + return NULL; + } + if (m_FreeTimers.empty()) { pTimer = new ITimer; @@ -253,8 +259,6 @@ void TimerSystem::FireTimerOnce(ITimer *pTimer, bool delayExec) void TimerSystem::KillTimer(ITimer *pTimer) { - TimerList *pList; - if (pTimer->m_KillMe) { return; @@ -278,7 +282,6 @@ void TimerSystem::KillTimer(ITimer *pTimer) m_SingleTimers.remove(pTimer); } - pList->remove(pTimer); m_FreeTimers.push(pTimer); } diff --git a/core/smn_timers.cpp b/core/smn_timers.cpp index f65580f2..0b7aae97 100644 --- a/core/smn_timers.cpp +++ b/core/smn_timers.cpp @@ -181,6 +181,13 @@ static cell_t smn_CreateTimer(IPluginContext *pCtx, const cell_t *params) pInfo = s_TimerNatives.CreateTimerInfo(); pTimer = g_Timers.CreateTimer(&s_TimerNatives, sp_ctof(params[1]), pInfo, flags); + + if (!pTimer) + { + s_TimerNatives.DeleteTimerInfo(pInfo); + return 0; + } + hndl = g_HandleSys.CreateHandle(g_TimerType, pInfo, pCtx->GetIdentity(), g_pCoreIdent, NULL); pInfo->UserData = params[3]; diff --git a/plugins/include/timers.inc b/plugins/include/timers.inc index 7b04792c..e11030de 100644 --- a/plugins/include/timers.inc +++ b/plugins/include/timers.inc @@ -84,6 +84,7 @@ funcenum Timer * @param value Handle or value to give to the timer function. * @param flags Flags to set (such as repeatability or auto-Handle closing). * @return Handle to the timer object. You do not need to call CloseHandle(). + * If the timer could not be created, INVALID_HANDLE will be returned. */ native Handle:CreateTimer(Float:interval, Timer:func, any:value=INVALID_HANDLE, flags=0);