Merge pull request #9050 from ChillerDragon/pr_sql_convention

Cleanup sql worker request/result naming convention
This commit is contained in:
Dennis Felsing 2024-09-27 11:19:09 +00:00 committed by GitHub
commit 2a64dac091
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 17 deletions

View file

@ -112,7 +112,7 @@ void CScore::LoadBestTime()
auto LoadBestTimeResult = std::make_shared<CScoreLoadBestTimeResult>(); auto LoadBestTimeResult = std::make_shared<CScoreLoadBestTimeResult>();
m_pGameServer->m_pController->m_pLoadBestTimeResult = LoadBestTimeResult; m_pGameServer->m_pController->m_pLoadBestTimeResult = LoadBestTimeResult;
auto Tmp = std::make_unique<CSqlLoadBestTimeData>(LoadBestTimeResult); auto Tmp = std::make_unique<CSqlLoadBestTimeRequest>(LoadBestTimeResult);
str_copy(Tmp->m_aMap, Server()->GetMapName(), sizeof(Tmp->m_aMap)); str_copy(Tmp->m_aMap, Server()->GetMapName(), sizeof(Tmp->m_aMap));
m_pPool->Execute(CScoreWorker::LoadBestTime, std::move(Tmp), "load best time"); m_pPool->Execute(CScoreWorker::LoadBestTime, std::move(Tmp), "load best time");
} }
@ -308,7 +308,7 @@ void CScore::SaveTeam(int ClientId, const char *pCode, const char *pServer)
return; return;
pController->Teams().SetSaving(Team, SaveResult); pController->Teams().SetSaving(Team, SaveResult);
auto Tmp = std::make_unique<CSqlTeamSave>(SaveResult); auto Tmp = std::make_unique<CSqlTeamSaveData>(SaveResult);
str_copy(Tmp->m_aCode, pCode, sizeof(Tmp->m_aCode)); str_copy(Tmp->m_aCode, pCode, sizeof(Tmp->m_aCode));
str_copy(Tmp->m_aMap, Server()->GetMapName(), sizeof(Tmp->m_aMap)); str_copy(Tmp->m_aMap, Server()->GetMapName(), sizeof(Tmp->m_aMap));
str_copy(Tmp->m_aServer, pServer, sizeof(Tmp->m_aServer)); str_copy(Tmp->m_aServer, pServer, sizeof(Tmp->m_aServer));
@ -370,7 +370,7 @@ void CScore::LoadTeam(const char *pCode, int ClientId)
auto SaveResult = std::make_shared<CScoreSaveResult>(ClientId); auto SaveResult = std::make_shared<CScoreSaveResult>(ClientId);
SaveResult->m_Status = CScoreSaveResult::LOAD_FAILED; SaveResult->m_Status = CScoreSaveResult::LOAD_FAILED;
pController->Teams().SetSaving(Team, SaveResult); pController->Teams().SetSaving(Team, SaveResult);
auto Tmp = std::make_unique<CSqlTeamLoad>(SaveResult); auto Tmp = std::make_unique<CSqlTeamLoadRequest>(SaveResult);
str_copy(Tmp->m_aCode, pCode, sizeof(Tmp->m_aCode)); str_copy(Tmp->m_aCode, pCode, sizeof(Tmp->m_aCode));
str_copy(Tmp->m_aMap, Server()->GetMapName(), sizeof(Tmp->m_aMap)); str_copy(Tmp->m_aMap, Server()->GetMapName(), sizeof(Tmp->m_aMap));
str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientId), sizeof(Tmp->m_aRequestingPlayer)); str_copy(Tmp->m_aRequestingPlayer, Server()->ClientName(ClientId), sizeof(Tmp->m_aRequestingPlayer));

View file

