Fixed amb1690 - Client prefs tables now create themselves.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402199
This commit is contained in:
Matt Woodrow 2008-05-26 07:51:36 +00:00
parent c93d05f622
commit 044ee841f2
4 changed files with 64 additions and 2 deletions

View File

@ -21,7 +21,7 @@
"clientprefs"
{
"driver" "default"
"driver" "sqlite"
"host" "localhost"
"database" "clientprefs-sqlite"
"user" "root"

View File

@ -92,10 +92,69 @@ bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
if (strcmp(identifier, "sqlite") == 0)
{
driver = DRIVER_SQLITE;
TQueryOp *op = new TQueryOp(
Database,
"CREATE TABLE sm_cookies IF NOT EXISTS \
( \
id INTEGER PRIMARY KEY AUTOINCREMENT, \
name varchar(30) NOT NULL UNIQUE, \
description varchar(255), \
access INTEGER \
)",
Query_CreateTable,
0);
dbi->AddToThreadQueue(op, PrioQueue_Normal);
op = new TQueryOp(
Database,
"CREATE TABLE sm_cookie_cache IF NOT EXISTS \
( \
player varchar(65) NOT NULL, \
cookie_id int(10) NOT NULL, \
value varchar(100), \
timestamp int, \
PRIMARY KEY (player, cookie_id) \
)",
Query_CreateTable,
0);
dbi->AddToThreadQueue(op, PrioQueue_Normal);
}
else if (strcmp(identifier, "mysql") == 0)
{
driver = DRIVER_MYSQL;
TQueryOp *op = new TQueryOp(
Database,
"CREATE TABLE sm_cookies IF NOT EXISTS \
( \
id INTEGER unsigned NOT NULL auto_increment, \
name varchar(30) NOT NULL UNIQUE, \
description varchar(255), \
access INTEGER, \
PRIMARY KEY (id) \
)",
Query_CreateTable,
0);
dbi->AddToThreadQueue(op, PrioQueue_Normal);
op = new TQueryOp(
Database,
"CREATE TABLE sm_cookie_cache IF NOT EXISTS \
( \
player varchar(65) NOT NULL, \
cookie_id int(10) NOT NULL, \
value varchar(100), \
timestamp int NOT NULL, \
PRIMARY KEY (player, cookie_id) \
)",
Query_CreateTable,
0);
dbi->AddToThreadQueue(op, PrioQueue_Normal);
}
else
{
@ -103,6 +162,8 @@ bool ClientPrefs::SDK_OnLoad(char *error, size_t maxlength, bool late)
return false;
}
sharesys->AddNatives(myself, g_ClientPrefNatives);
sharesys->RegisterLibrary(myself, "clientprefs");
g_CookieManager.cookieDataLoadedForward = forwards->CreateForward("OnClientCookiesCached", ET_Ignore, 1, NULL, Param_Cell);

View File

@ -40,13 +40,13 @@
#include "sh_list.h"
#include "cookie.h"
#include "menus.h"
#include "query.h"
#define DRIVER_MYSQL 1
#define DRIVER_SQLITE 0
#define MAX_TRANSLATE_PARAMS 32
/**
* @brief Sample implementation of the SDK Extension.
* Note: Uncomment one of the pre-defined virtual functions in order to use it.

View File

@ -42,6 +42,7 @@ enum querytype
Query_SelectData,
Query_InsertData,
Query_SelectId,
Query_CreateTable,
};
class TQueryOp : public IDBThreadOperation