mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 14:37:29 +08:00
[bot] Implement/match CScriptTimers::Process(...)
This commit is contained in:
parent
4c3bfe503f
commit
2d911feb2a
@ -1,6 +1,8 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
extern CNetGame* pNetGame;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
CScriptTimers::CScriptTimers()
|
||||
@ -106,3 +108,57 @@ void CScriptTimers::Kill(DWORD dwTimerId)
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void CScriptTimers::Process(int iElapsedTime)
|
||||
{
|
||||
DwordTimerMap::iterator itor;
|
||||
CGameMode *pGameMode;
|
||||
for (itor = m_Timers.begin(); itor != m_Timers.end(); itor++)
|
||||
{
|
||||
itor->second->iRemainingTime -= iElapsedTime;
|
||||
if (itor->second->iRemainingTime <= 0)
|
||||
{
|
||||
DwordTimerMap::iterator itor_tmp = ++itor; itor--;
|
||||
if (!itor->second->bKilled)
|
||||
{
|
||||
pGameMode = pNetGame->GetBotMode();
|
||||
if (pGameMode)
|
||||
{
|
||||
int idx;
|
||||
AMX* amx = itor->second->pAMX;
|
||||
if (amx && !amx_FindPublic(amx, itor->second->szScriptFunc, &idx))
|
||||
{
|
||||
cell ret;
|
||||
int count = itor->second->iParamCount;
|
||||
int i = 0;
|
||||
if (count > 0)
|
||||
{
|
||||
cell* pars = (cell*)itor->second->cellParams;
|
||||
while (i < count)
|
||||
{
|
||||
amx_Push(amx, pars[i]);
|
||||
i++; // Go forwards to maintain push order
|
||||
}
|
||||
}
|
||||
amx_Exec(amx, &ret, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itor->second->bRepeating)
|
||||
{
|
||||
itor->second->iRemainingTime = itor->second->iTotalTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Release parameter memory
|
||||
FreeMem(itor->second);
|
||||
Delete(itor->first);
|
||||
}
|
||||
itor = itor_tmp;
|
||||
}
|
||||
if (itor == m_Timers.end()) break;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// EOF
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
DWORD New(char* szScriptFunc, int iInterval, BOOL bRepeating, AMX* pAMX);
|
||||
void Delete(DWORD dwTimerId);
|
||||
void Kill(DWORD dwTimerId);
|
||||
void Process(int iElapsedTime);
|
||||
void FreeMem(ScriptTimer_s* Timer);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user