mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Merge f74ebfe3e8
into 885ae7ecae
This commit is contained in:
commit
bd2e6aa419
|
@ -2506,11 +2506,12 @@ void CServer::PumpNetwork(bool PacketWaiting)
|
|||
const char *CServer::GetMapName() const
|
||||
{
|
||||
// get the name of the map without his path
|
||||
const char *pMapShortName = &Config()->m_SvMap[0];
|
||||
for(int i = 0; i < str_length(Config()->m_SvMap) - 1; i++)
|
||||
const char *pMapName = m_aCurrentMap;
|
||||
const char *pMapShortName = pMapName;
|
||||
for(int i = 0; i < str_length(pMapName) - 1; i++)
|
||||
{
|
||||
if(Config()->m_SvMap[i] == '/' || Config()->m_SvMap[i] == '\\')
|
||||
pMapShortName = &Config()->m_SvMap[i + 1];
|
||||
if(pMapName[i] == '/' || pMapName[i] == '\\')
|
||||
pMapShortName = &pMapName[i + 1];
|
||||
}
|
||||
return pMapShortName;
|
||||
}
|
||||
|
|
|
@ -3997,6 +3997,14 @@ void CGameContext::DeleteTempfile()
|
|||
|
||||
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];
|
||||
str_format(aConfig, sizeof(aConfig), "maps/%s.cfg", g_Config.m_SvMap);
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ void CScore::RandomUnfinishedMap(int ClientID, int Stars)
|
|||
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))
|
||||
return;
|
||||
|
@ -289,13 +289,18 @@ void CScore::SaveTeam(int ClientID, const char *pCode, const char *pServer)
|
|||
auto SaveResult = std::make_shared<CScoreSaveResult>(ClientID);
|
||||
SaveResult->m_SaveID = RandomUuid();
|
||||
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;
|
||||
pController->Teams().SetSaving(Team, SaveResult);
|
||||
|
||||
auto Tmp = std::make_unique<CSqlTeamSave>(SaveResult);
|
||||
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_aClientName, this->Server()->ClientName(ClientID), sizeof(Tmp->m_aClientName));
|
||||
Tmp->m_aGeneratedCode[0] = '\0';
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
void RandomMap(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 GetSaves(int ClientID);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue