From 68b6b2405283f886b78d9c0ed8485d09eb1262a1 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 30 Oct 2021 21:45:24 +0200 Subject: [PATCH] moveplayer: fix / improve error handling and messages --- qcsrc/server/command/sv_cmd.qc | 14 ++++++++++---- qcsrc/server/scores_rules.qc | 5 +++++ qcsrc/server/scores_rules.qh | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 47e9f922a..4ed6e83ee 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -1043,7 +1043,7 @@ void GameCommand_moveplayer(int request, int argc) if (team_num == client.team) // already on the destination team { // keep the forcing undone - LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), "."); + LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), "^7."); continue; } else if (team_num == 0) // auto team @@ -1061,16 +1061,22 @@ void GameCommand_moveplayer(int request, int argc) int team_id = Team_TeamToIndex(team_num); if (team_id == -1) { - LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist."); + LOG_INFO("Can't move player to ", destination, " team because it doesn't exist."); TeamBalance_Destroy(balance); return; } - if (!TeamBalance_IsTeamAllowed(balance, team_id)) + if (!IsTeamAvailable(team_num)) { - LOG_INFOF("Sorry, can't move player to %s team if it doesn't exist.", destination); + LOG_INFO("Can't move player to ", destination, " team because it isn't available."); TeamBalance_Destroy(balance); return; } + if (!TeamBalance_IsTeamAllowed(balance, team_id)) + { + LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is not allowed to join the ", Team_ColoredFullName(team_num), "^7."); + TeamBalance_Destroy(balance); + continue; + } TeamBalance_Destroy(balance); // If so, lets continue and finally move the player diff --git a/qcsrc/server/scores_rules.qc b/qcsrc/server/scores_rules.qc index ac060dab5..2749db38e 100644 --- a/qcsrc/server/scores_rules.qc +++ b/qcsrc/server/scores_rules.qc @@ -9,6 +9,11 @@ int ScoreRules_teams; +bool IsTeamAvailable(int team_num) +{ + return boolean(ScoreRules_teams & Team_TeamToBit(team_num)); +} + int NumTeams(int teams) { return boolean(teams & BIT(0)) + boolean(teams & BIT(1)) + boolean(teams & BIT(2)) + boolean(teams & BIT(3)); diff --git a/qcsrc/server/scores_rules.qh b/qcsrc/server/scores_rules.qh index 9d1caf539..921864d26 100644 --- a/qcsrc/server/scores_rules.qh +++ b/qcsrc/server/scores_rules.qh @@ -1,5 +1,6 @@ #pragma once +bool IsTeamAvailable(int team_num); int NumTeams(int teams); int AvailableTeams(); void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled); -- 2.39.2