diff --git a/extensions/clientprefs/cookie.cpp b/extensions/clientprefs/cookie.cpp index a8917b90..7266ef1a 100644 --- a/extensions/clientprefs/cookie.cpp +++ b/extensions/clientprefs/cookie.cpp @@ -59,8 +59,8 @@ void CookieManager::Unload() } /* Find all cookies and delete them */ - for (SourceHook::List::iterator _iter = cookieList.begin(); _iter != cookieList.end(); _iter++) - delete (*_iter); + for (size_t iter = 0; iter < cookieList.length(); ++iter) + delete cookieList[iter]; cookieList.clear(); } @@ -95,7 +95,7 @@ Cookie *CookieManager::CreateCookie(const char *name, const char *description, C op->m_params.cookie = pCookie; cookieFinder.insert(name, pCookie); - cookieList.push_back(pCookie); + cookieList.append(pCookie); g_ClientPrefs.AddQueryToQueue(op); @@ -111,7 +111,7 @@ bool CookieManager::GetCookieValue(Cookie *pCookie, int client, char **value) { data = new CookieData(""); data->parent = pCookie; - clientData[client].push_back(data); + clientData[client].append(data); pCookie->data[client] = data; data->changed = false; data->timestamp = 0; @@ -130,7 +130,7 @@ bool CookieManager::SetCookieValue(Cookie *pCookie, int client, const char *valu { data = new CookieData(value); data->parent = pCookie; - clientData[client].push_back(data); + clientData[client].append(data); pCookie->data[client] = data; } else @@ -184,11 +184,11 @@ void CookieManager::OnClientDisconnecting(int client) pAuth = player->GetAuthString(); g_ClientPrefs.ClearQueryCache(player->GetSerial()); } - - for (SourceHook::List::iterator _iter = clientData[client].begin();\ - _iter != clientData[client].end(); _iter++) + + ke::Vector &clientvec = clientData[client]; + for (size_t iter = 0; iter < clientvec.length(); ++iter) { - current = (CookieData *)*_iter; + current = clientvec[iter]; dbId = current->parent->dbid; if (player == NULL || pAuth == NULL || !current->changed || dbId == -1) @@ -209,7 +209,7 @@ void CookieManager::OnClientDisconnecting(int client) current->parent->data[client] = NULL; } - clientData[client].clear(); + clientvec.clear(); } void CookieManager::ClientConnectCallback(int serial, IQuery *data) @@ -263,7 +263,7 @@ void CookieManager::ClientConnectCallback(int serial, IQuery *data) pData->parent = parent; parent->data[client] = pData; - clientData[client].push_back(pData); + clientData[client].append(pData); } statsLoaded[client] = true; @@ -317,19 +317,20 @@ bool CookieManager::AreClientCookiesPending(int client) void CookieManager::OnPluginDestroyed(IPlugin *plugin) { - SourceHook::List *pList; + ke::Vector *pList; if (plugin->GetProperty("SettingsMenuItems", (void **)&pList, true)) { + ke::Vector &menuitems = (*pList); char *name; ItemDrawInfo draw; const char *info; AutoMenuData * data; unsigned itemcount; - for (SourceHook::List::iterator p_iter = pList->begin(); p_iter != pList->end(); p_iter++) + for (size_t p_iter = 0; p_iter < menuitems.length(); ++p_iter) { - name = (char *)*p_iter; + name = menuitems[p_iter]; itemcount = clientMenu->GetItemCount(); //remove from this plugins list for (unsigned int i=0; i < itemcount; i++) @@ -360,7 +361,7 @@ void CookieManager::OnPluginDestroyed(IPlugin *plugin) delete [] name; } - pList->clear(); + menuitems.clear(); } } diff --git a/extensions/clientprefs/cookie.h b/extensions/clientprefs/cookie.h index f7997ba6..9684b264 100644 --- a/extensions/clientprefs/cookie.h +++ b/extensions/clientprefs/cookie.h @@ -33,7 +33,7 @@ #define _INCLUDE_SOURCEMOD_CLIENTPREFS_COOKIE_H_ #include "extension.h" -#include "sh_list.h" +#include "am-vector.h" #include #define MAX_NAME_LENGTH 30 @@ -128,12 +128,12 @@ public: public: IForward *cookieDataLoadedForward; - SourceHook::List cookieList; + ke::Vector cookieList; IBaseMenu *clientMenu; private: NameHashSet cookieFinder; - SourceHook::List clientData[SM_MAXPLAYERS+1]; + ke::Vector clientData[SM_MAXPLAYERS+1]; bool connected[SM_MAXPLAYERS+1]; bool statsLoaded[SM_MAXPLAYERS+1]; diff --git a/extensions/clientprefs/extension.cpp b/extensions/clientprefs/extension.cpp index 92bb145f..96a3173b 100644 --- a/extensions/clientprefs/extension.cpp +++ b/extensions/clientprefs/extension.cpp @@ -319,7 +319,7 @@ bool ClientPrefs::AddQueryToQueue(TQueryOp *query) AutoLock lock(&queryLock); if (!Database) { - cachedQueries.push_back(query); + cachedQueries.append(query); return false; } @@ -339,10 +339,9 @@ void ClientPrefs::ProcessQueryCache() if (!Database) return; - TQueryOp *op; - for (SourceHook::List::iterator iter = cachedQueries.begin(); iter != cachedQueries.end(); iter++) + for (size_t iter = 0; iter < cachedQueries.length(); ++iter) { - op = *iter; + TQueryOp *op = cachedQueries[iter]; op->SetDatabase(Database); dbi->AddToThreadQueue(op, PrioQueue_Normal); } @@ -402,18 +401,14 @@ void ClientPrefs::CatchLateLoadClients() void ClientPrefs::ClearQueryCache(int serial) { AutoLock lock(&queryLock); - for (SourceHook::List::iterator iter = cachedQueries.begin(); iter != cachedQueries.end();) + for (size_t iter = 0; iter < cachedQueries.length(); ++iter) { - TQueryOp *op = *iter; + TQueryOp *op = cachedQueries[iter]; if (op && op->PullQueryType() == Query_SelectData && op->PullQuerySerial() == serial) { op->Destroy(); - iter = cachedQueries.erase(iter); - } - else - { - iter++; - } + cachedQueries.remove(iter--); + } } } diff --git a/extensions/clientprefs/extension.h b/extensions/clientprefs/extension.h index d850e46d..910cd783 100644 --- a/extensions/clientprefs/extension.h +++ b/extensions/clientprefs/extension.h @@ -35,7 +35,7 @@ #include #include #include "smsdk_ext.h" -#include "sh_list.h" +#include "am-vector.h" #include #include @@ -158,7 +158,7 @@ public: bool databaseLoading; private: - SourceHook::List cachedQueries; + ke::Vector cachedQueries; ke::Mutex queryLock; IdentityToken_t *identity; }; @@ -177,7 +177,7 @@ class CookieIteratorHandler : public IHandleTypeDispatch public: void OnHandleDestroy(HandleType_t type, void *object) { - delete (SourceHook::List::iterator *)object; + delete (size_t *)object; } }; diff --git a/extensions/clientprefs/natives.cpp b/extensions/clientprefs/natives.cpp index 29da7197..0478734f 100644 --- a/extensions/clientprefs/natives.cpp +++ b/extensions/clientprefs/natives.cpp @@ -243,8 +243,8 @@ static cell_t GetCookieIterator(IPluginContext *pContext, const cell_t *params) { g_ClientPrefs.AttemptReconnection(); - SourceHook::List::iterator *iter = new SourceHook::List::iterator; - *iter = g_CookieManager.cookieList.begin(); + size_t *iter = new size_t; + *iter = 0; Handle_t hndl = handlesys->CreateHandle(g_CookieIterator, iter, pContext->GetIdentity(), myself->GetIdentity(), NULL); if (hndl == BAD_HANDLE) @@ -259,7 +259,7 @@ static cell_t ReadCookieIterator(IPluginContext *pContext, const cell_t *params) { g_ClientPrefs.AttemptReconnection(); - SourceHook::List::iterator *iter; + size_t *iter; Handle_t hndl = static_cast(params[1]); HandleError err; @@ -274,14 +274,12 @@ static cell_t ReadCookieIterator(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid Cookie iterator handle %x (error %d)", hndl, err); } - if (*iter == g_CookieManager.cookieList.end()) + if (*iter >= g_CookieManager.cookieList.length()) { return 0; } - Cookie *pCookie = (Cookie *)**iter; - - (*iter)++; + Cookie *pCookie = g_CookieManager.cookieList[(*iter)++]; pContext->StringToLocalUTF8(params[2], params[3], pCookie->name, NULL); pContext->StringToLocalUTF8(params[5], params[6], pCookie->description, NULL); @@ -333,18 +331,18 @@ cell_t AddSettingsMenuItem(IPluginContext *pContext, const cell_t *params) /* Track this in case the plugin unloads */ IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext()); - SourceHook::List *pList = NULL; + ke::Vector *pList = NULL; if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList) { - pList = new SourceHook::List; + pList = new ke::Vector; pPlugin->SetProperty("SettingsMenuItems", pList); } char *copyarray = new char[strlen(display)+1]; g_pSM->Format(copyarray, strlen(display)+1, "%s", display); - pList->push_back(copyarray); + pList->append(copyarray); return 0; } @@ -403,18 +401,18 @@ cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params) /* Track this in case the plugin unloads */ IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext()); - SourceHook::List *pList = NULL; + ke::Vector *pList = NULL; if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList) { - pList = new SourceHook::List; + pList = new ke::Vector; pPlugin->SetProperty("SettingsMenuItems", pList); } char *copyarray = new char[strlen(display)+1]; g_pSM->Format(copyarray, strlen(display)+1, "%s", display); - pList->push_back(copyarray); + pList->append(copyarray); return 0; }