[server] Implement/match CScriptTimers::DeleteForMode(...)

This commit is contained in:
RD42 2024-06-24 23:21:47 +08:00
parent 5675f1555b
commit 52ee926fdd
2 changed files with 22 additions and 0 deletions

View File

@ -34,6 +34,27 @@ void CScriptTimers::FreeMem(ScriptTimer_s* Timer)
//----------------------------------------------------------------------------------
void CScriptTimers::DeleteForMode(AMX* pEndedAMX)
{
bool bRestart = false;
DwordTimerMap::iterator itor;
for (itor = m_Timers.begin(); itor != m_Timers.end(); bRestart?(itor=m_Timers.begin()):(itor++))
{
bRestart = false;
if (itor->second->pAMX == pEndedAMX)
{
FreeMem(itor->second);
SAFE_DELETE(itor->second);
m_Timers.erase(itor);
// Can't continue iteration if a node is deleted, start iteration from start again.
bRestart = true;
}
}
}
//----------------------------------------------------------------------------------
DWORD CScriptTimers::New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX)
{
m_dwTimerCount++;

View File

@ -27,6 +27,7 @@ public:
CScriptTimers();
~CScriptTimers();
void DeleteForMode(AMX* pEndedAMX);
DWORD New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX);
DWORD NewEx(char* szScriptFunc, int iInterval, BOOL bRepeating, cell *params, AMX* pAMX);
void Kill(DWORD dwTimerId);