mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Switched tasks to forward system
This commit is contained in:
parent
54fb9fbfef
commit
53f8d12237
@ -350,7 +350,7 @@ void CLangMngr::CLang::MergeDefinitions(CQueue<sKeyDef*> &vec)
|
||||
entry->SetKey(key);
|
||||
entry->SetCache(false);
|
||||
} 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();
|
||||
|
@ -61,14 +61,11 @@ void CTaskMngr::CTask::set(CPluginMngr::CPlugin *pPlugin, int iFunc, int iFlags,
|
||||
|
||||
if (iParamsLen)
|
||||
{
|
||||
// also add a cell to the back with the value 0
|
||||
m_iParamLen = iParamsLen + 1;
|
||||
m_pParams = new cell[m_iParamLen];
|
||||
memcpy(m_pParams, pParams, sizeof(cell)*iParamsLen);
|
||||
m_pParams[iParamsLen] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
m_iParamLen = 0;
|
||||
m_pParams = NULL;
|
||||
}
|
||||
@ -114,28 +111,12 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
|
||||
|
||||
if (execute)
|
||||
{
|
||||
if (m_pPlugin->isExecutable(m_iFunc))
|
||||
{
|
||||
int err;
|
||||
if (m_iParamLen) // call with parameters
|
||||
{
|
||||
cell amx_addr, *phys_addr;
|
||||
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());
|
||||
}
|
||||
cell arr = prepareCellArray(m_pParams, m_iParamLen);
|
||||
executeForwards(m_iFunc, arr, m_iId);
|
||||
} else {
|
||||
executeForwards(m_iFunc, m_iId);
|
||||
}
|
||||
|
||||
// set new exec time OR remove the task if needed
|
||||
@ -145,6 +126,8 @@ void CTaskMngr::CTask::executeIfRequired(float fCurrentTime, float fTimeLimit, f
|
||||
}
|
||||
else
|
||||
{
|
||||
unregisterSPForward(m_iFunc);
|
||||
m_iFunc = 0;
|
||||
m_bFree = true;
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
|
||||
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() );
|
||||
amx_RaiseError(amx,AMX_ERR_NATIVE);
|
||||
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);
|
||||
|
||||
g_tasksMngr.registerTask( plugin ,
|
||||
iFunc , UTIL_ReadFlags(temp), params[3], base ,
|
||||
params[5] ,
|
||||
get_amxaddr(amx,params[4]) , params[7] );
|
||||
g_tasksMngr.registerTask( plugin , iFunc , UTIL_ReadFlags(temp), params[3], base , params[5] , get_amxaddr(amx,params[4]) , params[7] );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user