From 83fdfb28c41d23ca925df3708069fde58555a88c Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 11 Dec 2018 18:45:01 +0100 Subject: [PATCH] Avoid a glitch when the HUD cursor gets (re)displayed --- qcsrc/client/hud/hud.qc | 7 ++++++- qcsrc/client/view.qc | 9 +++++++++ qcsrc/client/view.qh | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index 0812ea4554..87ed2c4394 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -698,10 +698,15 @@ void HUD_Main() HUD_Panel_Draw(HUD_PANEL(QUICKMENU)); HUD_Panel_Draw(HUD_PANEL(SCOREBOARD)); - bool cursor_active_prev = cursor_active; + int cursor_active_prev = cursor_active; cursor_active = HUD_WouldShowCursor(); if (cursor_active_prev != cursor_active && autocvar_hud_cursormode) + { setcursormode(cursor_active); + // cursor inactive this frame, will be set to 1 the next frame + if (cursor_active) + cursor_active = -1; + } if (intermission == 2) HUD_Reset(); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 5172731ffb..e26f90894d 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1592,6 +1592,15 @@ void HUD_Mouse(entity player) return; } + if (cursor_active == -1) // starting to display the cursor + { + // since HUD_Mouse is called by CSQC_UpdateView before CSQC_InputEvent, + // in the first frame mousepos is the mouse position of the last time + // the cursor was displayed, thus we ignore it to avoid a glictch + cursor_active = 1; + return; + } + if(!autocvar_hud_cursormode) update_mousepos(); diff --git a/qcsrc/client/view.qh b/qcsrc/client/view.qh index 5bce2fe324..12fd6eb614 100644 --- a/qcsrc/client/view.qh +++ b/qcsrc/client/view.qh @@ -16,7 +16,7 @@ entity viewmodels[MAX_WEAPONSLOTS]; vector viewloc_mousepos; -bool cursor_active; +int cursor_active; int cursor_type; const int CURSOR_NORMAL = 0; const int CURSOR_MOVE = 1; -- 2.39.2