Switched tasks to forward system

This commit is contained in:
David Anderson 2004-08-29 17:11:08 +00:00
parent 54fb9fbfef
commit 53f8d12237
3 changed files with 18 additions and 31 deletions

View File

@ -350,7 +350,7 @@ void CLangMngr::CLang::MergeDefinitions(CQueue<sKeyDef*> &vec)
entry->SetKey(key); entry->SetKey(key);
entry->SetCache(false); entry->SetCache(false);
} else { } else {
AMXXLOG_Log("[AMXX] Language key %s[%s] defined twice", m_LMan->GetKey(key), m_LanguageName); //AMXXLOG_Log("[AMXX] Language key %s[%s] defined twice", m_LMan->GetKey(key), m_LanguageName);
} }
} }
delete vec.front(); delete vec.front();

View File

@ -61,14 +61,11 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
if (iParamsLen) if (iParamsLen)
{ {
// also add a cell to the back with the value 0
m_iParamLen = iParamsLen + 1; m_iParamLen = iParamsLen + 1;
m_pParams = new cell[m_iParamLen]; m_pParams = new cell[m_iParamLen];
memcpy(m_pParams, pParams, sizeof(cell)*iParamsLen); memcpy(m_pParams, pParams, sizeof(cell)*iParamsLen);
m_pParams[iParamsLen] = 0; m_pParams[iParamsLen] = 0;
} } else {
else
{
m_iParamLen = 0; m_iParamLen = 0;
m_pParams = NULL; m_pParams = NULL;
} }
@ -114,28 +111,12 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
if (execute) if (execute)
{ {
if (m_pPlugin->isExecutable(m_iFunc)) if (m_iParamLen) // call with parameters
{ {
int err; cell arr = prepareCellArray(m_pParams, m_iParamLen);
if (m_iParamLen) // call with parameters executeForwards(m_iFunc, arr, m_iId);
{ } else {
cell amx_addr, *phys_addr; executeForwards(m_iFunc, m_iId);
if (amx_Allot(m_pPlugin->getAMX(), m_iParamLen, &amx_addr, &phys_addr) != AMX_ERR_NONE)
AMXXLOG_Log("[AMXX] Failed to allocate AMX memory (task \"%d\") (plugin \"%s\")", m_iId, m_pPlugin->getName());
else
{
copy_amxmemory(phys_addr, m_pParams, m_iParamLen);
if ((err = amx_Exec(m_pPlugin->getAMX(), NULL, m_iFunc, 2, amx_addr, m_iId)) != AMX_ERR_NONE)
AMXXLOG_Log("[AMXX] Run time error %d on line %ld (task \"%d\") (plugin \"%s\")", err, m_pPlugin->getAMX()->curline, m_iId, m_pPlugin->getName());
amx_Release(m_pPlugin->getAMX(), amx_addr);
}
}
else
{
if ((err = amx_Exec(m_pPlugin->getAMX(), NULL, m_iFunc, 1, m_iId)) != AMX_ERR_NONE)
AMXXLOG_Log("[AMXX] Run time error %d on line %ld (task \"%d\") (plugin \"%s\")", err, m_pPlugin->getAMX()->curline, m_iId, m_pPlugin->getName());
}
} }
// set new exec time OR remove the task if needed // set new exec time OR remove the task if needed
@ -145,6 +126,8 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
} }
else else
{ {
unregisterSPForward(m_iFunc);
m_iFunc = 0;
m_bFree = true; m_bFree = true;
} }
} }

View File

@ -1676,7 +1676,14 @@ static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */
char* stemp = get_amxstring(amx,params[2],1, a ); char* stemp = get_amxstring(amx,params[2],1, a );
if (amx_FindPublic(amx, stemp , &iFunc) != AMX_ERR_NONE){ if (params[5])
{
iFunc = registerSPForwardByName(amx, stemp, FP_ARRAY, FP_CELL, FP_DONE);
} else {
iFunc = registerSPForwardByName(amx, stemp, FP_CELL, FP_DONE);
}
if (!iFunc)
{
AMXXLOG_Log("[AMXX] Function is not present (function \"%s\") (plugin \"%s\")",stemp,plugin->getName() ); AMXXLOG_Log("[AMXX] Function is not present (function \"%s\") (plugin \"%s\")",stemp,plugin->getName() );
amx_RaiseError(amx,AMX_ERR_NATIVE); amx_RaiseError(amx,AMX_ERR_NATIVE);
return 0; return 0;
@ -1689,10 +1696,7 @@ static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */
char* temp = get_amxstring(amx,params[6],0,a); char* temp = get_amxstring(amx,params[6],0,a);
g_tasksMngr.registerTask( plugin , g_tasksMngr.registerTask( plugin , iFunc , UTIL_ReadFlags(temp), params[3], base , params[5] , get_amxaddr(amx,params[4]) , params[7] );
iFunc , UTIL_ReadFlags(temp), params[3], base ,
params[5] ,
get_amxaddr(amx,params[4]) , params[7] );
return 1; return 1;
} }