diff --git a/src/engine/shared/uuid_manager.cpp b/src/engine/shared/uuid_manager.cpp index a27f3482e..b4a69eb89 100644 --- a/src/engine/shared/uuid_manager.cpp +++ b/src/engine/shared/uuid_manager.cpp @@ -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; diff --git a/src/engine/shared/uuid_manager.h b/src/engine/shared/uuid_manager.h index e05ad2d3e..0e45cbda0 100644 --- a/src/engine/shared/uuid_manager.h +++ b/src/engine/shared/uuid_manager.h @@ -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 { diff --git a/src/game/server/score.cpp b/src/game/server/score.cpp index d88529df5..1b3253d35 100644 --- a/src/game/server/score.cpp +++ b/src/game/server/score.cpp @@ -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];