2020-07-09 17:02:28 +00:00
|
|
|
#include "connection.h"
|
|
|
|
|
|
|
|
#include <engine/shared/protocol.h>
|
|
|
|
|
|
|
|
void IDbConnection::FormatCreateRace(char *aBuf, unsigned int BufferSize)
|
|
|
|
{
|
|
|
|
str_format(aBuf, BufferSize,
|
2020-09-26 19:41:58 +00:00
|
|
|
"CREATE TABLE IF NOT EXISTS %s_race ("
|
|
|
|
" Map VARCHAR(128) COLLATE %s NOT NULL, "
|
|
|
|
" Name VARCHAR(%d) COLLATE %s NOT NULL, "
|
|
|
|
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
|
|
|
|
" Time FLOAT DEFAULT 0, "
|
|
|
|
" Server CHAR(4), "
|
|
|
|
" cp1 FLOAT DEFAULT 0, cp2 FLOAT DEFAULT 0, cp3 FLOAT DEFAULT 0, "
|
|
|
|
" cp4 FLOAT DEFAULT 0, cp5 FLOAT DEFAULT 0, cp6 FLOAT DEFAULT 0, "
|
|
|
|
" cp7 FLOAT DEFAULT 0, cp8 FLOAT DEFAULT 0, cp9 FLOAT DEFAULT 0, "
|
|
|
|
" cp10 FLOAT DEFAULT 0, cp11 FLOAT DEFAULT 0, cp12 FLOAT DEFAULT 0, "
|
|
|
|
" cp13 FLOAT DEFAULT 0, cp14 FLOAT DEFAULT 0, cp15 FLOAT DEFAULT 0, "
|
|
|
|
" cp16 FLOAT DEFAULT 0, cp17 FLOAT DEFAULT 0, cp18 FLOAT DEFAULT 0, "
|
|
|
|
" cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, "
|
|
|
|
" cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, "
|
|
|
|
" cp25 FLOAT DEFAULT 0, "
|
|
|
|
" GameID VARCHAR(64), "
|
|
|
|
" DDNet7 BOOL DEFAULT FALSE, "
|
|
|
|
" PRIMARY KEY (Map, Name, Time, Timestamp, Server)"
|
|
|
|
");",
|
|
|
|
GetPrefix(), BinaryCollate(), MAX_NAME_LENGTH, BinaryCollate());
|
2020-07-09 17:02:28 +00:00
|
|
|
}
|
|
|
|
|
2020-07-09 17:18:18 +00:00
|
|
|
void IDbConnection::FormatCreateTeamrace(char *aBuf, unsigned int BufferSize, const char *pIdType)
|
2020-07-09 17:02:28 +00:00
|
|
|
{
|
|
|
|
str_format(aBuf, BufferSize,
|
2020-09-26 19:41:58 +00:00
|
|
|
"CREATE TABLE IF NOT EXISTS %s_teamrace ("
|
|
|
|
" Map VARCHAR(128) COLLATE %s NOT NULL, "
|
|
|
|
" Name VARCHAR(%d) COLLATE %s NOT NULL, "
|
|
|
|
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
|
|
|
|
" Time FLOAT DEFAULT 0, "
|
|
|
|
" ID %s NOT NULL, " // VARBINARY(16) for MySQL and BLOB for SQLite
|
|
|
|
" GameID VARCHAR(64), "
|
|
|
|
" DDNet7 BOOL DEFAULT FALSE, "
|
|
|
|
" PRIMARY KEY (ID, Name)"
|
|
|
|
");",
|
|
|
|
GetPrefix(), BinaryCollate(), MAX_NAME_LENGTH, BinaryCollate(), pIdType);
|
2020-07-09 17:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IDbConnection::FormatCreateMaps(char *aBuf, unsigned int BufferSize)
|
|
|
|
{
|
|
|
|
str_format(aBuf, BufferSize,
|
2020-09-26 19:41:58 +00:00
|
|
|
"CREATE TABLE IF NOT EXISTS %s_maps ("
|
|
|
|
" Map VARCHAR(128) COLLATE %s NOT NULL, "
|
|
|
|
" Server VARCHAR(32) COLLATE %s NOT NULL, "
|
|
|
|
" Mapper VARCHAR(128) COLLATE %s NOT NULL, "
|
|
|
|
" Points INT DEFAULT 0, "
|
|
|
|
" Stars INT DEFAULT 0, "
|
|
|
|
" Timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, "
|
|
|
|
" PRIMARY KEY (Map)"
|
|
|
|
");",
|
|
|
|
GetPrefix(), BinaryCollate(), BinaryCollate(), BinaryCollate());
|
2020-07-09 17:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IDbConnection::FormatCreateSaves(char *aBuf, unsigned int BufferSize)
|
|
|
|
{
|
|
|
|
str_format(aBuf, BufferSize,
|
2020-09-26 19:41:58 +00:00
|
|
|
"CREATE TABLE IF NOT EXISTS %s_saves ("
|
|
|
|
" Savegame TEXT COLLATE %s NOT NULL, "
|
|
|
|
" Map VARCHAR(128) COLLATE %s NOT NULL, "
|
|
|
|
" Code VARCHAR(128) COLLATE %s NOT NULL, "
|
|
|
|
" Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
|
|
|
|
" Server CHAR(4), "
|
|
|
|
" DDNet7 BOOL DEFAULT FALSE, "
|
|
|
|
" SaveID VARCHAR(36) DEFAULT NULL, "
|
|
|
|
" PRIMARY KEY (Map, Code)"
|
|
|
|
");",
|
|
|
|
GetPrefix(), BinaryCollate(), BinaryCollate(), BinaryCollate());
|
2020-07-09 17:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IDbConnection::FormatCreatePoints(char *aBuf, unsigned int BufferSize)
|
|
|
|
{
|
|
|
|
str_format(aBuf, BufferSize,
|
2020-09-26 19:41:58 +00:00
|
|
|
"CREATE TABLE IF NOT EXISTS %s_points ("
|
|
|
|
" Name VARCHAR(%d) COLLATE %s NOT NULL, "
|
|
|
|
" Points INT DEFAULT 0, "
|
|
|
|
" PRIMARY KEY (Name)"
|
|
|
|
");",
|
|
|
|
GetPrefix(), MAX_NAME_LENGTH, BinaryCollate());
|
2020-07-09 17:02:28 +00:00
|
|
|
}
|