MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / CreateTimer

Method CreateTimer

core/TimerSys.cpp:297–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297ITimer *TimerSystem::CreateTimer(ITimedEvent *pCallbacks, float fInterval, void *pData, int flags)
298{
299 ITimer *pTimer;
300 TimerIter iter;
301 float to_exec = GetSimulatedTime() + fInterval;
302
303 if (m_FreeTimers.empty())
304 {
305 pTimer = new ITimer;
306 } else {
307 pTimer = m_FreeTimers.front();
308 m_FreeTimers.pop();
309 }
310
311 pTimer->Initialize(pCallbacks, fInterval, to_exec, pData, flags);
312
313 if (flags & TIMER_FLAG_REPEAT)
314 {
315 m_LoopTimers.push_back(pTimer);
316 goto return_timer;
317 }
318
319 if (m_SingleTimers.size() >= 1)
320 {
321 iter = --m_SingleTimers.end();
322 if ((*iter)->m_ToExec <= to_exec)
323 {
324 goto normal_insert_end;
325 }
326 }
327
328 for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++)
329 {
330 if ((*iter)->m_ToExec >= to_exec)
331 {
332 m_SingleTimers.insert(iter, pTimer);
333 goto return_timer;
334 }
335 }
336
337normal_insert_end:
338 m_SingleTimers.push_back(pTimer);
339
340return_timer:
341 return pTimer;
342}
343
344void TimerSystem::FireTimerOnce(ITimer *pTimer, bool delayExec)
345{

Callers 5

DoBasicAdminChecksMethod · 0.80
StartVotingMethod · 0.80
smn_CreateTimerFunction · 0.80
OnClientVoiceMethod · 0.80
ProcessVoiceDataMethod · 0.80

Calls 9

GetSimulatedTimeFunction · 0.85
emptyMethod · 0.80
popMethod · 0.80
push_backMethod · 0.80
InitializeMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected