From f676a8b9ad37dee43a875bc32b611a7ffa1b9a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 1 Aug 2024 21:33:48 +0200 Subject: [PATCH 1/2] Add error message when trying to `/swap` on forced solo server Previously, swapping on forced solo servers was already impossible, as this would require two players to join the same team, so it would always fail with the error `Player is on a different team` (or earlier). The check `g_Config.m_SvTeam != 3` was never reached. Also, this check was not using the constant `SV_TEAM_FORCED_SOLO`. Now, an earlier check is added to show a more specific error message when trying to use `/swap` on a forced solo server. --- src/game/server/ddracechat.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index f778e1ab2..b46594e56 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -744,6 +744,15 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData) return; } + if(g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO) + { + pSelf->Console()->Print( + IConsole::OUTPUT_LEVEL_STANDARD, + "chatresp", + "Swap is not available on forced solo servers."); + return; + } + CGameTeams &Teams = pSelf->m_pController->Teams(); int Team = Teams.m_Core.Team(pResult->m_ClientId); @@ -804,7 +813,7 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData) } CPlayer *pSwapPlayer = pSelf->m_apPlayers[TargetClientId]; - if((Team == TEAM_FLOCK || Teams.TeamFlock(Team)) && g_Config.m_SvTeam != 3) + if(Team == TEAM_FLOCK || Teams.TeamFlock(Team)) { CCharacter *pChr = pPlayer->GetCharacter(); CCharacter *pSwapChr = pSwapPlayer->GetCharacter(); From 7930eb9b799e5c3961ac67f4191c4008123441bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 1 Aug 2024 21:33:48 +0200 Subject: [PATCH 2/2] Use `!=` instead of `<` to future-proof `sv_team` Assume that this branch should apply to all team modes except `SV_TEAM_FORCED_SOLO` also when new team modes would get added after `SV_TEAM_FORCED_SOLO` in the future, as the values will never be changed and there is no relation between the order of the numeric values and the behavior. --- src/game/server/teams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 30762fe8b..200e39741 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -172,7 +172,7 @@ void CGameTeams::OnCharacterStart(int ClientId) } } - if(g_Config.m_SvTeam < SV_TEAM_FORCED_SOLO && g_Config.m_SvMaxTeamSize != 2 && g_Config.m_SvPauseable) + if(g_Config.m_SvTeam != SV_TEAM_FORCED_SOLO && g_Config.m_SvMaxTeamSize != 2 && g_Config.m_SvPauseable) { for(int i = 0; i < MAX_CLIENTS; ++i) {