This commit is contained in:
Vladislav Gerasimov 2024-03-03 16:35:59 +01:00 committed by GitHub
commit bd2e6aa419
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 8 deletions

View file

@ -2506,11 +2506,12 @@ void CServer::PumpNetwork(bool PacketWaiting)
const char *CServer::GetMapName() const const char *CServer::GetMapName() const
{ {
// get the name of the map without his path // get the name of the map without his path
const char *pMapShortName = &Config()->m_SvMap[0]; const char *pMapName = m_aCurrentMap;
for(int i = 0; i < str_length(Config()->m_SvMap) - 1; i++) const char *pMapShortName = pMapName;
for(int i = 0; i < str_length(pMapName) - 1; i++)
{ {
if(Config()->m_SvMap[i] == '/' || Config()->m_SvMap[i] == '\\') if(pMapName[i] == '/' || pMapName[i] == '\\')
pMapShortName = &Config()->m_SvMap[i + 1]; pMapShortName = &pMapName[i + 1];
} }
return pMapShortName; return pMapShortName;
} }

View file

@ -3997,6 +3997,14 @@ void CGameContext::DeleteTempfile()
void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize) void CGameContext::OnMapChange(char *pNewMapName, int MapNameSize)
{ {
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(!m_apPlayers[i])
continue;
Score()->SaveTeam(i, "", g_Config.m_SvSqlServerName, true);
}
char aConfig[IO_MAX_PATH_LENGTH]; char aConfig[IO_MAX_PATH_LENGTH];
str_format(aConfig, sizeof(aConfig), "maps/%s.cfg", g_Config.m_SvMap); str_format(aConfig, sizeof(aConfig), "maps/%s.cfg", g_Config.m_SvMap);

View file

@ -277,7 +277,7 @@ void CScore::RandomUnfinishedMap(int ClientID, int Stars)
m_pPool->Execute(CScoreWorker::RandomUnfinishedMap, std::move(Tmp), "random unfinished map"); m_pPool->Execute(CScoreWorker::RandomUnfinishedMap, std::move(Tmp), "random unfinished map");
} }
void CScore::SaveTeam(int ClientID, const char *pCode, const char *pServer) void CScore::SaveTeam(int ClientID, const char *pCode, const char *pServer, bool Silent)
{ {
if(RateLimitPlayer(ClientID)) if(RateLimitPlayer(ClientID))
return; return;
@ -289,13 +289,18 @@ void CScore::SaveTeam(int ClientID, const char *pCode, const char *pServer)
auto SaveResult = std::make_shared<CScoreSaveResult>(ClientID); auto SaveResult = std::make_shared<CScoreSaveResult>(ClientID);
SaveResult->m_SaveID = RandomUuid(); SaveResult->m_SaveID = RandomUuid();
int Result = SaveResult->m_SavedTeam.Save(GameServer(), Team); int Result = SaveResult->m_SavedTeam.Save(GameServer(), Team);
if(CSaveTeam::HandleSaveError(Result, ClientID, GameServer())) if(Silent)
{
if(Result)
return;
}
else if(CSaveTeam::HandleSaveError(Result, ClientID, GameServer()))
return; return;
pController->Teams().SetSaving(Team, SaveResult); pController->Teams().SetSaving(Team, SaveResult);
auto Tmp = std::make_unique<CSqlTeamSave>(SaveResult); auto Tmp = std::make_unique<CSqlTeamSave>(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, g_Config.m_SvMap, sizeof(Tmp->m_aMap)); str_copy(Tmp->m_aMap, this->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));
str_copy(Tmp->m_aClientName, this->Server()->ClientName(ClientID), sizeof(Tmp->m_aClientName)); str_copy(Tmp->m_aClientName, this->Server()->ClientName(ClientID), sizeof(Tmp->m_aClientName));
Tmp->m_aGeneratedCode[0] = '\0'; Tmp->m_aGeneratedCode[0] = '\0';

View file

@ -68,7 +68,7 @@ public:
void RandomMap(int ClientID, int Stars); void RandomMap(int ClientID, int Stars);
void RandomUnfinishedMap(int ClientID, int Stars); void RandomUnfinishedMap(int ClientID, int Stars);
void SaveTeam(int ClientID, const char *pCode, const char *pServer); void SaveTeam(int ClientID, const char *pCode, const char *pServer, bool Silent = false);
void LoadTeam(const char *pCode, int ClientID); void LoadTeam(const char *pCode, int ClientID);
void GetSaves(int ClientID); void GetSaves(int ClientID);
}; };