From c33c27391f1412cae8820a343f0e70fec268e3b3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 14 Jul 2007 01:55:15 +0000 Subject: [PATCH] added amb622, TIMER_FLAG_NO_MAPCHANGE --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401114 --- core/TimerSys.cpp | 21 +++++++++++++++++++-- plugins/include/timers.inc | 5 +++-- public/ITimerSystem.h | 3 ++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/core/TimerSys.cpp b/core/TimerSys.cpp index 667ac3b9..32e6d206 100644 --- a/core/TimerSys.cpp +++ b/core/TimerSys.cpp @@ -207,6 +207,7 @@ void TimerSystem::KillTimer(ITimer *pTimer) m_FreeTimers.push(pTimer); } +CStack s_tokill; void TimerSystem::MapChange() { ITimer *pTimer; @@ -215,13 +216,29 @@ void TimerSystem::MapChange() for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++) { pTimer = (*iter); - pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime(); + if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE) + { + s_tokill.push(pTimer); + } else { + pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime(); + } } for (iter=m_LoopTimers.begin(); iter!=m_LoopTimers.end(); iter++) { pTimer = (*iter); - pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime(); + if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE) + { + s_tokill.push(pTimer); + } else { + pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime(); + } + } + + while (!s_tokill.empty()) + { + KillTimer(s_tokill.front()); + s_tokill.pop(); } m_LastExecTime = GetSimulatedTime(); diff --git a/plugins/include/timers.inc b/plugins/include/timers.inc index f639bcf9..409341b2 100644 --- a/plugins/include/timers.inc +++ b/plugins/include/timers.inc @@ -20,8 +20,9 @@ #include -#define TIMER_REPEAT (1<<0) /**< Timer will repeat until it returns Plugin_Stop */ -#define TIMER_HNDL_CLOSE (1<<9) /**< Timer will automatically call CloseHandle() on its value when finished */ +#define TIMER_REPEAT (1<<0) /**< Timer will repeat until it returns Plugin_Stop */ +#define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */ +#define TIMER_HNDL_CLOSE (1<<9) /**< Timer will automatically call CloseHandle() on its value when finished */ /** * Any of the following prototypes will work for a timed function. diff --git a/public/ITimerSystem.h b/public/ITimerSystem.h index 9a8fb89c..a9d9f407 100644 --- a/public/ITimerSystem.h +++ b/public/ITimerSystem.h @@ -59,7 +59,8 @@ namespace SourceMod virtual void OnTimerEnd(ITimer *pTimer, void *pData) =0; }; - #define TIMER_FLAG_REPEAT (1<<0) + #define TIMER_FLAG_REPEAT (1<<0) /**< Timer will repeat until stopped */ + #define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */ class ITimerSystem : public SMInterface {