$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "stratagus.h"
#include "sqlite3.h"
#include "games.h"
db.cpp - Database routines. | |
#define | SQLCreatePlayersTable |
#define | SQLCreateGamesTable |
#define | SQLCreateGameDataTable |
#define | SQLCreateRankingsTable |
#define | SQLCreateMapsTable |
#define | SQLCreateTables |
static const char * | dbfile = "metaserver.db" |
static sqlite3 * | DB |
static int | DBMaxIDCallback (void *password, int argc, char **argv, char **colname) |
int | DBInit (void) |
void | DBQuit (void) |
static int | DBFindUserCallback (void *password, int argc, char **argv, char **colname) |
int | DBFindUser (char *username, char *password) |
int | DBAddUser (char *username, char *password) |
int | DBUpdateLoginDate (char *username) |
#define SQLCreateGameDataTable |
Value:
"CREATE TABLE game_data (" \ "id INTEGER," \ "username TEXT," \ "result INTEGER," \ "score INTEGER," \ "units INTEGER," \ "buildings INTEGER," \ "res1 INTEGER, res2 INTEGER, res3 INTEGER, res4 INTEGER, res5 INTEGER, res6 INTEGER," \ "res1_used INTEGER, res2_used INTEGER, res3_used INTEGER, res4_used INTEGER, res5_used INTEGER, res6_used INTEGER," \ "kills INTEGER," \ "razings INTEGER," \ "gamecycle INTEGER," \ "PRIMARY KEY (id, username));"
#define SQLCreateGamesTable |
Value:
"CREATE TABLE games (" \ "date INTEGER," \ "id INTEGER PRIMARY KEY," \ "gamename TEXT," \ "map_id INTEGER" \ ");"
#define SQLCreateMapsTable |
Value:
"CREATE TABLE maps (" \ "map_id INTEGER PRIMARY KEY," \ "map_name TEXT," \ "map_filename TEXT," \ "map_uuid TEXT," \ "map_size_x INTEGER," \ "map_size_y INTEGER" \ ");"
#define SQLCreatePlayersTable |
Value:
"CREATE TABLE players (" \ "username TEXT PRIMARY KEY," \ "password TEXT," \ "register_date INTEGER," \ "last_login_date INTEGER" \ ");"
#define SQLCreateRankingsTable |
Value:
"CREATE TABLE rankings (" \ "username TEXT," \ "gamename TEXT," \ "ranking INTEGER," \ "PRIMARY KEY (username, gamename)" \ ");"
#define SQLCreateTables |
int DBAddUser | ( | char * | username, | |
char * | password | |||
) |
Add a user
username | User name | |
password | Password |
int DBFindUser | ( | char * | username, | |
char * | password | |||
) |
Find a user and return the password
username | User name to find | |
password | If the user is found the password will be returned here |
static int DBFindUserCallback | ( | void * | password, | |
int | argc, | |||
char ** | argv, | |||
char ** | colname | |||
) | [static] |
Find user callback
int DBInit | ( | void | ) |
Initialize the database
static int DBMaxIDCallback | ( | void * | password, | |
int | argc, | |||
char ** | argv, | |||
char ** | colname | |||
) | [static] |
Max id callback
void DBQuit | ( | void | ) |
Close the database
int DBUpdateLoginDate | ( | char * | username | ) |
Log in a user
username | User name |
sqlite3* DB [static] |
const char* dbfile = "metaserver.db" [static] |