Fixed incorrect forward orders
Fixed bug in CVector
This commit is contained in:
parent
ff23a74e9c
commit
3dedf9976b
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
|
|
||||||
|
|
||||||
CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes)
|
CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes)
|
||||||
{
|
{
|
||||||
m_FuncName = name;
|
m_FuncName = name;
|
||||||
@ -41,6 +40,7 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo
|
|||||||
// find funcs
|
// find funcs
|
||||||
int func;
|
int func;
|
||||||
AMXForward *tmp = NULL;
|
AMXForward *tmp = NULL;
|
||||||
|
m_Funcs.clear();
|
||||||
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
|
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
|
||||||
{
|
{
|
||||||
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
|
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
|
||||||
@ -50,7 +50,7 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo
|
|||||||
return; // :TODO: Better error report!!!
|
return; // :TODO: Better error report!!!
|
||||||
tmp->pPlugin = &(*iter);
|
tmp->pPlugin = &(*iter);
|
||||||
tmp->func = func;
|
tmp->func = func;
|
||||||
m_Funcs.put(tmp);
|
m_Funcs.push_back(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,9 +64,13 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
|
|
||||||
cell globRetVal = 0;
|
cell globRetVal = 0;
|
||||||
|
|
||||||
for (CList<AMXForward>::iterator iter = m_Funcs.begin(); iter; ++iter)
|
unsigned int id = 0;
|
||||||
|
|
||||||
|
CVector<AMXForward *>::iterator iter;
|
||||||
|
|
||||||
|
for (iter = m_Funcs.begin(); iter != m_Funcs.end(); iter++)
|
||||||
{
|
{
|
||||||
if ((*iter).pPlugin->isExecutable((*iter).func))
|
if ((*iter)->pPlugin->isExecutable((*iter)->func))
|
||||||
{
|
{
|
||||||
// handle strings & arrays
|
// handle strings & arrays
|
||||||
int i;
|
int i;
|
||||||
@ -75,7 +79,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot((*iter).pPlugin->getAMX(),
|
amx_Allot((*iter)->pPlugin->getAMX(),
|
||||||
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
(m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast<const char*>(params[i]))+1 : STRINGEX_MAXLENGTH,
|
||||||
&realParams[i], &tmp);
|
&realParams[i], &tmp);
|
||||||
amx_SetString(tmp, (const char *)(params[i]), 0, 0);
|
amx_SetString(tmp, (const char *)(params[i]), 0, 0);
|
||||||
@ -84,7 +88,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||||
{
|
{
|
||||||
cell *tmp;
|
cell *tmp;
|
||||||
amx_Allot((*iter).pPlugin->getAMX(), preparedArrays[params[i]].size,
|
amx_Allot((*iter)->pPlugin->getAMX(), preparedArrays[params[i]].size,
|
||||||
&realParams[i], &tmp);
|
&realParams[i], &tmp);
|
||||||
physAddrs[i] = tmp;
|
physAddrs[i] = tmp;
|
||||||
if (preparedArrays[params[i]].type == Type_Cell)
|
if (preparedArrays[params[i]].type == Type_Cell)
|
||||||
@ -105,23 +109,23 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
}
|
}
|
||||||
// exec
|
// exec
|
||||||
cell retVal;
|
cell retVal;
|
||||||
int err = amx_Execv((*iter).pPlugin->getAMX(), &retVal, (*iter).func, m_NumParams, realParams);
|
int err = amx_Execv((*iter)->pPlugin->getAMX(), &retVal, (*iter)->func, m_NumParams, realParams);
|
||||||
// log runtime error, if any
|
// log runtime error, if any
|
||||||
if (err != AMX_ERR_NONE)
|
if (err != AMX_ERR_NONE)
|
||||||
AMXXLOG_Log("[AMXX] Run time error %d on line %ld (plugin \"%s\")", err, (*iter).pPlugin->getAMX()->curline, (*iter).pPlugin->getName());
|
AMXXLOG_Log("[AMXX] Run time error %d on line %ld (plugin \"%s\")", err, (*iter)->pPlugin->getAMX()->curline, (*iter)->pPlugin->getName());
|
||||||
|
|
||||||
// cleanup strings & arrays
|
// cleanup strings & arrays
|
||||||
for (i = 0; i < m_NumParams; ++i)
|
for (i = 0; i < m_NumParams; ++i)
|
||||||
{
|
{
|
||||||
if (m_ParamTypes[i] == FP_STRING)
|
if (m_ParamTypes[i] == FP_STRING)
|
||||||
{
|
{
|
||||||
amx_Release((*iter).pPlugin->getAMX(), realParams[i]);
|
amx_Release((*iter)->pPlugin->getAMX(), realParams[i]);
|
||||||
}
|
}
|
||||||
else if (m_ParamTypes[i] == FP_STRINGEX)
|
else if (m_ParamTypes[i] == FP_STRINGEX)
|
||||||
{
|
{
|
||||||
// copy back
|
// copy back
|
||||||
amx_GetString(reinterpret_cast<char*>(params[i]), physAddrs[i], 0);
|
amx_GetString(reinterpret_cast<char*>(params[i]), physAddrs[i], 0);
|
||||||
amx_Release((*iter).pPlugin->getAMX(), realParams[i]);
|
amx_Release((*iter)->pPlugin->getAMX(), realParams[i]);
|
||||||
}
|
}
|
||||||
else if (m_ParamTypes[i] == FP_ARRAY)
|
else if (m_ParamTypes[i] == FP_ARRAY)
|
||||||
{
|
{
|
||||||
@ -137,7 +141,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
|
|||||||
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j)
|
||||||
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
*data++ = static_cast<char>(*tmp++ & 0xFF);
|
||||||
}
|
}
|
||||||
amx_Release((*iter).pPlugin->getAMX(), realParams[i]);
|
amx_Release((*iter)->pPlugin->getAMX(), realParams[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class CForward
|
|||||||
CPluginMngr::CPlugin *pPlugin;
|
CPluginMngr::CPlugin *pPlugin;
|
||||||
int func;
|
int func;
|
||||||
};
|
};
|
||||||
typedef CList<AMXForward> AMXForwardList;
|
typedef CVector<AMXForward*> AMXForwardList;
|
||||||
AMXForwardList m_Funcs;
|
AMXForwardList m_Funcs;
|
||||||
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
|
||||||
public:
|
public:
|
||||||
|
@ -240,6 +240,8 @@ public:
|
|||||||
// constructors / destructors
|
// constructors / destructors
|
||||||
CVector<T>()
|
CVector<T>()
|
||||||
{
|
{
|
||||||
|
m_Size = 0;
|
||||||
|
m_CurrentUsedSize = 0;
|
||||||
m_Data = NULL;
|
m_Data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user