Replace SourceHook list usages in clientprefs with AMTL.
This commit is contained in:
parent
c37dbe131e
commit
695fc802a9
@ -59,8 +59,8 @@ void CookieManager::Unload()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find all cookies and delete them */
|
/* Find all cookies and delete them */
|
||||||
for (SourceHook::List<Cookie *>::iterator _iter = cookieList.begin(); _iter != cookieList.end(); _iter++)
|
for (size_t iter = 0; iter < cookieList.length(); ++iter)
|
||||||
delete (*_iter);
|
delete cookieList[iter];
|
||||||
|
|
||||||
cookieList.clear();
|
cookieList.clear();
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ Cookie *CookieManager::CreateCookie(const char *name, const char *description, C
|
|||||||
op->m_params.cookie = pCookie;
|
op->m_params.cookie = pCookie;
|
||||||
|
|
||||||
cookieFinder.insert(name, pCookie);
|
cookieFinder.insert(name, pCookie);
|
||||||
cookieList.push_back(pCookie);
|
cookieList.append(pCookie);
|
||||||
|
|
||||||
g_ClientPrefs.AddQueryToQueue(op);
|
g_ClientPrefs.AddQueryToQueue(op);
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ bool CookieManager::GetCookieValue(Cookie *pCookie, int client, char **value)
|
|||||||
{
|
{
|
||||||
data = new CookieData("");
|
data = new CookieData("");
|
||||||
data->parent = pCookie;
|
data->parent = pCookie;
|
||||||
clientData[client].push_back(data);
|
clientData[client].append(data);
|
||||||
pCookie->data[client] = data;
|
pCookie->data[client] = data;
|
||||||
data->changed = false;
|
data->changed = false;
|
||||||
data->timestamp = 0;
|
data->timestamp = 0;
|
||||||
@ -130,7 +130,7 @@ bool CookieManager::SetCookieValue(Cookie *pCookie, int client, const char *valu
|
|||||||
{
|
{
|
||||||
data = new CookieData(value);
|
data = new CookieData(value);
|
||||||
data->parent = pCookie;
|
data->parent = pCookie;
|
||||||
clientData[client].push_back(data);
|
clientData[client].append(data);
|
||||||
pCookie->data[client] = data;
|
pCookie->data[client] = data;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -185,10 +185,10 @@ void CookieManager::OnClientDisconnecting(int client)
|
|||||||
g_ClientPrefs.ClearQueryCache(player->GetSerial());
|
g_ClientPrefs.ClearQueryCache(player->GetSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SourceHook::List<CookieData *>::iterator _iter = clientData[client].begin();\
|
ke::Vector<CookieData *> &clientvec = clientData[client];
|
||||||
_iter != clientData[client].end(); _iter++)
|
for (size_t iter = 0; iter < clientvec.length(); ++iter)
|
||||||
{
|
{
|
||||||
current = (CookieData *)*_iter;
|
current = clientvec[iter];
|
||||||
dbId = current->parent->dbid;
|
dbId = current->parent->dbid;
|
||||||
|
|
||||||
if (player == NULL || pAuth == NULL || !current->changed || dbId == -1)
|
if (player == NULL || pAuth == NULL || !current->changed || dbId == -1)
|
||||||
@ -209,7 +209,7 @@ void CookieManager::OnClientDisconnecting(int client)
|
|||||||
current->parent->data[client] = NULL;
|
current->parent->data[client] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
clientData[client].clear();
|
clientvec.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CookieManager::ClientConnectCallback(int serial, IQuery *data)
|
void CookieManager::ClientConnectCallback(int serial, IQuery *data)
|
||||||
@ -263,7 +263,7 @@ void CookieManager::ClientConnectCallback(int serial, IQuery *data)
|
|||||||
|
|
||||||
pData->parent = parent;
|
pData->parent = parent;
|
||||||
parent->data[client] = pData;
|
parent->data[client] = pData;
|
||||||
clientData[client].push_back(pData);
|
clientData[client].append(pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
statsLoaded[client] = true;
|
statsLoaded[client] = true;
|
||||||
@ -317,19 +317,20 @@ bool CookieManager::AreClientCookiesPending(int client)
|
|||||||
|
|
||||||
void CookieManager::OnPluginDestroyed(IPlugin *plugin)
|
void CookieManager::OnPluginDestroyed(IPlugin *plugin)
|
||||||
{
|
{
|
||||||
SourceHook::List<char *> *pList;
|
ke::Vector<char *> *pList;
|
||||||
|
|
||||||
if (plugin->GetProperty("SettingsMenuItems", (void **)&pList, true))
|
if (plugin->GetProperty("SettingsMenuItems", (void **)&pList, true))
|
||||||
{
|
{
|
||||||
|
ke::Vector<char *> &menuitems = (*pList);
|
||||||
char *name;
|
char *name;
|
||||||
ItemDrawInfo draw;
|
ItemDrawInfo draw;
|
||||||
const char *info;
|
const char *info;
|
||||||
AutoMenuData * data;
|
AutoMenuData * data;
|
||||||
unsigned itemcount;
|
unsigned itemcount;
|
||||||
|
|
||||||
for (SourceHook::List<char *>::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();
|
itemcount = clientMenu->GetItemCount();
|
||||||
//remove from this plugins list
|
//remove from this plugins list
|
||||||
for (unsigned int i=0; i < itemcount; i++)
|
for (unsigned int i=0; i < itemcount; i++)
|
||||||
@ -360,7 +361,7 @@ void CookieManager::OnPluginDestroyed(IPlugin *plugin)
|
|||||||
delete [] name;
|
delete [] name;
|
||||||
}
|
}
|
||||||
|
|
||||||
pList->clear();
|
menuitems.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#define _INCLUDE_SOURCEMOD_CLIENTPREFS_COOKIE_H_
|
#define _INCLUDE_SOURCEMOD_CLIENTPREFS_COOKIE_H_
|
||||||
|
|
||||||
#include "extension.h"
|
#include "extension.h"
|
||||||
#include "sh_list.h"
|
#include "am-vector.h"
|
||||||
#include <sm_namehashset.h>
|
#include <sm_namehashset.h>
|
||||||
|
|
||||||
#define MAX_NAME_LENGTH 30
|
#define MAX_NAME_LENGTH 30
|
||||||
@ -128,12 +128,12 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
IForward *cookieDataLoadedForward;
|
IForward *cookieDataLoadedForward;
|
||||||
SourceHook::List<Cookie *> cookieList;
|
ke::Vector<Cookie *> cookieList;
|
||||||
IBaseMenu *clientMenu;
|
IBaseMenu *clientMenu;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NameHashSet<Cookie *> cookieFinder;
|
NameHashSet<Cookie *> cookieFinder;
|
||||||
SourceHook::List<CookieData *> clientData[SM_MAXPLAYERS+1];
|
ke::Vector<CookieData *> clientData[SM_MAXPLAYERS+1];
|
||||||
|
|
||||||
bool connected[SM_MAXPLAYERS+1];
|
bool connected[SM_MAXPLAYERS+1];
|
||||||
bool statsLoaded[SM_MAXPLAYERS+1];
|
bool statsLoaded[SM_MAXPLAYERS+1];
|
||||||
|
@ -319,7 +319,7 @@ bool ClientPrefs::AddQueryToQueue(TQueryOp *query)
|
|||||||
AutoLock lock(&queryLock);
|
AutoLock lock(&queryLock);
|
||||||
if (!Database)
|
if (!Database)
|
||||||
{
|
{
|
||||||
cachedQueries.push_back(query);
|
cachedQueries.append(query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,10 +339,9 @@ void ClientPrefs::ProcessQueryCache()
|
|||||||
if (!Database)
|
if (!Database)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TQueryOp *op;
|
for (size_t iter = 0; iter < cachedQueries.length(); ++iter)
|
||||||
for (SourceHook::List<TQueryOp *>::iterator iter = cachedQueries.begin(); iter != cachedQueries.end(); iter++)
|
|
||||||
{
|
{
|
||||||
op = *iter;
|
TQueryOp *op = cachedQueries[iter];
|
||||||
op->SetDatabase(Database);
|
op->SetDatabase(Database);
|
||||||
dbi->AddToThreadQueue(op, PrioQueue_Normal);
|
dbi->AddToThreadQueue(op, PrioQueue_Normal);
|
||||||
}
|
}
|
||||||
@ -402,18 +401,14 @@ void ClientPrefs::CatchLateLoadClients()
|
|||||||
void ClientPrefs::ClearQueryCache(int serial)
|
void ClientPrefs::ClearQueryCache(int serial)
|
||||||
{
|
{
|
||||||
AutoLock lock(&queryLock);
|
AutoLock lock(&queryLock);
|
||||||
for (SourceHook::List<TQueryOp *>::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)
|
if (op && op->PullQueryType() == Query_SelectData && op->PullQuerySerial() == serial)
|
||||||
{
|
{
|
||||||
op->Destroy();
|
op->Destroy();
|
||||||
iter = cachedQueries.erase(iter);
|
cachedQueries.remove(iter--);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "smsdk_ext.h"
|
#include "smsdk_ext.h"
|
||||||
#include "sh_list.h"
|
#include "am-vector.h"
|
||||||
|
|
||||||
#include <am-thread-utils.h>
|
#include <am-thread-utils.h>
|
||||||
#include <am-refcounting.h>
|
#include <am-refcounting.h>
|
||||||
@ -158,7 +158,7 @@ public:
|
|||||||
bool databaseLoading;
|
bool databaseLoading;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SourceHook::List<TQueryOp *> cachedQueries;
|
ke::Vector<TQueryOp *> cachedQueries;
|
||||||
ke::Mutex queryLock;
|
ke::Mutex queryLock;
|
||||||
IdentityToken_t *identity;
|
IdentityToken_t *identity;
|
||||||
};
|
};
|
||||||
@ -177,7 +177,7 @@ class CookieIteratorHandler : public IHandleTypeDispatch
|
|||||||
public:
|
public:
|
||||||
void OnHandleDestroy(HandleType_t type, void *object)
|
void OnHandleDestroy(HandleType_t type, void *object)
|
||||||
{
|
{
|
||||||
delete (SourceHook::List<Cookie *>::iterator *)object;
|
delete (size_t *)object;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -243,8 +243,8 @@ static cell_t GetCookieIterator(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
g_ClientPrefs.AttemptReconnection();
|
g_ClientPrefs.AttemptReconnection();
|
||||||
|
|
||||||
SourceHook::List<Cookie *>::iterator *iter = new SourceHook::List<Cookie *>::iterator;
|
size_t *iter = new size_t;
|
||||||
*iter = g_CookieManager.cookieList.begin();
|
*iter = 0;
|
||||||
|
|
||||||
Handle_t hndl = handlesys->CreateHandle(g_CookieIterator, iter, pContext->GetIdentity(), myself->GetIdentity(), NULL);
|
Handle_t hndl = handlesys->CreateHandle(g_CookieIterator, iter, pContext->GetIdentity(), myself->GetIdentity(), NULL);
|
||||||
if (hndl == BAD_HANDLE)
|
if (hndl == BAD_HANDLE)
|
||||||
@ -259,7 +259,7 @@ static cell_t ReadCookieIterator(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
g_ClientPrefs.AttemptReconnection();
|
g_ClientPrefs.AttemptReconnection();
|
||||||
|
|
||||||
SourceHook::List<Cookie *>::iterator *iter;
|
size_t *iter;
|
||||||
|
|
||||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
HandleError err;
|
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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cookie *pCookie = (Cookie *)**iter;
|
Cookie *pCookie = g_CookieManager.cookieList[(*iter)++];
|
||||||
|
|
||||||
(*iter)++;
|
|
||||||
|
|
||||||
pContext->StringToLocalUTF8(params[2], params[3], pCookie->name, NULL);
|
pContext->StringToLocalUTF8(params[2], params[3], pCookie->name, NULL);
|
||||||
pContext->StringToLocalUTF8(params[5], params[6], pCookie->description, 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 */
|
/* Track this in case the plugin unloads */
|
||||||
|
|
||||||
IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext());
|
IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext());
|
||||||
SourceHook::List<char *> *pList = NULL;
|
ke::Vector<char *> *pList = NULL;
|
||||||
|
|
||||||
if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList)
|
if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList)
|
||||||
{
|
{
|
||||||
pList = new SourceHook::List<char *>;
|
pList = new ke::Vector<char *>;
|
||||||
pPlugin->SetProperty("SettingsMenuItems", pList);
|
pPlugin->SetProperty("SettingsMenuItems", pList);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *copyarray = new char[strlen(display)+1];
|
char *copyarray = new char[strlen(display)+1];
|
||||||
g_pSM->Format(copyarray, strlen(display)+1, "%s", display);
|
g_pSM->Format(copyarray, strlen(display)+1, "%s", display);
|
||||||
|
|
||||||
pList->push_back(copyarray);
|
pList->append(copyarray);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -403,18 +401,18 @@ cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params)
|
|||||||
/* Track this in case the plugin unloads */
|
/* Track this in case the plugin unloads */
|
||||||
|
|
||||||
IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext());
|
IPlugin *pPlugin = plsys->FindPluginByContext(pContext->GetContext());
|
||||||
SourceHook::List<char *> *pList = NULL;
|
ke::Vector<char *> *pList = NULL;
|
||||||
|
|
||||||
if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList)
|
if (!pPlugin->GetProperty("SettingsMenuItems", (void **)&pList, false) || !pList)
|
||||||
{
|
{
|
||||||
pList = new SourceHook::List<char *>;
|
pList = new ke::Vector<char *>;
|
||||||
pPlugin->SetProperty("SettingsMenuItems", pList);
|
pPlugin->SetProperty("SettingsMenuItems", pList);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *copyarray = new char[strlen(display)+1];
|
char *copyarray = new char[strlen(display)+1];
|
||||||
g_pSM->Format(copyarray, strlen(display)+1, "%s", display);
|
g_pSM->Format(copyarray, strlen(display)+1, "%s", display);
|
||||||
|
|
||||||
pList->push_back(copyarray);
|
pList->append(copyarray);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user