| 1752 | } |
| 1753 | |
| 1754 | bool CScoreWorker::LoadTeam(IDbConnection *pSqlServer, const ISqlData *pGameData, Write w, char *pError, int ErrorSize) |
| 1755 | { |
| 1756 | if(w == Write::NORMAL_SUCCEEDED || w == Write::BACKUP_FIRST) |
| 1757 | return true; |
| 1758 | const auto *pData = dynamic_cast<const CSqlTeamLoadRequest *>(pGameData); |
| 1759 | auto *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get()); |
| 1760 | pResult->m_Status = CScoreSaveResult::LOAD_FAILED; |
| 1761 | |
| 1762 | char aCurrentTimestamp[512]; |
| 1763 | pSqlServer->ToUnixTimestamp("CURRENT_TIMESTAMP", aCurrentTimestamp, sizeof(aCurrentTimestamp)); |
| 1764 | char aTimestamp[512]; |
| 1765 | pSqlServer->ToUnixTimestamp("Timestamp", aTimestamp, sizeof(aTimestamp)); |
| 1766 | |
| 1767 | char aBuf[512]; |
| 1768 | str_format(aBuf, sizeof(aBuf), |
| 1769 | "SELECT Savegame, %s-%s AS Ago, SaveId " |
| 1770 | "FROM %s_saves " |
| 1771 | "where Code = ? AND Map = ? AND DDNet7 = %s", |
| 1772 | aCurrentTimestamp, aTimestamp, |
| 1773 | pSqlServer->GetPrefix(), pSqlServer->False()); |
| 1774 | if(!pSqlServer->PrepareStatement(aBuf, pError, ErrorSize)) |
| 1775 | { |
| 1776 | return false; |
| 1777 | } |
| 1778 | pSqlServer->BindString(1, pData->m_aCode); |
| 1779 | pSqlServer->BindString(2, pData->m_aMap); |
| 1780 | |
| 1781 | bool End; |
| 1782 | if(!pSqlServer->Step(&End, pError, ErrorSize)) |
| 1783 | { |
| 1784 | return false; |
| 1785 | } |
| 1786 | if(End) |
| 1787 | { |
| 1788 | str_copy(pResult->m_aMessage, "No such savegame for this map", sizeof(pResult->m_aMessage)); |
| 1789 | return true; |
| 1790 | } |
| 1791 | |
| 1792 | pResult->m_SaveId = UUID_NO_SAVE_ID; |
| 1793 | if(!pSqlServer->IsNull(3)) |
| 1794 | { |
| 1795 | char aSaveId[UUID_MAXSTRSIZE]; |
| 1796 | pSqlServer->GetString(3, aSaveId, sizeof(aSaveId)); |
| 1797 | if(ParseUuid(&pResult->m_SaveId, aSaveId) || pResult->m_SaveId == UUID_NO_SAVE_ID) |
| 1798 | { |
| 1799 | str_copy(pResult->m_aMessage, "Unable to load savegame: SaveId corrupted", sizeof(pResult->m_aMessage)); |
| 1800 | return true; |
| 1801 | } |
| 1802 | } |
| 1803 | |
| 1804 | char aSaveString[65536]; |
| 1805 | pSqlServer->GetString(1, aSaveString, sizeof(aSaveString)); |
| 1806 | int Num = pResult->m_SavedTeam.FromString(aSaveString); |
| 1807 | |
| 1808 | if(Num != 0) |
| 1809 | { |
| 1810 | str_copy(pResult->m_aMessage, "Unable to load savegame: data corrupted", sizeof(pResult->m_aMessage)); |
| 1811 | return true; |
nothing calls this directly
no test coverage detected