diff --git a/extensions/clientprefs/cookie.cpp b/extensions/clientprefs/cookie.cpp index 883eb4c3..f05c57d3 100644 --- a/extensions/clientprefs/cookie.cpp +++ b/extensions/clientprefs/cookie.cpp @@ -196,9 +196,16 @@ bool CookieManager::SetCookieValue(Cookie *pCookie, int client, char *value) void CookieManager::OnClientAuthorized(int client, const char *authstring) { + IGamePlayer *player = playerhelpers->GetGamePlayer(client); + + if (player == NULL) + { + return; + } + connected[client] = true; - TQueryOp *op = new TQueryOp(Query_SelectData, client); + TQueryOp *op = new TQueryOp(Query_SelectData, player->GetUserId()); strcpy(op->m_params.steamId, authstring); g_ClientPrefs.AddQueryToQueue(op); @@ -261,10 +268,18 @@ void CookieManager::OnClientDisconnecting(int client) } } -void CookieManager::ClientConnectCallback(int client, IQuery *data) +void CookieManager::ClientConnectCallback(int userid, IQuery *data) { + int client; IResultSet *results; + /* Check validity of client */ + if ((client = playerhelpers->GetClientOfUserId(userid)) == 0) + { + return; + } + + /* Check validity of results */ if (data == NULL || (results = data->GetResultSet()) == NULL) { return; diff --git a/extensions/clientprefs/cookie.h b/extensions/clientprefs/cookie.h index 361b746a..c3cf75dc 100644 --- a/extensions/clientprefs/cookie.h +++ b/extensions/clientprefs/cookie.h @@ -121,7 +121,7 @@ public: void Unload(); - void ClientConnectCallback(int client, IQuery *data); + void ClientConnectCallback(int userid, IQuery *data); void InsertCookieCallback(Cookie *pCookie, int dbId); void SelectIdCallback(Cookie *pCookie, IQuery *data); diff --git a/extensions/clientprefs/query.cpp b/extensions/clientprefs/query.cpp index 7dade90e..555699ae 100644 --- a/extensions/clientprefs/query.cpp +++ b/extensions/clientprefs/query.cpp @@ -51,7 +51,7 @@ void TQueryOp::RunThinkPart() case Query_SelectData: { - g_CookieManager.ClientConnectCallback(m_client, m_pResult); + g_CookieManager.ClientConnectCallback(m_userid, m_pResult); break; } @@ -84,10 +84,10 @@ void TQueryOp::RunThreadPart() if (!BindParamsAndRun()) { g_pSM->LogError(myself, - "Failed SQL Query, Error: \"%s\" (Query id %i - client %i)", + "Failed SQL Query, Error: \"%s\" (Query id %i - userid %i)", m_database->GetError(), m_type, - m_client); + m_userid); } m_database->UnlockFromFullAtomicOperation(); @@ -115,10 +115,10 @@ void TQueryOp::Destroy() delete this; } -TQueryOp::TQueryOp(enum querytype type, int client) +TQueryOp::TQueryOp(enum querytype type, int userid) { m_type = type; - m_client = client; + m_userid = userid; m_database = NULL; m_insertId = -1; m_pResult = NULL; diff --git a/extensions/clientprefs/query.h b/extensions/clientprefs/query.h index f0926684..29de40f2 100644 --- a/extensions/clientprefs/query.h +++ b/extensions/clientprefs/query.h @@ -68,7 +68,7 @@ struct ParamData class TQueryOp : public IDBThreadOperation { public: - TQueryOp(enum querytype type, int client); + TQueryOp(enum querytype type, int userid); TQueryOp(enum querytype type, Cookie *cookie); ~TQueryOp() {} @@ -102,7 +102,7 @@ private: enum querytype m_type; /* Data to be passed to the callback */ - int m_client; + int m_userid; int m_insertId; Cookie *m_pCookie; };