added a case where CreateTimer() can return INVALID_HANDLE
fixed two initialization bugs in TimerSys --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401415
This commit is contained in:
parent
641041b906
commit
dd824d2056
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user