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 {