added amb622, TIMER_FLAG_NO_MAPCHANGE
authorDavid Anderson <dvander@alliedmods.net>
Sat Jul 14 01:55:15 2007 +0000 (2007-07-14)
changeset 1108fafe809b16ca
parent 1107 3789127b580e
child 1109 5c9901734aef
added amb622, TIMER_FLAG_NO_MAPCHANGE
core/TimerSys.cpp
plugins/include/timers.inc
public/ITimerSystem.h
     1.1 --- a/core/TimerSys.cpp	Sat Jul 14 01:46:28 2007 +0000
     1.2 +++ b/core/TimerSys.cpp	Sat Jul 14 01:55:15 2007 +0000
     1.3 @@ -207,6 +207,7 @@
     1.4  	m_FreeTimers.push(pTimer);
     1.5  }
     1.6  
     1.7 +CStack<ITimer *> s_tokill;
     1.8  void TimerSystem::MapChange()
     1.9  {
    1.10  	ITimer *pTimer;
    1.11 @@ -215,13 +216,29 @@
    1.12  	for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++)
    1.13  	{
    1.14  		pTimer = (*iter);
    1.15 -		pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime();
    1.16 +		if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE)
    1.17 +		{
    1.18 +			s_tokill.push(pTimer);
    1.19 +		} else {
    1.20 +			pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime();
    1.21 +		}
    1.22  	}
    1.23  
    1.24  	for (iter=m_LoopTimers.begin(); iter!=m_LoopTimers.end(); iter++)
    1.25  	{
    1.26  		pTimer = (*iter);
    1.27 -		pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime();
    1.28 +		if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE)
    1.29 +		{
    1.30 +			s_tokill.push(pTimer);
    1.31 +		} else {
    1.32 +			pTimer->m_ToExec = pTimer->m_ToExec - m_LastExecTime + GetSimulatedTime();
    1.33 +		}
    1.34 +	}
    1.35 +
    1.36 +	while (!s_tokill.empty())
    1.37 +	{
    1.38 +		KillTimer(s_tokill.front());
    1.39 +		s_tokill.pop();
    1.40  	}
    1.41  
    1.42  	m_LastExecTime = GetSimulatedTime();
     2.1 --- a/plugins/include/timers.inc	Sat Jul 14 01:46:28 2007 +0000
     2.2 +++ b/plugins/include/timers.inc	Sat Jul 14 01:55:15 2007 +0000
     2.3 @@ -20,8 +20,9 @@
     2.4  
     2.5  #include <datapack>
     2.6  
     2.7 -#define TIMER_REPEAT		(1<<0)		/**< Timer will repeat until it returns Plugin_Stop */
     2.8 -#define TIMER_HNDL_CLOSE	(1<<9)		/**< Timer will automatically call CloseHandle() on its value when finished */
     2.9 +#define TIMER_REPEAT			(1<<0)		/**< Timer will repeat until it returns Plugin_Stop */
    2.10 +#define TIMER_FLAG_NO_MAPCHANGE	(1<<1)		/**< Timer will not carry over mapchanges */
    2.11 +#define TIMER_HNDL_CLOSE		(1<<9)		/**< Timer will automatically call CloseHandle() on its value when finished */
    2.12  
    2.13  /**
    2.14   * Any of the following prototypes will work for a timed function.
     3.1 --- a/public/ITimerSystem.h	Sat Jul 14 01:46:28 2007 +0000
     3.2 +++ b/public/ITimerSystem.h	Sat Jul 14 01:55:15 2007 +0000
     3.3 @@ -59,7 +59,8 @@
     3.4  		virtual void OnTimerEnd(ITimer *pTimer, void *pData) =0;
     3.5  	};
     3.6  
     3.7 -	#define TIMER_FLAG_REPEAT		(1<<0)
     3.8 +	#define TIMER_FLAG_REPEAT			(1<<0)		/**< Timer will repeat until stopped */
     3.9 +	#define TIMER_FLAG_NO_MAPCHANGE		(1<<1)		/**< Timer will not carry over mapchanges */
    3.10  
    3.11  	class ITimerSystem : public SMInterface
    3.12  	{