Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod Client Preferences Extension
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
35 void TQueryOp::RunThinkPart()
37 //handler for threaded sql queries
40 case Query_InsertCookie:
42 g_CookieManager.InsertCookieCallback(m_pCookie, m_insertId);
46 case Query_SelectData:
48 g_CookieManager.ClientConnectCallback(m_serial, m_pResult);
54 g_CookieManager.SelectIdCallback(m_pCookie, m_pResult);
70 void TQueryOp::RunThreadPart()
72 if (m_type == Query_Connect)
74 g_ClientPrefs.DatabaseConnect();
78 assert(m_database != NULL);
79 /* I don't think this is needed anymore... keeping for now. */
80 m_database->LockForFullAtomicOperation();
81 if (!BindParamsAndRun())
83 g_pSM->LogError(myself,
84 "Failed SQL Query, Error: \"%s\" (Query id %i - serial %i)",
85 m_database->GetError(),
90 m_database->UnlockFromFullAtomicOperation();
93 IDBDriver *TQueryOp::GetDriver()
95 return m_database->GetDriver();
98 IdentityToken_t *TQueryOp::GetOwner()
100 return myself->GetIdentity();
103 void TQueryOp::Destroy()
105 if (m_pResult != NULL)
107 m_pResult->Destroy();
112 TQueryOp::TQueryOp(enum querytype type, int serial)
121 TQueryOp::TQueryOp(enum querytype type, Cookie *cookie)
131 void TQueryOp::SetDatabase(IDatabase *db)
136 bool TQueryOp::BindParamsAndRun()
143 case Query_InsertCookie:
145 char safe_name[MAX_NAME_LENGTH*2 + 1];
146 char safe_desc[MAX_DESC_LENGTH*2 + 1];
148 m_database->QuoteString(m_params.cookie->name,
152 m_database->QuoteString(m_params.cookie->description,
157 if (g_DriverType == Driver_MySQL)
161 "INSERT IGNORE INTO sm_cookies (name, description, access) \
162 VALUES (\"%s\", \"%s\", %d)",
165 m_params.cookie->access);
167 else if (g_DriverType == Driver_SQLite)
171 "INSERT OR IGNORE INTO sm_cookies (name, description, access) \
172 VALUES ('%s', '%s', %d)",
175 m_params.cookie->access);
178 if (!m_database->DoSimpleQuery(query))
183 m_insertId = m_database->GetInsertID();
188 case Query_SelectData:
192 m_database->QuoteString(m_params.steamId, safe_str, sizeof(safe_str), &ignore);
196 "SELECT sm_cookies.name, sm_cookie_cache.value, sm_cookies.description, \
197 sm_cookies.access, sm_cookie_cache.timestamp \
199 JOIN sm_cookie_cache \
200 ON sm_cookies.id = sm_cookie_cache.cookie_id \
201 WHERE player = '%s'",
204 m_pResult = m_database->DoQuery(query);
206 return (m_pResult != NULL);
209 case Query_InsertData:
212 char safe_val[MAX_VALUE_LENGTH*2 + 1];
214 m_database->QuoteString(m_params.steamId,
218 m_database->QuoteString(m_params.data->value,
223 if (g_DriverType == Driver_MySQL)
227 "INSERT INTO sm_cookie_cache (player, cookie_id, value, timestamp) \
228 VALUES (\"%s\", %d, \"%s\", %d) \
229 ON DUPLICATE KEY UPDATE \
230 value = \"%s\", timestamp = %d",
234 (unsigned int)m_params.data->timestamp,
236 (unsigned int)m_params.data->timestamp);
238 else if (g_DriverType == Driver_SQLite)
242 "INSERT OR REPLACE INTO sm_cookie_cache \
243 (player, cookie_id, value, timestamp) \
244 VALUES ('%s', %d, '%s', %d)",
248 (unsigned int)m_params.data->timestamp);
251 if (!m_database->DoSimpleQuery(query))
256 m_insertId = m_database->GetInsertID();
263 char safe_name[MAX_NAME_LENGTH*2 + 1];
265 /* the steamId var was actually used to store the name of the cookie - Save duplicating vars */
266 m_database->QuoteString(m_params.steamId,
273 "SELECT id FROM sm_cookies WHERE name = '%s'",
276 m_pResult = m_database->DoQuery(query);
278 return (m_pResult != NULL);
293 querytype TQueryOp::PullQueryType()
298 int TQueryOp::PullQuerySerial()
303 ParamData::~ParamData()
307 /* Data is only ever passed in a client disconnect query and always needs to be deleted */
313 ParamData::ParamData()