mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed birthdaycheck and the format of sql-inserts for the failure-file
This commit is contained in:
parent
cd41220a44
commit
a7c0cd58ee
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <base/system.h>
|
||||
|
||||
void FuzzyString(char *pString)
|
||||
|
@ -136,4 +137,12 @@ void agoTimeToString(int agoTime, char agoString[])
|
|||
}
|
||||
}
|
||||
|
||||
void getTimeStamp(char* dest, size_t size)
|
||||
{
|
||||
std::time_t rawtime;
|
||||
std::time(&rawtime);
|
||||
|
||||
str_timestamp_ex(rawtime, dest, size, "%Y-%m-%d %H:%M:%S");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -150,6 +150,9 @@ bool CSqlScore::CheckBirthdayThread(CSqlServer* pSqlServer, CSqlData *pGameData,
|
|||
{
|
||||
CSqlPlayerData *pData = (CSqlPlayerData *)pGameData;
|
||||
|
||||
if (HandleFailure)
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
// check strings
|
||||
|
@ -479,8 +482,11 @@ bool CSqlScore::SaveScoreThread(CSqlServer* pSqlServer, CSqlData *pGameData, boo
|
|||
{
|
||||
dbg_msg("sql", "ERROR: Could not save Score, writing insert to a file now...");
|
||||
|
||||
char aTimestamp [20];
|
||||
getTimeStamp(aTimestamp, sizeof(aTimestamp));
|
||||
|
||||
char aBuf[768];
|
||||
str_format(aBuf, sizeof(aBuf), "INSERT IGNORE INTO %%s_race(Map, Name, Timestamp, Time, Server, cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8, cp9, cp10, cp11, cp12, cp13, cp14, cp15, cp16, cp17, cp18, cp19, cp20, cp21, cp22, cp23, cp24, cp25) VALUES ('%s', '%s', CURRENT_TIMESTAMP(), '%.2f', '%s', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f');", pData->MapName(), pData->m_aName, pData->m_Time, g_Config.m_SvSqlServerName, pData->m_aCpCurrent[0], pData->m_aCpCurrent[1], pData->m_aCpCurrent[2], pData->m_aCpCurrent[3], pData->m_aCpCurrent[4], pData->m_aCpCurrent[5], pData->m_aCpCurrent[6], pData->m_aCpCurrent[7], pData->m_aCpCurrent[8], pData->m_aCpCurrent[9], pData->m_aCpCurrent[10], pData->m_aCpCurrent[11], pData->m_aCpCurrent[12], pData->m_aCpCurrent[13], pData->m_aCpCurrent[14], pData->m_aCpCurrent[15], pData->m_aCpCurrent[16], pData->m_aCpCurrent[17], pData->m_aCpCurrent[18], pData->m_aCpCurrent[19], pData->m_aCpCurrent[20], pData->m_aCpCurrent[21], pData->m_aCpCurrent[22], pData->m_aCpCurrent[23], pData->m_aCpCurrent[24]);
|
||||
str_format(aBuf, sizeof(aBuf), "INSERT IGNORE INTO %%s_race(Map, Name, Timestamp, Time, Server, cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8, cp9, cp10, cp11, cp12, cp13, cp14, cp15, cp16, cp17, cp18, cp19, cp20, cp21, cp22, cp23, cp24, cp25) VALUES ('%s', '%s', '%s', '%.2f', '%s', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f');", pData->MapName(), pData->m_aName, aTimestamp, pData->m_Time, g_Config.m_SvSqlServerName, pData->m_aCpCurrent[0], pData->m_aCpCurrent[1], pData->m_aCpCurrent[2], pData->m_aCpCurrent[3], pData->m_aCpCurrent[4], pData->m_aCpCurrent[5], pData->m_aCpCurrent[6], pData->m_aCpCurrent[7], pData->m_aCpCurrent[8], pData->m_aCpCurrent[9], pData->m_aCpCurrent[10], pData->m_aCpCurrent[11], pData->m_aCpCurrent[12], pData->m_aCpCurrent[13], pData->m_aCpCurrent[14], pData->m_aCpCurrent[15], pData->m_aCpCurrent[16], pData->m_aCpCurrent[17], pData->m_aCpCurrent[18], pData->m_aCpCurrent[19], pData->m_aCpCurrent[20], pData->m_aCpCurrent[21], pData->m_aCpCurrent[22], pData->m_aCpCurrent[23], pData->m_aCpCurrent[24]);
|
||||
io_write(File, aBuf, str_length(aBuf));
|
||||
io_write_newline(File);
|
||||
io_close(File);
|
||||
|
@ -575,14 +581,21 @@ bool CSqlScore::SaveTeamScoreThread(CSqlServer* pSqlServer, CSqlData *pGameData,
|
|||
IOHANDLE File = io_open(g_Config.m_SvSqlFailureFile, IOFLAG_APPEND);
|
||||
if(File)
|
||||
{
|
||||
const char pUUID[] = "SET @id = UUID();";
|
||||
io_write(File, pUUID, sizeof(pUUID));
|
||||
io_write_newline(File);
|
||||
|
||||
char aTimestamp [20];
|
||||
getTimeStamp(aTimestamp, sizeof(aTimestamp));
|
||||
|
||||
char aBuf[2300];
|
||||
for(unsigned int i = 0; i < pData->m_Size; i++)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "INSERT IGNORE INTO %%s_teamrace(Map, Name, Timestamp, Time, ID) VALUES ('%s', '%s', CURRENT_TIMESTAMP(), '%.2f', @id);", pData->MapName(), pData->m_aNames[i], pData->m_Time);
|
||||
str_format(aBuf, sizeof(aBuf), "INSERT IGNORE INTO %%s_teamrace(Map, Name, Timestamp, Time, ID) VALUES ('%s', '%s', '%s', '%.2f', @id);", pData->MapName(), pData->m_aNames[i], aTimestamp, pData->m_Time);
|
||||
io_write(File, aBuf, str_length(aBuf));
|
||||
io_write_newline(File);
|
||||
io_close(File);
|
||||
}
|
||||
io_close(File);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue