diff --git a/amxmodx/CForward.cpp b/amxmodx/CForward.cpp index feea95fe..0f9092b5 100755 --- a/amxmodx/CForward.cpp +++ b/amxmodx/CForward.cpp @@ -31,7 +31,6 @@ #include "amxmodx.h" - CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes) { m_FuncName = name; @@ -41,6 +40,7 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo // find funcs int func; AMXForward *tmp = NULL; + m_Funcs.clear(); for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter) { 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!!! tmp->pPlugin = &(*iter); 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; - for (CList::iterator iter = m_Funcs.begin(); iter; ++iter) + unsigned int id = 0; + + CVector::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 int i; @@ -75,7 +79,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays) if (m_ParamTypes[i] == FP_STRING || m_ParamTypes[i] == FP_STRINGEX) { cell *tmp; - amx_Allot((*iter).pPlugin->getAMX(), + amx_Allot((*iter)->pPlugin->getAMX(), (m_ParamTypes[i] == FP_STRING) ? strlen(reinterpret_cast(params[i]))+1 : STRINGEX_MAXLENGTH, &realParams[i], &tmp); 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) { cell *tmp; - amx_Allot((*iter).pPlugin->getAMX(), preparedArrays[params[i]].size, + amx_Allot((*iter)->pPlugin->getAMX(), preparedArrays[params[i]].size, &realParams[i], &tmp); physAddrs[i] = tmp; if (preparedArrays[params[i]].type == Type_Cell) @@ -105,23 +109,23 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays) } // exec 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 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 for (i = 0; i < m_NumParams; ++i) { 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) { // copy back amx_GetString(reinterpret_cast(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) { @@ -137,7 +141,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays) for (unsigned int j = 0; j < preparedArrays[params[i]].size; ++j) *data++ = static_cast(*tmp++ & 0xFF); } - amx_Release((*iter).pPlugin->getAMX(), realParams[i]); + amx_Release((*iter)->pPlugin->getAMX(), realParams[i]); } } diff --git a/amxmodx/CForward.h b/amxmodx/CForward.h index 38561848..80ba1553 100755 --- a/amxmodx/CForward.h +++ b/amxmodx/CForward.h @@ -92,7 +92,7 @@ class CForward CPluginMngr::CPlugin *pPlugin; int func; }; - typedef CList AMXForwardList; + typedef CVector AMXForwardList; AMXForwardList m_Funcs; ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS]; public: diff --git a/amxmodx/CVector.h b/amxmodx/CVector.h index 627e24f1..cdb49355 100755 --- a/amxmodx/CVector.h +++ b/amxmodx/CVector.h @@ -240,6 +240,8 @@ public: // constructors / destructors CVector() { + m_Size = 0; + m_CurrentUsedSize = 0; m_Data = NULL; }