From d7293c88717d29473807a95c0343cd87a0ae9e64 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 22 May 2021 20:36:55 +0200 Subject: [PATCH] Client: Separate flashlight code from player.qc. --- src/client/flashlight.qc | 43 ++++++++++++++++++++++++++++++++++++++++ src/client/player.qc | 24 +--------------------- src/client/progs.src | 1 + 3 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 src/client/flashlight.qc diff --git a/src/client/flashlight.qc b/src/client/flashlight.qc new file mode 100644 index 0000000..3efc50c --- /dev/null +++ b/src/client/flashlight.qc @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016-2020 Marco Hladik + * + * 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 +Player_Flashlight(base_player pl) +{ + if (pl.gflags & GF_FLASHLIGHT) { + vector src; + vector ang; + + if (pl.entnum != player_localentnum) { + src = pl.origin + pl.view_ofs; + ang = [pl.pitch, pl.angles[1], pl.angles[2]]; + } else { + src = pSeat->m_vecPredictedOrigin + [0,0,-8]; + ang = view_angles; + } + + makevectors(ang); + traceline(src, src + (v_forward * 8096), MOVE_NORMAL, pl); + + 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); + } + } +} diff --git a/src/client/player.qc b/src/client/player.qc index 05f22ce..d21ce5a 100644 --- a/src/client/player.qc +++ b/src/client/player.qc @@ -166,29 +166,7 @@ void Player_PreDraw(base_player pl, int thirdperson) { /* Handle the flashlights... */ - if (pl.gflags & GF_FLASHLIGHT) { - vector src; - vector ang; - - if (pl.entnum != player_localentnum) { - src = pl.origin + pl.view_ofs; - ang = [pl.pitch, pl.angles[1], pl.angles[2]]; - } else { - src = pSeat->m_vecPredictedOrigin + [0,0,-8]; - ang = view_angles; - } - - makevectors(ang); - traceline(src, src + (v_forward * 8096), MOVE_NORMAL, pl); - - 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); - } - } + Player_Flashlight(pl); PMove_SetSize(pl); Animation_PlayerUpdate((player)pl); diff --git a/src/client/progs.src b/src/client/progs.src index 6b9c103..a1568f3 100755 --- a/src/client/progs.src +++ b/src/client/progs.src @@ -21,6 +21,7 @@ defs.h ../../../base/src/client/draw.qc init.qc +flashlight.qc player.qc entities.qc cmds.qc