mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Initial support for release dates in /mapinfo
This commit is contained in:
parent
55e0c58707
commit
6b1c7a5350
|
@ -172,7 +172,7 @@ void CSqlScore::Init()
|
|||
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_teamrace (Map VARCHAR(128) BINARY NOT NULL, Name VARCHAR(%d) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Time FLOAT DEFAULT 0, ID VARBINARY(16) NOT NULL, KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH);
|
||||
m_pStatement->execute(aBuf);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_maps (Map VARCHAR(128) BINARY NOT NULL, Server VARCHAR(32) BINARY NOT NULL, Mapper VARCHAR(128) BINARY NOT NULL, Points INT DEFAULT 0, Stars INT DEFAULT 0, UNIQUE KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix);
|
||||
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_maps (Map VARCHAR(128) BINARY NOT NULL, Server VARCHAR(32) BINARY NOT NULL, Mapper VARCHAR(128) BINARY NOT NULL, Points INT DEFAULT 0, Stars INT DEFAULT 0, Timestamp TIMESTAMP, UNIQUE KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix);
|
||||
m_pStatement->execute(aBuf);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_saves (Savegame TEXT CHARACTER SET utf8 BINARY NOT NULL, Map VARCHAR(128) BINARY NOT NULL, Code VARCHAR(128) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Server CHAR(3), UNIQUE KEY (Map, Code)) CHARACTER SET utf8 ;", m_pPrefix);
|
||||
|
@ -532,7 +532,7 @@ void CSqlScore::MapInfoThread(void *pUser)
|
|||
try
|
||||
{
|
||||
char aBuf[768];
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT l.Map, l.Server, Mapper, Points, Stars, count(Name) as Finishes FROM ((SELECT Map, Server, Mapper, Points, Stars FROM %s_maps WHERE Map LIKE '%s' COLLATE utf8_general_ci ORDER BY LENGTH(Map), Map LIMIT 1) as l) LEFT JOIN %s_race as r on l.Map = r.Map;", pData->m_pSqlData->m_pPrefix, pData->m_aMap, pData->m_pSqlData->m_pPrefix);
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT l.Map, l.Server, Mapper, Points, Stars, count(Name) as Finishes, UNIX_TIMESTAMP(l.Timestamp) as Stamp, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(l.Timestamp) as Ago FROM ((SELECT Map, Server, Mapper, Points, Stars FROM %s_maps WHERE Map LIKE '%s' COLLATE utf8_general_ci ORDER BY LENGTH(Map), Map LIMIT 1) as l) LEFT JOIN %s_race as r on l.Map = r.Map;", pData->m_pSqlData->m_pPrefix, pData->m_aMap, pData->m_pSqlData->m_pPrefix);
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
|
||||
if(pData->m_pSqlData->m_pResults->rowsCount() != 1)
|
||||
|
@ -551,6 +551,15 @@ void CSqlScore::MapInfoThread(void *pUser)
|
|||
strcpy(aServer, pData->m_pSqlData->m_pResults->getString("Server").c_str());
|
||||
char aMapper[128];
|
||||
strcpy(aMapper, pData->m_pSqlData->m_pResults->getString("Mapper").c_str());
|
||||
int stamp = (int)pData->m_pSqlData->m_pResults->getInt("Stamp");
|
||||
int ago = (int)pData->m_pSqlData->m_pResults->getInt("Ago");
|
||||
|
||||
char pAgoString[51] = "\0";
|
||||
if(stamp != 0)
|
||||
{
|
||||
strcpy(pAgoString, ", released ");
|
||||
agoTimeToString(ago, pAgoString+11);
|
||||
}
|
||||
|
||||
char aStars[20];
|
||||
switch(stars)
|
||||
|
@ -564,10 +573,7 @@ void CSqlScore::MapInfoThread(void *pUser)
|
|||
}
|
||||
|
||||
aServer[0] = toupper(aServer[0]);
|
||||
if (points == 1)
|
||||
str_format(aBuf, sizeof(aBuf), "\"%s\" by %s on %s (%s, %d point, %d finishes)", aMap, aMapper, aServer, aStars, points, finishes);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "\"%s\" by %s on %s (%s, %d points, %d finishes)", aMap, aMapper, aServer, aStars, points, finishes);
|
||||
str_format(aBuf, sizeof(aBuf), "\"%s\" by %s on %s (%s, %d %s, %d %s%s)", aMap, aMapper, aServer, aStars, points, points == 1 ? "point" : "points", finishes, finishes == 1 ? "finish" : "finishes");
|
||||
}
|
||||
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
|
||||
|
|
Loading…
Reference in a new issue