From 7c94b26fc83348f1a9540028ce8407db1a6c6b11 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Wed, 28 Dec 2022 16:50:29 -0800 Subject: [PATCH] Client: Use the new Crosshair drawing functions to help with cl_thirdperson and remove obsolete routines. --- manifest.fmf | 24 ++++++------- src/server/client.qc | 76 --------------------------------------- src/server/progs.src | 2 -- src/server/spectator.qc | 28 --------------- src/shared/fx_blood.qc | 4 +-- src/shared/player.qc | 25 ------------- src/shared/w_crossbow.qc | 24 ++----------- src/shared/w_egon.qc | 5 ++- src/shared/w_gauss.qc | 14 +------- src/shared/w_glock.qc | 13 +------ src/shared/w_hornetgun.qc | 14 +------- src/shared/w_mp5.qc | 14 +------- src/shared/w_python.qc | 25 ++----------- src/shared/w_rpg.qc | 25 ++----------- src/shared/w_shotgun.qc | 4 +-- 15 files changed, 27 insertions(+), 270 deletions(-) delete mode 100644 src/server/client.qc mode change 100755 => 100644 src/server/progs.src delete mode 100644 src/server/spectator.qc diff --git a/manifest.fmf b/manifest.fmf index c692fa4..bbd9ab7 100644 --- a/manifest.fmf +++ b/manifest.fmf @@ -1,13 +1,13 @@ -FTEMANIFEST 1 -GAME valve -NAME "Half-Life" -BASEGAME platform +FTEMANIFEST 1 +GAME valve +NAME "Half-Life" +BASEGAME platform BASEGAME valve - -// you don't really want to change these -RTCBROKER master.frag-net.com:27950 -PROTOCOLNAME "FreeHL" -MAINCONFIG game.cfg -DOWNLOADSURL "http://www.frag-net.com/dl/packages" - --exec platform_default.cfg + +// you don't really want to change these +RTCBROKER master.frag-net.com:27950 +PROTOCOLNAME "Nuclide" +MAINCONFIG game.cfg +DOWNLOADSURL "http://www.frag-net.com/dl/packages" + +-exec platform_default.cfg diff --git a/src/server/client.qc b/src/server/client.qc deleted file mode 100644 index 543a71c..0000000 --- a/src/server/client.qc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2016-2020 Marco Cawthorne - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* called every input frame */ -void -Game_RunClientCommand(void) -{ - player pl = (player)self; - pl.Physics_Run(); -} - -/* custom chat packet */ -void -SV_SendChat(entity sender, string msg, entity eEnt, float fType) -{ - WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); - WriteByte(MSG_MULTICAST, fType == 0 ? EV_CHAT:EV_CHAT_TEAM); - WriteByte(MSG_MULTICAST, num_for_edict(sender) - 1); - WriteByte(MSG_MULTICAST, sender.team); - WriteString(MSG_MULTICAST, msg); - - if (eEnt) { - msg_entity = eEnt; - multicast([0,0,0], MULTICAST_ONE); - } else { - multicast([0,0,0], MULTICAST_ALL); - } - - localcmd(sprintf("echo [SERVER] %s: %s\n", sender.netname, msg)); -} - -/* client cmd overrides happen here */ -void -Game_ParseClientCommand(string cmd) -{ - tokenize(cmd); - - if (argv(1) == "timeleft") { - string msg; - string timestring; - float timeleft; - timeleft = cvar("timelimit") - (time / 60); - timestring = Util_TimeToString(timeleft); - msg = sprintf("we have %s minutes remaining", timestring); - bprint(PRINT_CHAT, msg); - return; - } - - if (argv(0) == "say") { - SV_SendChat(self, argv(1), world, 0); - return; - } else if (argv(0) == "say_team") { - entity a; - for (a = world; (a = find(a, ::classname, "player"));) { - if (a.team == self.team) { - SV_SendChat(self, argv(1), a, 1); - } - } - return; - } - - clientcommand(self, cmd); -} diff --git a/src/server/progs.src b/src/server/progs.src old mode 100755 new mode 100644 index 95c403b..6e48f3e --- a/src/server/progs.src +++ b/src/server/progs.src @@ -55,7 +55,6 @@ monster_turret.qc monster_zombie.qc player.qc -spectator.qc items.qc item_longjump.qc item_suit.qc @@ -75,7 +74,6 @@ ammo.qc gamerules.qc gamerules_singleplayer.qc gamerules_multiplayer.qc -client.qc server.qc ../../../base/src/server/damage.qc flashlight.qc diff --git a/src/server/spectator.qc b/src/server/spectator.qc deleted file mode 100644 index de8d29f..0000000 --- a/src/server/spectator.qc +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2016-2020 Marco Cawthorne - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -void Game_SpectatorThink(void) -{ - -} -void Game_SpectatorConnect(void) -{ - -} -void Game_SpectatorDisconnect(void) -{ - -} diff --git a/src/shared/fx_blood.qc b/src/shared/fx_blood.qc index 1e70a56..0d44912 100644 --- a/src/shared/fx_blood.qc +++ b/src/shared/fx_blood.qc @@ -45,7 +45,7 @@ FX_Blood(vector pos, vector color) #else static void Blood_Touch(void) { - if (self.think != Util_Destroy) { + if (self.think != NSEntity::Destroy) { if (serverkeyfloat("*bspversion") == BSPVER_HL) Decals_Place(self.origin, sprintf("{blood%d", floor(random(1,9)))); else { @@ -54,7 +54,7 @@ FX_Blood(vector pos, vector color) } } - self.think = Util_Destroy; + self.think = NSEntity::Destroy; self.nextthink = time + 5.0f; } diff --git a/src/shared/player.qc b/src/shared/player.qc index 29a1258..366abab 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -187,31 +187,6 @@ string Weapons_GetPlayermodel(player, int); void player::UpdatePlayerAttachments(bool visible) { - /* draw the flashlight */ - if (gflags & GF_FLASHLIGHT) { - vector src; - vector ang; - - if (entnum != player_localentnum) { - src = origin + view_ofs; - ang = v_angle; - } else { - src = pSeat->m_vecPredictedOrigin + [0,0,-8]; - ang = view_angles; - } - - makevectors(ang); - traceline(src, src + (v_forward * 8096), MOVE_NORMAL, this); - - if (serverkeyfloat("*bspversion") == BSPVER_HL) { - dynamiclight_add(trace_endpos + (v_forward * -2), 128, [1,1,1]); - } else { - float p = dynamiclight_add(src, 512, [1,1,1], 0, "textures/flashlight"); - dynamiclight_set(p, LFIELD_ANGLES, ang); - dynamiclight_set(p, LFIELD_FLAGS, 3); - } - } - /* FIXME: this needs to be incorporated and simplified, now that we can handle it all in-class */ if (!visible) return; diff --git a/src/shared/w_crossbow.qc b/src/shared/w_crossbow.qc index ebc283e..d2d72c2 100644 --- a/src/shared/w_crossbow.qc +++ b/src/shared/w_crossbow.qc @@ -349,29 +349,9 @@ w_crossbow_crosshair(player pl) vector aicon_pos; if (pl.viewzoom == 1) { - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [72/128,0], - [0.1875, 0.1875], - [1,1,1], - 1, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [24,24], [72/128,0], [0.1875, 0.1875]); } else { - cross_pos = g_hudmins + (g_hudres / 2) + [-52,-8]; - drawsubpic( - cross_pos, - [104,16], - g_cross_spr, - [24/128,96/128], - [104/128, 16/128], - [1,1,1], - 1, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [104,16], [24/128,96/128], [104/128, 16/128]); } HUD_DrawAmmo1(); diff --git a/src/shared/w_egon.qc b/src/shared/w_egon.qc index d8879dc..f8bb183 100644 --- a/src/shared/w_egon.qc +++ b/src/shared/w_egon.qc @@ -269,9 +269,8 @@ w_egon_postdraw(player pl, int thirdperson) void w_egon_crosshair(player pl) { #ifdef CLIENT - static vector cross_pos; - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; - drawsubpic(cross_pos, [24,24], g_cross_spr, [72/128,48/128], [0.1875, 0.1875], [1,1,1], 1, DRAWFLAG_NORMAL); + Cross_DrawSub(g_cross_spr, [24,24], [72/128,48/128], [0.1875, 0.1875]); + HUD_DrawAmmo2(); vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; drawsubpic(aicon_pos, [24,24], g_hud7_spr, [0,96/128], [24/256, 24/128], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE); diff --git a/src/shared/w_gauss.qc b/src/shared/w_gauss.qc index 502bc64..d9f0079 100644 --- a/src/shared/w_gauss.qc +++ b/src/shared/w_gauss.qc @@ -327,23 +327,11 @@ void w_gauss_secondary(player pl) void w_gauss_crosshair(player pl) { #ifdef CLIENT - vector cross_pos; vector aicon_pos; + Cross_DrawSub(g_cross_spr, [24,24], [48/128,48/128], [0.1875, 0.1875]); - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [48/128,48/128], - [0.1875, 0.1875], - [1,1,1], - 1, - DRAWFLAG_NORMAL - ); - drawsubpic( aicon_pos, [24,24], diff --git a/src/shared/w_glock.qc b/src/shared/w_glock.qc index eec5825..55255f2 100644 --- a/src/shared/w_glock.qc +++ b/src/shared/w_glock.qc @@ -327,22 +327,11 @@ void w_glock_hud(player pl) { #ifdef CLIENT - vector cross_pos; vector aicon_pos; - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [0.1875,0], - [0.1875, 0.1875], - [1,1,1], - 1.0f, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [24,24], [0.1875,0], [0.1875, 0.1875]); HUD_DrawAmmo1(); HUD_DrawAmmo2(); diff --git a/src/shared/w_hornetgun.qc b/src/shared/w_hornetgun.qc index 33357c9..10af31e 100644 --- a/src/shared/w_hornetgun.qc +++ b/src/shared/w_hornetgun.qc @@ -225,23 +225,11 @@ void w_hornetgun_crosshair(player pl) { #ifdef CLIENT - vector cross_pos; vector aicon_pos; - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; + Cross_DrawSub(g_cross_spr, [24,24], [72/128,24/128], [0.1875, 0.1875]); aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [72/128,24/128], - [0.1875, 0.1875], - [1,1,1], - 1.0f, - DRAWFLAG_NORMAL - ); - HUD_DrawAmmo2(); drawsubpic( diff --git a/src/shared/w_mp5.qc b/src/shared/w_mp5.qc index 10116a7..c7db3ba 100644 --- a/src/shared/w_mp5.qc +++ b/src/shared/w_mp5.qc @@ -340,21 +340,9 @@ void w_mp5_crosshair(player pl) { #ifdef CLIENT - vector cross_pos; vector aicon_pos; - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; - - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [0,48/128], - [0.1875, 0.1875], - [1,1,1], - 1.0f, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [24,24], [0,48/128], [0.1875, 0.1875]); HUD_DrawAmmo1(); HUD_DrawAmmo2(); diff --git a/src/shared/w_python.qc b/src/shared/w_python.qc index e1a33a2..94b9e58 100644 --- a/src/shared/w_python.qc +++ b/src/shared/w_python.qc @@ -265,33 +265,12 @@ void w_python_crosshair(player pl) { #ifdef CLIENT - vector cross_pos; vector aicon_pos; - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; - if (pl.viewzoom == 1) { - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [48/128,0], - [0.1875, 0.1875], - [1,1,1], - 1, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [24,24], [48/128,0], [0.1875, 0.1875]); } else { - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [96/128,0], - [0.1875, 0.1875], - [1,1,1], - 1, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [24,24], [96/128,0], [0.1875, 0.1875]); } HUD_DrawAmmo1(); diff --git a/src/shared/w_rpg.qc b/src/shared/w_rpg.qc index 558bd52..8051bfa 100644 --- a/src/shared/w_rpg.qc +++ b/src/shared/w_rpg.qc @@ -279,7 +279,6 @@ void w_rpg_hudpic(player pl, int selected, vector pos, float a) void w_rpg_hud(player pl) { #ifdef CLIENT - vector cross_pos; vector laser_pos; vector aicon_pos; @@ -294,7 +293,6 @@ void w_rpg_hud(player pl) jitter[0] = (random(0,2) - 2) * (1 - trace_fraction); jitter[1] = (random(0,2) - 2) * (1 - trace_fraction); laser_pos = g_hudmins + (g_hudres / 2) + ([-lerp,-lerp] / 2); - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; drawsubpic( laser_pos + jitter, @@ -307,28 +305,9 @@ void w_rpg_hud(player pl) DRAWFLAG_ADDITIVE ); - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [24/128,48/128], - [0.1875, 0.1875], - [1,1,1], - 1.0f, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [24,24], [24/128,48/128], [0.1875, 0.1875]); } else { - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [24/128,48/128], - [0.1875, 0.1875], - [1,1,1], - 1.0f, - DRAWFLAG_NORMAL - ); + Cross_DrawSub(g_cross_spr, [24,24], [24/128,48/128], [0.1875, 0.1875]); } /* ammo counters */ diff --git a/src/shared/w_shotgun.qc b/src/shared/w_shotgun.qc index 138c404..a9d82d2 100644 --- a/src/shared/w_shotgun.qc +++ b/src/shared/w_shotgun.qc @@ -373,9 +373,7 @@ void w_shotgun_crosshair(player pl) { #ifdef CLIENT - static vector cross_pos; - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; - drawsubpic(cross_pos, [24,24], g_cross_spr, [48/128,24/128], [0.1875, 0.1875], [1,1,1], 1, DRAWFLAG_NORMAL); + Cross_DrawSub(g_cross_spr, [24,24], [48/128,24/128], [0.1875, 0.1875]); HUD_DrawAmmo1(); HUD_DrawAmmo2(); vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42];