Merge pull request #8227 from Zwelf/pr-disable-practice-while-saving

Disallow activating /practice while save is in progress and improve messaging for when `/save`/`/load` command does nothing
This commit is contained in:
Dennis Felsing 2024-04-18 01:53:19 +00:00 committed by GitHub
commit da09087416
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -644,6 +644,15 @@ void CGameContext::ConPractice(IConsole::IResult *pResult, void *pUserData)
return;
}
if(Teams.GetSaving(Team))
{
pSelf->Console()->Print(
IConsole::OUTPUT_LEVEL_STANDARD,
"chatresp",
"Practice mode can't be enabled while team save or load is in progress");
return;
}
if(Teams.IsPractice(Team))
{
pSelf->Console()->Print(

View file

@ -288,10 +288,17 @@ void CScore::SaveTeam(int ClientId, const char *pCode, const char *pServer)
return;
auto *pController = GameServer()->m_pController;
int Team = pController->Teams().m_Core.Team(ClientId);
char aBuf[512];
if(pController->Teams().GetSaving(Team))
{
GameServer()->SendChatTarget(ClientId, "Team save already in progress");
return;
}
if(pController->Teams().IsPractice(Team))
{
GameServer()->SendChatTarget(ClientId, "Team save disabled for teams in practice mode");
return;
}
auto SaveResult = std::make_shared<CScoreSaveResult>(ClientId);
SaveResult->m_SaveId = RandomUuid();
@ -308,7 +315,6 @@ void CScore::SaveTeam(int ClientId, const char *pCode, const char *pServer)
Tmp->m_aGeneratedCode[0] = '\0';
GeneratePassphrase(Tmp->m_aGeneratedCode, sizeof(Tmp->m_aGeneratedCode));
char aBuf[512];
if(Tmp->m_aCode[0] == '\0')
{
str_format(aBuf,
@ -336,7 +342,10 @@ void CScore::LoadTeam(const char *pCode, int ClientId)
auto *pController = GameServer()->m_pController;
int Team = pController->Teams().m_Core.Team(ClientId);
if(pController->Teams().GetSaving(Team))
{
GameServer()->SendChatTarget(ClientId, "Team load already in progress");
return;
}
if(Team < TEAM_FLOCK || Team >= MAX_CLIENTS || (g_Config.m_SvTeam != SV_TEAM_FORCED_SOLO && Team == TEAM_FLOCK))
{
GameServer()->SendChatTarget(ClientId, "You have to be in a team (from 1-63)");
@ -352,6 +361,11 @@ void CScore::LoadTeam(const char *pCode, int ClientId)
GameServer()->SendChatTarget(ClientId, "Team can't be loaded while in team 0 mode");
return;
}
if(pController->Teams().IsPractice(Team))
{
GameServer()->SendChatTarget(ClientId, "Team can't be loaded while practice is enabled");
return;
}
auto SaveResult = std::make_shared<CScoreSaveResult>(ClientId);
SaveResult->m_Status = CScoreSaveResult::LOAD_FAILED;
pController->Teams().SetSaving(Team, SaveResult);