From 1da96e958217f87f41d20c0968d51856a801b538 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 7 Jun 2022 18:23:58 +0200 Subject: [PATCH] Fix ESC key not closing team selection if automatically opened by the server, scoreboard_team_selection spam, jump sometimes stuck. This change also allowed to get rid of a no longer needed workaround --- qcsrc/client/hud/panel/quickmenu.qc | 7 +------ qcsrc/client/hud/panel/radar.qc | 7 +------ qcsrc/client/hud/panel/scoreboard.qc | 14 +++++--------- qcsrc/client/hud/panel/scoreboard.qh | 1 - qcsrc/client/main.qc | 9 +++++++++ qcsrc/client/main.qh | 2 ++ 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/qcsrc/client/hud/panel/quickmenu.qc b/qcsrc/client/hud/panel/quickmenu.qc index 01a4a2cdb0..f274411ae5 100644 --- a/qcsrc/client/hud/panel/quickmenu.qc +++ b/qcsrc/client/hud/panel/quickmenu.qc @@ -193,12 +193,7 @@ bool QuickMenu_Open(string mode, string submenu, string file) mouseClicked = 0; hudShiftState = 0; - // we must unset the player's buttons, as they aren't released elsewhere - localcmd("-fire\n"); - localcmd("-fire2\n"); - localcmd("-use\n"); - localcmd("-hook\n"); - localcmd("-jump\n"); + Release_Common_Keys(); QuickMenu_TimeOut_Set(); return true; diff --git a/qcsrc/client/hud/panel/radar.qc b/qcsrc/client/hud/panel/radar.qc index cf395e7634..a5b17d75ee 100644 --- a/qcsrc/client/hud/panel/radar.qc +++ b/qcsrc/client/hud/panel/radar.qc @@ -40,12 +40,7 @@ void HUD_Radar_Show_Maximized(bool doshow, bool clickable) { hud_panel_radar_mouse = 1; - // we must unset the player's buttons, as they aren't released elsewhere - localcmd("-fire\n"); - localcmd("-fire2\n"); - localcmd("-use\n"); - localcmd("-hook\n"); - localcmd("-jump\n"); + Release_Common_Keys(); } } else if ( hud_panel_radar_mouse ) diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index a2921ac980..dfab7d61b7 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -173,7 +173,6 @@ void HUD_Scoreboard_UI_Disable() scoreboard_selected_panel = 0; scoreboard_selected_player = NULL; scoreboard_selected_team = NULL; - scoreboard_ui_disabled_time = time; } // mode: 0 normal, 1 team selection @@ -183,14 +182,11 @@ void Scoreboard_UI_Enable(int mode) { if (scoreboard_ui_enabled == 2 || !teamplay) return; - // Do not allow reopening the team selection for some time after it has been closed. - // It works around a bug caused by the server sending scoreboard_team_selection every frame - // until client selects a team and joins: scoreboard_team_selection gets executed even - // after client already joined - // For the record, with the menu dialog this workaround is not needed because it takes - // some time to fade away - if (time < scoreboard_ui_disabled_time + 0.5) - return; + + // release player's pressed keys as they aren't released elsewhere + // in particular jump needs to be released as it may open the team selection + // (when server detects jump has been pressed it sends the command to open the team selection) + Release_Common_Keys(); scoreboard_ui_enabled = 2; scoreboard_selected_panel = SB_PANEL_SCOREBOARD; } diff --git a/qcsrc/client/hud/panel/scoreboard.qh b/qcsrc/client/hud/panel/scoreboard.qh index 77f3245549..76a22d533d 100644 --- a/qcsrc/client/hud/panel/scoreboard.qh +++ b/qcsrc/client/hud/panel/scoreboard.qh @@ -26,7 +26,6 @@ bool Scoreboard_WouldDraw(); void Scoreboard_UI_Enable(int mode); int scoreboard_ui_enabled; -float scoreboard_ui_disabled_time; bool autocvar__scoreboard_team_selection; float HUD_Scoreboard_InputEvent(float bInputType, float nPrimary, float nSecondary); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 0e5b4b5e10..aa5e50038c 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -443,6 +443,15 @@ void PostInit() postinit = true; } +void Release_Common_Keys() +{ + localcmd("-fire\n"); + localcmd("-fire2\n"); + localcmd("-use\n"); + localcmd("-hook\n"); + localcmd("-jump\n"); +} + // CSQC_InputEvent : Used to perform actions based on any key pressed, key released and mouse on the client. // Return value should be 1 if CSQC handled the input, otherwise return 0 to have the input passed to the engine. // All keys are in ascii. diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 7be53f6dee..4d1271c419 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -115,6 +115,8 @@ string _getcommandkey(string text, string command, bool forcename); #define getcommandkey(cmd_name, command) _getcommandkey(cmd_name, command, false) #define getcommandkey_forcename(cmd_name, command) _getcommandkey(cmd_name, command, true) +void Release_Common_Keys(); + string vote_called_vote; bool ready_waiting; bool ready_waiting_for_me; -- 2.39.2