added amb622, TIMER_FLAG_NO_MAPCHANGE

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401114
This commit is contained in:
David Anderson 2007-07-14 01:55:15 +00:00
parent 91a1e2faaa
commit c33c27391f
3 changed files with 24 additions and 5 deletions

View File

@ -207,6 +207,7 @@ void TimerSystem::KillTimer(ITimer *pTimer)
m_FreeTimers.push(pTimer);
}
CStack<ITimer *> s_tokill;
void TimerSystem::MapChange()
{
ITimer *pTimer;
@ -215,14 +216,30 @@ void TimerSystem::MapChange()
for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++)
{
pTimer = (*iter);
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);
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();
}

View File

@ -21,6 +21,7 @@
#include <datapack>
#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 */
/**

View File

@ -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
{