mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
Add uuid parsing
This commit is contained in:
parent
c6b1b08355
commit
3e1324dd0a
|
@ -55,6 +55,14 @@ void FormatUuid(CUuid Uuid, char *pBuffer, unsigned BufferLength)
|
|||
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
|
||||
}
|
||||
|
||||
void ParseUuid(CUuid *pUuid, char *pBuffer)
|
||||
{
|
||||
unsigned char *p = pUuid->m_aData;
|
||||
sscanf(pBuffer, "%02hhX%02hhX%02hhX%02hhX-%02hhX%02hhX-%02hhX%02hhX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX",
|
||||
&p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6], &p[7],
|
||||
&p[8], &p[9], &p[10], &p[11], &p[12], &p[13], &p[14], &p[15]);
|
||||
}
|
||||
|
||||
bool CUuid::operator==(const CUuid& Other)
|
||||
{
|
||||
return mem_comp(this, &Other, sizeof(*this)) == 0;
|
||||
|
|
|
@ -25,6 +25,7 @@ CUuid RandomUuid();
|
|||
CUuid CalculateUuid(const char *pName);
|
||||
// The buffer length should be at least UUID_MAXSTRSIZE.
|
||||
void FormatUuid(CUuid Uuid, char *pBuffer, unsigned BufferLength);
|
||||
void ParseUuid(CUuid *pUuid, char *pBuffer);
|
||||
|
||||
struct CName
|
||||
{
|
||||
|
|
|
@ -1450,8 +1450,7 @@ bool CScore::LoadTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData
|
|||
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf),
|
||||
"SELECT Savegame, Server, %s-%s AS Ago, "
|
||||
"(UNHEX(REPLACE(SaveID, '-',''))) AS SaveID "
|
||||
"SELECT Savegame, Server, %s-%s AS Ago, SaveID "
|
||||
"FROM %s_saves "
|
||||
"where Code = ? AND Map = ? AND DDNet7 = false AND Savegame LIKE ?;",
|
||||
aCurrentTimestamp, aTimestamp,
|
||||
|
@ -1483,17 +1482,18 @@ bool CScore::LoadTeamThread(IDbConnection *pSqlServer, const ISqlData *pGameData
|
|||
g_Config.m_SvSaveGamesDelay - Since);
|
||||
goto end;
|
||||
}
|
||||
if(pSqlServer->IsNull(4))
|
||||
|
||||
char aSaveID[UUID_MAXSTRSIZE];
|
||||
memset(pData->m_pResult->m_SaveID.m_aData, 0, sizeof(pData->m_pResult->m_SaveID.m_aData));
|
||||
if(!pSqlServer->IsNull(4))
|
||||
{
|
||||
memset(pData->m_pResult->m_SaveID.m_aData, 0, sizeof(pData->m_pResult->m_SaveID.m_aData));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pSqlServer->GetBlob(4, pData->m_pResult->m_SaveID.m_aData, sizeof(pData->m_pResult->m_SaveID.m_aData)) != 16)
|
||||
pSqlServer->GetString(4, aSaveID, sizeof(aSaveID));
|
||||
if(str_length(aSaveID) + 1 != UUID_MAXSTRSIZE)
|
||||
{
|
||||
strcpy(pData->m_pResult->m_aMessage, "Unable to load savegame: SaveID corrupted");
|
||||
goto end;
|
||||
}
|
||||
ParseUuid(&pData->m_pResult->m_SaveID, aSaveID);
|
||||
}
|
||||
|
||||
char aSaveString[65536];
|
||||
|
|
Loading…
Reference in a new issue