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

This commit is contained in:
RD42 2024-08-29 23:22:54 +08:00
parent 02b4a7b509
commit c1d02b9ab0
2 changed files with 24 additions and 0 deletions

View File

@ -34,6 +34,29 @@ void CScriptTimers::FreeMem(ScriptTimer_s* Timer)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Kills only the timers found in one mode
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) DWORD CScriptTimers::New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX)
{ {
m_dwTimerCount++; m_dwTimerCount++;

View File

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