From 926794d19c4c45de337dbc12326a73544d084aa0 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Fri, 14 Jun 2024 20:42:55 +1000 Subject: [PATCH] teamplay: display translated notifications for typical failures or state changes Fixes some uses of NOTIF_ONE where it should have been NOTIF_ONE_ONLY. --- notifications.cfg | 8 ++++++++ qcsrc/common/notifications/all.inc | 13 +++++++++++-- qcsrc/server/command/cmd.qc | 12 ++++++++---- qcsrc/server/command/sv_cmd.qc | 4 ++-- qcsrc/server/teamplay.qc | 14 ++++++++------ 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/notifications.cfg b/notifications.cfg index b1c203976..ee486bd42 100644 --- a/notifications.cfg +++ b/notifications.cfg @@ -289,7 +289,11 @@ seta notification_INFO_SUPERWEAPON_PICKUP "1" "0 = off, 1 = print to console, 2 seta notification_INFO_SURVIVAL_HUNTER_WIN "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" seta notification_INFO_SURVIVAL_SURVIVOR_WIN "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" seta notification_INFO_TEAMCHANGE_LARGERTEAM "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" +seta notification_INFO_TEAMCHANGE_LOCKED "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" seta notification_INFO_TEAMCHANGE_NOTALLOWED "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" +seta notification_INFO_TEAMCHANGE_SAME "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" +seta notification_INFO_TEAMS_LOCKED "2" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" +seta notification_INFO_TEAMS_UNLOCKED "2" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" seta notification_INFO_VERSION_BETA "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" seta notification_INFO_VERSION_OLD "2" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" seta notification_INFO_VERSION_OUTDATED "2" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)" @@ -558,7 +562,11 @@ seta notification_CENTER_SURVIVAL_HUNTER_WIN "1" "0 = off, 1 = centerprint" seta notification_CENTER_SURVIVAL_SURVIVOR "1" "0 = off, 1 = centerprint" seta notification_CENTER_SURVIVAL_SURVIVOR_WIN "1" "0 = off, 1 = centerprint" seta notification_CENTER_TEAMCHANGE_AUTO "1" "0 = off, 1 = centerprint" +seta notification_CENTER_TEAMCHANGE_LARGERTEAM "1" "0 = off, 1 = centerprint" +seta notification_CENTER_TEAMCHANGE_LOCKED "1" "0 = off, 1 = centerprint" +seta notification_CENTER_TEAMCHANGE_NOTALLOWED "1" "0 = off, 1 = centerprint" seta notification_CENTER_TEAMCHANGE "1" "0 = off, 1 = centerprint" +seta notification_CENTER_TEAMCHANGE_SAME "1" "0 = off, 1 = centerprint" seta notification_CENTER_TEAMCHANGE_SPECTATE "1" "0 = off, 1 = centerprint" seta notification_CENTER_TEAMCHANGE_SUICIDE "1" "0 = off, 1 = centerprint" seta notification_CENTER_TIMEOUT_BEGINNING "1" "0 = off, 1 = centerprint" diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 8e9a1ced6..23cf5e3e7 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -456,8 +456,13 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != MSG_INFO_NOTIF(SURVIVAL_HUNTER_WIN, N_CONSOLE, 0, 0, "", "", "", _("^K1Hunters^BG win the round"), "") MSG_INFO_NOTIF(SURVIVAL_SURVIVOR_WIN, N_CONSOLE, 0, 0, "", "", "", _("^F1Survivors^BG win the round"), "") - MSG_INFO_NOTIF(TEAMCHANGE_LARGERTEAM, N_CONSOLE, 0, 0, "", "", "", _("^BGYou cannot change to a larger team"), "") - MSG_INFO_NOTIF(TEAMCHANGE_NOTALLOWED, N_CONSOLE, 0, 0, "", "", "", _("^BGYou are not allowed to change teams"), "") + MSG_INFO_NOTIF(TEAMCHANGE_LARGERTEAM, N_CONSOLE, 0, 0, "", "", "", _("^K2You're not allowed to join a larger team!"), "") + MSG_INFO_NOTIF(TEAMCHANGE_NOTALLOWED, N_CONSOLE, 0, 0, "", "", "", _("^K2You're not allowed to change teams!"), "") + MSG_INFO_NOTIF(TEAMCHANGE_LOCKED, N_CONSOLE, 0, 0, "", "", "", _("^K2Teams are locked, you can't join or change teams until they're unlocked or the map changes."), "") + MSG_INFO_NOTIF(TEAMCHANGE_SAME, N_CONSOLE, 0, 0, "", "", "", _("^K2You're already on that team!"), "") + + MSG_INFO_NOTIF(TEAMS_LOCKED, N_CHATCON, 0, 0, "", "", "", _("^F4The teams are now locked."), "") + MSG_INFO_NOTIF(TEAMS_UNLOCKED, N_CHATCON, 0, 0, "", "", "", _("^F1The teams are now unlocked."), "") MSG_INFO_NOTIF(VERSION_BETA, N_CONSOLE, 2, 0, "s1 s2", "", "", _("^F4NOTE: ^BGThe server is running ^F1Xonotic %s (beta)^BG, you have ^F2Xonotic %s"), "") MSG_INFO_NOTIF(VERSION_OLD, N_CHATCON, 2, 0, "s1 s2", "", "", _("^F4NOTE: ^BGThe server is running ^F1Xonotic %s^BG, you have ^F2Xonotic %s"), "") @@ -808,6 +813,10 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != MSG_CENTER_NOTIF(TEAMCHANGE_AUTO, N_ENABLE, 0, 1, "", CPID_TEAMCHANGE, "1 f1", _("^K1Changing team in ^COUNT"), "") MSG_CENTER_NOTIF(TEAMCHANGE_SPECTATE, N_ENABLE, 0, 1, "", CPID_TEAMCHANGE, "1 f1", _("^K1Spectating in ^COUNT"), "") MSG_CENTER_NOTIF(TEAMCHANGE_SUICIDE, N_ENABLE, 0, 1, "", CPID_TEAMCHANGE, "1 f1", _("^K1Suicide in ^COUNT"), "") + MSG_CENTER_NOTIF(TEAMCHANGE_LARGERTEAM, N_ENABLE, 0, 0, "", CPID_PREVENT_JOIN, "0 0", _("^K2You're not allowed to join a larger team!"), "") + MSG_CENTER_NOTIF(TEAMCHANGE_NOTALLOWED, N_ENABLE, 0, 0, "", CPID_PREVENT_JOIN, "0 0", _("^K2You're not allowed to change teams!"), "") + MSG_CENTER_NOTIF(TEAMCHANGE_LOCKED, N_ENABLE, 0, 0, "", CPID_PREVENT_JOIN, "0 0", _("^K2Teams are locked, you can't join or change teams until they're unlocked or the map changes."), "") + MSG_CENTER_NOTIF(TEAMCHANGE_SAME, N_ENABLE, 0, 0, "", CPID_PREVENT_JOIN, "0 0", _("^K2You're already on that team!"), "") MSG_CENTER_NOTIF(TIMEOUT_BEGINNING, N_ENABLE, 0, 1, "", CPID_TIMEOUT, "1 f1", _("^F4Timeout begins in ^COUNT"), "") MSG_CENTER_NOTIF(TIMEOUT_ENDING, N_ENABLE, 0, 1, "", CPID_TIMEIN, "1 f1", _("^F4Timeout ends in ^COUNT"), "") diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 41e75d5a4..aaf1c1106 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -550,7 +550,8 @@ void ClientCommand_selectteam(entity caller, int request, int argc) } if (lockteams) { - sprint(caller, "^7The game has already begun, you must wait until the next map to be able to join a team.\n"); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_INFO, INFO_TEAMCHANGE_LOCKED); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CENTER_TEAMCHANGE_LOCKED); return; } @@ -559,12 +560,14 @@ void ClientCommand_selectteam(entity caller, int request, int argc) return; if (caller.team == team_num && team_num && !IS_DEAD(caller)) { - sprint(caller, "^7You already are on that team.\n"); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_INFO, INFO_TEAMCHANGE_SAME); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CENTER_TEAMCHANGE_SAME); return; } if (CS(caller).wasplayer && autocvar_g_changeteam_banned) { - sprint(caller, "^1You cannot change team, forbidden by the server.\n"); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_INFO, INFO_TEAMCHANGE_NOTALLOWED); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CENTER_TEAMCHANGE_NOTALLOWED); return; } if (team_num && autocvar_g_balance_teams_prevent_imbalance && !warmup_stage) @@ -574,7 +577,8 @@ void ClientCommand_selectteam(entity caller, int request, int argc) if ((Team_IndexToBit(Team_TeamToIndex(team_num)) & TeamBalance_FindBestTeams(balance, caller, false)) == 0) { - Send_Notification(NOTIF_ONE, caller, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM); + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CENTER_TEAMCHANGE_LARGERTEAM); TeamBalance_Destroy(balance); return; } diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index bb6074517..23c0df96f 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -969,7 +969,7 @@ void GameCommand_lockteams(int request) if (teamplay) { lockteams = 1; - bprint("^1The teams are now locked.\n"); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_TEAMS_LOCKED); } else { @@ -1645,7 +1645,7 @@ void GameCommand_unlockteams(int request) if (teamplay) { lockteams = 0; - bprint("^1The teams are now unlocked.\n"); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_TEAMS_UNLOCKED); } else { diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 4558eb723..f9da5a2d4 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -309,11 +309,12 @@ void Player_SetTeamIndexChecked(entity player, int team_index) { return; } - if ((autocvar_g_campaign) || (autocvar_g_changeteam_banned && - CS(player).wasplayer)) + + // TODO: this is in ClientCommand_selectteam(), shouldn't be necessary to have it here too (refactor SV_ChangeTeam ?) + if ((autocvar_g_campaign) || (autocvar_g_changeteam_banned && CS(player).wasplayer)) { - Send_Notification(NOTIF_ONE, player, MSG_INFO, - INFO_TEAMCHANGE_NOTALLOWED); + Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_TEAMCHANGE_NOTALLOWED); + Send_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CENTER_TEAMCHANGE_NOTALLOWED); return; } entity balance = TeamBalance_CheckAllowedTeams(player); @@ -334,14 +335,15 @@ void Player_SetTeamIndexChecked(entity player, int team_index) team_index = 1; } + // TODO: this is in ClientCommand_selectteam(), shouldn't be necessary to have it here too (refactor SV_ChangeTeam ?) if (autocvar_g_balance_teams_prevent_imbalance && !warmup_stage) { TeamBalance_GetTeamCounts(balance, player); if ((Team_IndexToBit(team_index) & TeamBalance_FindBestTeams(balance, player, false)) == 0) { - Send_Notification(NOTIF_ONE, player, MSG_INFO, - INFO_TEAMCHANGE_LARGERTEAM); + Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM); + Send_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CENTER_TEAMCHANGE_LARGERTEAM); TeamBalance_Destroy(balance); return; } -- 2.39.2