From c365c112b1918921fcd6d149d880a0183c5c1a56 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sat, 7 Dec 2024 12:19:01 -0600 Subject: [PATCH 01/12] SERVER: network velocity to CSQC --- source/server/main.qc | 3 ++- source/shared/shared_defs.qc | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/server/main.qc b/source/server/main.qc index d3e5b71..1b0b665 100644 --- a/source/server/main.qc +++ b/source/server/main.qc @@ -377,6 +377,7 @@ void() worldspawn = clientstat(STAT_VIEWZOOM, EV_FLOAT, viewzoom); clientstat(STAT_MAXHEALTH, EV_FLOAT, max_health); clientstat(STAT_PERKS, EV_FLOAT, perks); + clientstat(STAT_VELOCITY, EV_VECTOR, velocity); #endif // FTE @@ -581,4 +582,4 @@ void() EndFrame = if (cheats_have_been_activated == false && cvar("sv_cheats") == 1) { cheats_have_been_activated = true; } -}; \ No newline at end of file +}; diff --git a/source/shared/shared_defs.qc b/source/shared/shared_defs.qc index 3df9276..0e9ff4a 100644 --- a/source/shared/shared_defs.qc +++ b/source/shared/shared_defs.qc @@ -309,6 +309,10 @@ float map_compatibility_mode; #define STAT_MAXHEALTH 67 #define STAT_WEAPONSKIN 68 #define STAT_PERKS 69 +#define STAT_VELOCITY 70 +#define STAT_VELOCITY_X 70 +#define STAT_VELOCITY_Y 71 +#define STAT_VELOCITY_Z 72 .float playernum; float game_over; From 25c65eaf41706541d72aa96be5c82cee84a65e20 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sat, 7 Dec 2024 12:19:11 -0600 Subject: [PATCH 02/12] CLIENT: first pass at Draw_UPS() --- source/client/hud.qc | 31 +++++++++++++++++++++++++++++++ source/client/main.qc | 3 +++ 2 files changed, 34 insertions(+) diff --git a/source/client/hud.qc b/source/client/hud.qc index ef11368..79d7930 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1925,6 +1925,35 @@ void(float width, float height) HUD_RoundStopWatch = Draw_String([width - (getTextWidth(stopwatch, 12)) - 2, 16], stopwatch, [12, 12], [1, 1, 1], 1, 0); } +/******************* +* HUD UPS * +*******************/ + +void() Draw_UPS = +{ + static float lastupstime; + static float lastups; + + if (!cvar("show_speed")) + return; + + if ((time - lastupstime) >= 1.0 / 20) + { + vector vel = [ + getstatf(STAT_VELOCITY_X), + getstatf(STAT_VELOCITY_Y), + getstatf(STAT_VELOCITY_Z) + ]; + + lastups = vlen(vel); + lastupstime = time; + } + + string str = sprintf("%3.1f UPS", lastups); + vector pos = [cvar("show_speed_x"), cvar("show_speed_y")]; + Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); +}; + /******************* * HUD Draw * *******************/ @@ -1999,6 +2028,8 @@ void(float width, float height) HUD_Draw = HUD_Scores(); HUD_Achievements(width, height); + + Draw_UPS(); if (screenflash_duration > time) HUD_Screenflash(); diff --git a/source/client/main.qc b/source/client/main.qc index cee2149..fa7e9eb 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -175,6 +175,9 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = autocvar(in_rumbleenabled, 1); autocvar(in_aimassist, 0); + cvar_set("show_speed_x", ftos(32)); + cvar_set("show_speed_y", ftos(32)); + // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") platform_is_web = true; From 81b033318d9613e7c5238828ec00cae097fe5846 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 8 Dec 2024 08:24:45 -0600 Subject: [PATCH 03/12] SERVER: don't network velocity manually --- source/server/main.qc | 1 - source/shared/shared_defs.qc | 4 ---- 2 files changed, 5 deletions(-) diff --git a/source/server/main.qc b/source/server/main.qc index 1b0b665..5320874 100644 --- a/source/server/main.qc +++ b/source/server/main.qc @@ -377,7 +377,6 @@ void() worldspawn = clientstat(STAT_VIEWZOOM, EV_FLOAT, viewzoom); clientstat(STAT_MAXHEALTH, EV_FLOAT, max_health); clientstat(STAT_PERKS, EV_FLOAT, perks); - clientstat(STAT_VELOCITY, EV_VECTOR, velocity); #endif // FTE diff --git a/source/shared/shared_defs.qc b/source/shared/shared_defs.qc index 0e9ff4a..3df9276 100644 --- a/source/shared/shared_defs.qc +++ b/source/shared/shared_defs.qc @@ -309,10 +309,6 @@ float map_compatibility_mode; #define STAT_MAXHEALTH 67 #define STAT_WEAPONSKIN 68 #define STAT_PERKS 69 -#define STAT_VELOCITY 70 -#define STAT_VELOCITY_X 70 -#define STAT_VELOCITY_Y 71 -#define STAT_VELOCITY_Z 72 .float playernum; float game_over; From 167e85acf9cb0eac369006d70baff695129fed14 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 8 Dec 2024 08:24:56 -0600 Subject: [PATCH 04/12] CLIENT: HUD_PlayerDebugInfo() --- source/client/hud.qc | 34 +++++++++++++++++++++------------- source/client/main.qc | 8 ++++++-- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/source/client/hud.qc b/source/client/hud.qc index 79d7930..ca2fafe 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1926,32 +1926,40 @@ void(float width, float height) HUD_RoundStopWatch = } /******************* -* HUD UPS * +* HUD Debug Info * *******************/ -void() Draw_UPS = +// set from CSQC_Ent_Update +vector player_velocity; + +void(float width, float height) HUD_PlayerDebugInfo = { static float lastupstime; static float lastups; - if (!cvar("show_speed")) + if (!cvar("scr_playerdebuginfo")) return; if ((time - lastupstime) >= 1.0 / 20) { - vector vel = [ - getstatf(STAT_VELOCITY_X), - getstatf(STAT_VELOCITY_Y), - getstatf(STAT_VELOCITY_Z) - ]; - - lastups = vlen(vel); + lastups = vlen(player_velocity); lastupstime = time; } - string str = sprintf("%3.1f UPS", lastups); - vector pos = [cvar("show_speed_x"), cvar("show_speed_y")]; + string str = sprintf("speed: %3.1f qu/s", lastups); + vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")]; Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); + + if (cvar("scr_playerdebuginfo") >= 2) + { + pos.y += 16; + str = sprintf("angles: %v", getproperty(VF_ANGLES)); + Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); + + pos.y += 16; + str = sprintf("origin: %v", getproperty(VF_ORIGIN)); + Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); + } }; /******************* @@ -2029,7 +2037,7 @@ void(float width, float height) HUD_Draw = HUD_Achievements(width, height); - Draw_UPS(); + HUD_PlayerDebugInfo(width, height); if (screenflash_duration > time) HUD_Screenflash(); diff --git a/source/client/main.qc b/source/client/main.qc index fa7e9eb..e4a4b5d 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -175,8 +175,9 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = autocvar(in_rumbleenabled, 1); autocvar(in_aimassist, 0); - cvar_set("show_speed_x", ftos(32)); - cvar_set("show_speed_y", ftos(32)); + autocvar(scr_playerdebuginfo, 0); + autocvar(scr_playerdebuginfo_x, 48); + autocvar(scr_playerdebuginfo_y, 48); // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") @@ -432,6 +433,9 @@ noref void(float isnew) CSQC_Ent_Update = self.kills = readshort(); self.is_in_menu = readbyte(); + // set for HUD_PlayerDebugInfo + player_velocity = self.velocity; + RegisterPointChange(self.points - old_points, self.playernum); if (self.movetype == MOVETYPE_BOUNCE) From 1ae4e646bad879f05fce49b130cde636074ffce0 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 8 Dec 2024 20:02:22 -0600 Subject: [PATCH 05/12] CLIENT: change default playerdebuginfo pos to 64,64 --- source/client/main.qc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/client/main.qc b/source/client/main.qc index bd34050..d1e475c 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -176,8 +176,8 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = autocvar(in_aimassist, 0); autocvar(scr_playerdebuginfo, 0); - autocvar(scr_playerdebuginfo_x, 48); - autocvar(scr_playerdebuginfo_y, 48); + autocvar(scr_playerdebuginfo_x, 64); + autocvar(scr_playerdebuginfo_y, 64); // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") From a9356369acd5ff77da494aba1ef797229d3ca8b1 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 8 Dec 2024 20:13:23 -0600 Subject: [PATCH 06/12] CLIENT: HUD_PlayerDebugInfo: draw with capitals --- source/client/hud.qc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/client/hud.qc b/source/client/hud.qc index d56505c..2552d86 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1955,18 +1955,18 @@ void(float width, float height) HUD_PlayerDebugInfo = lastupstime = time; } - string str = sprintf("speed: %3.1f qu/s", lastups); + string str = sprintf("Speed: %3.1f qu/s", lastups); vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")]; Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); if (cvar("scr_playerdebuginfo") >= 2) { pos.y += 16; - str = sprintf("angles: %v", getproperty(VF_ANGLES)); + str = sprintf("Angles: %v", getproperty(VF_ANGLES)); Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); pos.y += 16; - str = sprintf("origin: %v", getproperty(VF_ORIGIN)); + str = sprintf("Origin: %v", getproperty(VF_ORIGIN)); Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); } }; From 35dc06686856638c05209217ab42a70793f63613 Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 8 Dec 2024 20:13:37 -0600 Subject: [PATCH 07/12] CLIENT: HUD_PlayerDebugInfo: add ultrawide offset --- source/client/hud.qc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/client/hud.qc b/source/client/hud.qc index 2552d86..17899c4 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1957,6 +1957,7 @@ void(float width, float height) HUD_PlayerDebugInfo = string str = sprintf("Speed: %3.1f qu/s", lastups); vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")]; + pos.x += GetUltraWideOffset(); Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); if (cvar("scr_playerdebuginfo") >= 2) From 9e96f938bc1c2e1c7ec5fde523fb49227b6c852e Mon Sep 17 00:00:00 2001 From: erysdren Date: Sun, 8 Dec 2024 20:14:09 -0600 Subject: [PATCH 08/12] CLIENT: change default playerdebuginfo y pos to 6 --- source/client/main.qc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/main.qc b/source/client/main.qc index d1e475c..9ede104 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -177,7 +177,7 @@ noref void(float apiver, string enginename, float enginever) CSQC_Init = autocvar(scr_playerdebuginfo, 0); autocvar(scr_playerdebuginfo_x, 64); - autocvar(scr_playerdebuginfo_y, 64); + autocvar(scr_playerdebuginfo_y, 6); // Runtime check if we're running this in WebASM/WebGL. if (cvar_string("sys_platform") == "Web") From 31282c700d4451aff8434eb3fbdc989386a1437d Mon Sep 17 00:00:00 2001 From: erysdren Date: Mon, 9 Dec 2024 19:50:04 -0600 Subject: [PATCH 09/12] CLIENT: hud.qc: make the readout all fancy and stuff --- source/client/hud.qc | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/source/client/hud.qc b/source/client/hud.qc index 17899c4..a710639 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1941,6 +1941,21 @@ void(float width, float height) HUD_RoundStopWatch = // set from CSQC_Ent_Update vector player_velocity; +// probably only need these right here +static void(vector pos, string label, vector v) Draw_Vector_Fancy = +{ + Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0); + Draw_String(pos + [32, 16], sprintf("X: %d", v.x), [12, 12], [1, 1, 1], 1, 0); + Draw_String(pos + [32, 32], sprintf("Y: %d", v.y), [12, 12], [1, 1, 1], 1, 0); + Draw_String(pos + [32, 48], sprintf("Z: %d", v.z), [12, 12], [1, 1, 1], 1, 0); +}; + +static void(vector pos, string label, float f, string suffix) Draw_Float_Fancy = +{ + Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0); + Draw_String(pos + [32, 16], sprintf("%d %s", f, suffix), [12, 12], [1, 1, 1], 1, 0); +}; + void(float width, float height) HUD_PlayerDebugInfo = { static float lastupstime; @@ -1955,20 +1970,15 @@ void(float width, float height) HUD_PlayerDebugInfo = lastupstime = time; } - string str = sprintf("Speed: %3.1f qu/s", lastups); vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")]; pos.x += GetUltraWideOffset(); - Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); + + Draw_Float_Fancy(pos, "Speed:", lastups, "qu/s"); if (cvar("scr_playerdebuginfo") >= 2) { - pos.y += 16; - str = sprintf("Angles: %v", getproperty(VF_ANGLES)); - Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); - - pos.y += 16; - str = sprintf("Origin: %v", getproperty(VF_ORIGIN)); - Draw_String(pos, str, [12, 12], [1, 1, 1], 1, 0); + Draw_Vector_Fancy(pos + [0, 36], "Angles:", getproperty(VF_ANGLES)); + Draw_Vector_Fancy(pos + [0, 106], "Origin:", getproperty(VF_ORIGIN)); } }; From 798e1b257ac9bd56ec66733efae81e66e34c28c0 Mon Sep 17 00:00:00 2001 From: erysdren Date: Mon, 9 Dec 2024 20:15:47 -0600 Subject: [PATCH 10/12] CLIENT: hud.qc: add a nice drawfill for a11y --- source/client/hud.qc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/client/hud.qc b/source/client/hud.qc index a710639..7f3d036 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1973,6 +1973,8 @@ void(float width, float height) HUD_PlayerDebugInfo = vector pos = [cvar("scr_playerdebuginfo_x"), cvar("scr_playerdebuginfo_y")]; pos.x += GetUltraWideOffset(); + drawfill(pos - [8, 8], [128, 192], [0, 0, 0], 0.75, 0); + Draw_Float_Fancy(pos, "Speed:", lastups, "qu/s"); if (cvar("scr_playerdebuginfo") >= 2) From eb8bd3456e18e5bb676d55bacc5ae8b63951d365 Mon Sep 17 00:00:00 2001 From: erysdren Date: Mon, 9 Dec 2024 20:36:28 -0600 Subject: [PATCH 11/12] CLIENT: move Draw_Fancy* functions into draw.qc --- source/client/draw.qc | 16 +++++++++++++++- source/client/hud.qc | 21 +++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/source/client/draw.qc b/source/client/draw.qc index 674a2eb..ff3c7b9 100644 --- a/source/client/draw.qc +++ b/source/client/draw.qc @@ -91,4 +91,18 @@ void(vector position, string text, vector size, vector rgb, float alpha, float d else x += (font_kerningamount[(chr - 33)] + 1) * (size_x/8); } -}; \ No newline at end of file +}; + +void(vector pos, string label, vector v) Draw_FancyVector = +{ + Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0); + Draw_String(pos + [32, 16], sprintf("X: %d", v.x), [12, 12], [1, 1, 1], 1, 0); + Draw_String(pos + [32, 32], sprintf("Y: %d", v.y), [12, 12], [1, 1, 1], 1, 0); + Draw_String(pos + [32, 48], sprintf("Z: %d", v.z), [12, 12], [1, 1, 1], 1, 0); +}; + +void(vector pos, string label, float f, string suffix) Draw_FancyFloat = +{ + Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0); + Draw_String(pos + [32, 16], sprintf("%d %s", f, suffix), [12, 12], [1, 1, 1], 1, 0); +}; diff --git a/source/client/hud.qc b/source/client/hud.qc index 7f3d036..bbc5eb3 100644 --- a/source/client/hud.qc +++ b/source/client/hud.qc @@ -1941,21 +1941,6 @@ void(float width, float height) HUD_RoundStopWatch = // set from CSQC_Ent_Update vector player_velocity; -// probably only need these right here -static void(vector pos, string label, vector v) Draw_Vector_Fancy = -{ - Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0); - Draw_String(pos + [32, 16], sprintf("X: %d", v.x), [12, 12], [1, 1, 1], 1, 0); - Draw_String(pos + [32, 32], sprintf("Y: %d", v.y), [12, 12], [1, 1, 1], 1, 0); - Draw_String(pos + [32, 48], sprintf("Z: %d", v.z), [12, 12], [1, 1, 1], 1, 0); -}; - -static void(vector pos, string label, float f, string suffix) Draw_Float_Fancy = -{ - Draw_String(pos, label, [12, 12], [1, 1, 0], 1, 0); - Draw_String(pos + [32, 16], sprintf("%d %s", f, suffix), [12, 12], [1, 1, 1], 1, 0); -}; - void(float width, float height) HUD_PlayerDebugInfo = { static float lastupstime; @@ -1975,12 +1960,12 @@ void(float width, float height) HUD_PlayerDebugInfo = drawfill(pos - [8, 8], [128, 192], [0, 0, 0], 0.75, 0); - Draw_Float_Fancy(pos, "Speed:", lastups, "qu/s"); + Draw_FancyFloat(pos, "Speed:", lastups, "qu/s"); if (cvar("scr_playerdebuginfo") >= 2) { - Draw_Vector_Fancy(pos + [0, 36], "Angles:", getproperty(VF_ANGLES)); - Draw_Vector_Fancy(pos + [0, 106], "Origin:", getproperty(VF_ORIGIN)); + Draw_FancyVector(pos + [0, 36], "Angles:", getproperty(VF_ANGLES)); + Draw_FancyVector(pos + [0, 106], "Origin:", getproperty(VF_ORIGIN)); } }; From c1c726acd63d981fb6efa6d1324f622297221a32 Mon Sep 17 00:00:00 2001 From: erysdren Date: Mon, 9 Dec 2024 20:38:05 -0600 Subject: [PATCH 12/12] SERVER: undo added newline, sorry --- source/server/main.qc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/server/main.qc b/source/server/main.qc index 79aed45..579b994 100644 --- a/source/server/main.qc +++ b/source/server/main.qc @@ -581,4 +581,4 @@ void() EndFrame = if (cheats_have_been_activated == false && cvar("sv_cheats") == 1) { cheats_have_been_activated = true; } -}; +}; \ No newline at end of file