From 25e171d872446ac91e1e9f9a4354ea2086d49119 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 6 Sep 2016 19:09:00 +0200 Subject: [PATCH] Remove HUD_Minigame_Showpanels() and minigame_isactive(): it reduces function calls by 3 * 24 (number of panels) every frame during normal gameplay --- qcsrc/client/hud/hud.qc | 5 ++--- qcsrc/client/view.qc | 2 +- qcsrc/common/minigames/cl_minigames.qh | 8 +------- qcsrc/common/minigames/cl_minigames_hud.qc | 9 ++------- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 8ac6a4d99..c89fe08bc 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -4,6 +4,7 @@ #include "hud_config.qh" #include "../mapvoting.qh" #include "../teamradar.qh" +#include #include #include #include @@ -409,8 +410,6 @@ void HUD_Vehicle() } } -bool HUD_Minigame_Showpanels(); - void HUD_Panel_Draw(entity panent) { panel = panent; @@ -425,7 +424,7 @@ void HUD_Panel_Draw(entity panent) } bool draw_allowed = false; - if (HUD_Minigame_Showpanels()) + if (active_minigame && HUD_MinigameMenu_IsOpened()) { if (panel.panel_showflags & PANEL_SHOW_MINIGAME) draw_allowed = true; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index c375ccaa4..c272e3217 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -2249,7 +2249,7 @@ void CSQC_UpdateView(entity this, float w, float h) if(autocvar__hud_configure) HUD_Panel_Mouse(); - else if ( HUD_MinigameMenu_IsOpened() || minigame_isactive() ) + else if (HUD_MinigameMenu_IsOpened() || active_minigame) HUD_Minigame_Mouse(); else if(QuickMenu_IsOpened()) QuickMenu_Mouse(); diff --git a/qcsrc/common/minigames/cl_minigames.qh b/qcsrc/common/minigames/cl_minigames.qh index 602c79735..a0f6195d1 100644 --- a/qcsrc/common/minigames/cl_minigames.qh +++ b/qcsrc/common/minigames/cl_minigames.qh @@ -84,12 +84,6 @@ entity active_minigame; // minigame_player representing this client entity minigame_self; -// Whethere there's an active minigame -float minigame_isactive() -{ - return active_minigame != NULL; -} - // Execute a minigame command #define minigame_cmd(...) minigame_cmd_workaround(0,__VA_ARGS__) void minigame_cmd_workaround(float dummy, string...cmdargc); @@ -100,7 +94,7 @@ void minigame_prompt(); float HUD_MinigameMenu_IsOpened(); void HUD_MinigameMenu_Close(entity this, entity actor, entity trigger); -float HUD_Minigame_Showpanels(); + // Adds a game-specific entry to the menu void HUD_MinigameMenu_CustomEntry(entity parent, string message, string event_arg); diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index a359831df..1a6d4ff52 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -575,7 +575,7 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary { mousepos_x = nPrimary; mousepos_y = nSecondary; - if ( minigame_isactive() && HUD_mouse_over(HUD_PANEL(MINIGAME_BOARD)) ) + if ( active_minigame && HUD_mouse_over(HUD_PANEL(MINIGAME_BOARD)) ) active_minigame.minigame_event(active_minigame,"mouse_moved",mousepos); return true; @@ -607,7 +607,7 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary return false; } - if ( minigame_isactive() && ( bInputType == 0 || bInputType == 1 ) ) + if ( active_minigame && ( bInputType == 0 || bInputType == 1 ) ) { string device = ""; string action = bInputType == 0 ? "pressed" : "released"; @@ -690,8 +690,3 @@ void HUD_Minigame_Mouse() draw_cursor_normal(mousepos, '1 1 1', panel_fg_alpha); } - -bool HUD_Minigame_Showpanels() -{ - return (HUD_MinigameMenu_IsOpened() && minigame_isactive()); -} -- 2.39.2