@ -101,7 +101,7 @@ bool CTeamrank::SamePlayers(const std::vector<std::string> *pvSortedNames)
bool CScoreWorker::LoadBestTime(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize) bool CScoreWorker::LoadBestTime(IDbConnection *pSqlServer, const ISqlData *pGameData, char *pError, int ErrorSize)
{ {
const auto *pData = dynamic_cast<const CSqlLoadBestTimeData *>(pGameData); const auto *pData = dynamic_cast<const CSqlLoadBestTimeRequest *>(pGameData);
auto *pResult = dynamic_cast<CScoreLoadBestTimeResult *>(pGameData->m_pResult.get()); auto *pResult = dynamic_cast<CScoreLoadBestTimeResult *>(pGameData->m_pResult.get());
char aBuf[512]; char aBuf[512];
@ -1568,7 +1568,7 @@ bool CScoreWorker::RandomUnfinishedMap(IDbConnection *pSqlServer, const ISqlData
bool CScoreWorker::SaveTeam(IDbConnection *pSqlServer, const ISqlData *pGameData, Write w, char *pError, int ErrorSize) bool CScoreWorker::SaveTeam(IDbConnection *pSqlServer, const ISqlData *pGameData, Write w, char *pError, int ErrorSize)
{ {
const auto *pData = dynamic_cast<const CSqlTeamSave *>(pGameData); const auto *pData = dynamic_cast<const CSqlTeamSaveData *>(pGameData);
auto *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get()); auto *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get());
if(w == Write::NORMAL_SUCCEEDED) if(w == Write::NORMAL_SUCCEEDED)
@ -1715,7 +1715,7 @@ bool CScoreWorker::LoadTeam(IDbConnection *pSqlServer, const ISqlData *pGameData
{ {
if(w == Write::NORMAL_SUCCEEDED || w == Write::BACKUP_FIRST) if(w == Write::NORMAL_SUCCEEDED || w == Write::BACKUP_FIRST)
return false; return false;
const auto *pData = dynamic_cast<const CSqlTeamLoad *>(pGameData); const auto *pData = dynamic_cast<const CSqlTeamLoadRequest *>(pGameData);
auto *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get()); auto *pResult = dynamic_cast<CScoreSaveResult *>(pGameData->m_pResult.get());
pResult->m_Status = CScoreSaveResult::LOAD_FAILED; pResult->m_Status = CScoreSaveResult::LOAD_FAILED;

View file

@ -72,9 +72,9 @@ struct CScoreLoadBestTimeResult : ISqlResult
float m_CurrentRecord; float m_CurrentRecord;
}; };
struct CSqlLoadBestTimeData : ISqlData struct CSqlLoadBestTimeRequest : ISqlData
{ {
CSqlLoadBestTimeData(std::shared_ptr<CScoreLoadBestTimeResult> pResult) : CSqlLoadBestTimeRequest(std::shared_ptr<CScoreLoadBestTimeResult> pResult) :
ISqlData(std::move(pResult)) ISqlData(std::move(pResult))
{ {
} }
@ -188,13 +188,13 @@ struct CSqlTeamScoreData : ISqlData
CUuid m_TeamrankUuid; CUuid m_TeamrankUuid;
}; };
struct CSqlTeamSave : ISqlData struct CSqlTeamSaveData : ISqlData
{ {
CSqlTeamSave(std::shared_ptr<CScoreSaveResult> pResult) : CSqlTeamSaveData(std::shared_ptr<CScoreSaveResult> pResult) :
ISqlData(std::move(pResult)) ISqlData(std::move(pResult))
{ {
} }
virtual ~CSqlTeamSave(){}; virtual ~CSqlTeamSaveData(){};
char m_aClientName[MAX_NAME_LENGTH]; char m_aClientName[MAX_NAME_LENGTH];
char m_aMap[MAX_MAP_LENGTH]; char m_aMap[MAX_MAP_LENGTH];
@ -203,13 +203,13 @@ struct CSqlTeamSave : ISqlData
char m_aServer[5]; char m_aServer[5];
}; };
struct CSqlTeamLoad : ISqlData struct CSqlTeamLoadRequest : ISqlData
{ {
CSqlTeamLoad(std::shared_ptr<CScoreSaveResult> pResult) : CSqlTeamLoadRequest(std::shared_ptr<CScoreSaveResult> pResult) :
ISqlData(std::move(pResult)) ISqlData(std::move(pResult))
{ {
} }
virtual ~CSqlTeamLoad(){}; virtual ~CSqlTeamLoadRequest(){};
char m_aCode[128]; char m_aCode[128];
char m_aMap[MAX_MAP_LENGTH]; char m_aMap[MAX_MAP_LENGTH];

View file

@ -70,9 +70,9 @@ struct Score : public testing::TestWithParam<IDbConnection *>
void LoadBestTime() void LoadBestTime()
{ {
CSqlLoadBestTimeData loadBestTimeData(std::make_shared<CScoreLoadBestTimeResult>()); CSqlLoadBestTimeRequest loadBestTimeReq(std::make_shared<CScoreLoadBestTimeResult>());
str_copy(loadBestTimeData.m_aMap, "Kobra 3", sizeof(loadBestTimeData.m_aMap)); str_copy(loadBestTimeReq.m_aMap, "Kobra 3", sizeof(loadBestTimeReq.m_aMap));
ASSERT_FALSE(CScoreWorker::LoadBestTime(m_pConn, &loadBestTimeData, m_aError, sizeof(m_aError))) << m_aError; ASSERT_FALSE(CScoreWorker::LoadBestTime(m_pConn, &loadBestTimeReq, m_aError, sizeof(m_aError))) << m_aError;
} }
void InsertMap() void InsertMap()