diff --git a/include/Makemodule.am b/include/Makemodule.am index 40c448f33..01bdc2a69 100644 --- a/include/Makemodule.am +++ b/include/Makemodule.am @@ -84,11 +84,12 @@ EXTRA_DIST += \ include/world.h \ include/client/effects.h \ include/client/entities.h \ + include/client/hud.h \ include/client/input.h \ - include/client/temp_entities.h \ include/client/locs.h \ include/client/particles.h \ include/client/state.h \ + include/client/temp_entities.h \ include/client/view.h \ include/evdev/hotplug.h \ include/evdev/inputlib.h \ diff --git a/include/client/hud.h b/include/client/hud.h new file mode 100644 index 000000000..31b4d5542 --- /dev/null +++ b/include/client/hud.h @@ -0,0 +1,35 @@ +/* + hud.h + + Heads-up display + + Copyright (C) 1996-1997 Id Software, Inc. + Copyright (C) 2022 Bill Currie + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ +#ifndef __client_hud_h_ +#define __client_hud_h_ + +extern struct cvar_s *hud_sbar; +extern struct cvar_s *hud_scoreboard_gravity; +extern struct cvar_s *hud_swap; + +#endif // __client_hud_h_ diff --git a/include/client/view.h b/include/client/view.h index b0419e165..ea7712a31 100644 --- a/include/client/view.h +++ b/include/client/view.h @@ -26,8 +26,8 @@ */ // view.h -#ifndef __client_view_h_ -#define __client_view_h_ +#ifndef __client_view_h +#define __client_view_h #include "QF/mathlib.h" #include "QF/render.h" @@ -54,6 +54,7 @@ typedef struct viewstate_s { int voffs_enabled:1; int bob_enabled:1; int intermission:1; + int decay_punchangle:1; int force_cshifts; // bitfield of server enforced cshifts uint32_t flags; @@ -79,13 +80,18 @@ typedef struct viewstate_s { #define VF_DEAD 1 #define VF_GIB 2 -void V_Init (void); +struct msg_s; + +void V_Init (viewstate_t *vs); void V_Init_Cvars (void); void V_RenderView (viewstate_t *vs); float V_CalcRoll (const vec3_t angles, vec4f_t velocity); void V_StartPitchDrift (viewstate_t *vs); void V_StopPitchDrift (viewstate_t *vs); - void V_SetContentsColor (viewstate_t *vs, int contents); +void V_ParseDamage (struct msg_s *net_message, viewstate_t *vs); +void V_PrepBlend (viewstate_t *vs); -#endif // __client_view_h_ +extern qboolean noclip_anglehack; + +#endif // __client_view_h diff --git a/libs/client/Makemodule.am b/libs/client/Makemodule.am index 397eacc9f..14e52a315 100644 --- a/libs/client/Makemodule.am +++ b/libs/client/Makemodule.am @@ -9,6 +9,8 @@ libs_client_libQFclient_la_SOURCES= \ libs/client/cl_input.c \ libs/client/cl_particles.c \ libs/client/cl_temp_entities.c \ + libs/client/cl_view.c \ + libs/client/hud.c \ libs/client/locs.c \ libs/client/old_keys.c diff --git a/qw/source/cl_view.c b/libs/client/cl_view.c similarity index 95% rename from qw/source/cl_view.c rename to libs/client/cl_view.c index 5eb642b7c..6eb3c20d8 100644 --- a/qw/source/cl_view.c +++ b/libs/client/cl_view.c @@ -33,18 +33,17 @@ #include "QF/msg.h" #include "QF/screen.h" +#include "QF/plugin/vid_render.h" +#include "QF/scene/transform.h" #include "QF/simd/vec4f.h" #include "compat.h" -#include "qw/bothdefs.h" - #include "client/chase.h" -#include "qw/include/cl_cam.h" -#include "qw/include/cl_ents.h" -#include "qw/include/cl_main.h" -#include "qw/include/client.h" -#include "qw/include/host.h" +#include "client/entities.h" +#include "client/hud.h" +#include "client/input.h" +#include "client/view.h" /* The view is allowed to move slightly from it's true position for bobbing, @@ -71,6 +70,11 @@ cvar_t *v_kicktime; cvar_t *v_kickroll; cvar_t *v_kickpitch; +cvar_t *cl_cshift_bonus; +cvar_t *cl_cshift_contents; +cvar_t *cl_cshift_damage; +cvar_t *cl_cshift_powerup; + cvar_t *v_iyaw_cycle; cvar_t *v_iroll_cycle; cvar_t *v_ipitch_cycle; @@ -269,7 +273,7 @@ V_DriftPitch (viewstate_t *vs) /* PALETTE FLASHES */ void -V_ParseDamage (viewstate_t *vs) +V_ParseDamage (qmsg_t *net_message, viewstate_t *vs) { float count, side; int armor, blood; @@ -725,7 +729,9 @@ V_RenderView (viewstate_t *vs) return; } - DropPunchAngle (vs); + if (vs->decay_punchangle) { + DropPunchAngle (vs); + } if (vs->intermission) { // intermission / finale rendering V_CalcIntermissionRefdef (vs); } else { @@ -734,11 +740,11 @@ V_RenderView (viewstate_t *vs) } void -V_Init (void) +V_Init (viewstate_t *viewstate) { - Cmd_AddDataCommand ("bf", V_BonusFlash_f, &cl.viewstate, + Cmd_AddDataCommand ("bf", V_BonusFlash_f, viewstate, "Background flash, used when you pick up an item"); - Cmd_AddDataCommand ("centerview", V_StartPitchDrift_f, &cl.viewstate, + Cmd_AddDataCommand ("centerview", V_StartPitchDrift_f, viewstate, "Centers the player's " "view ahead after +lookup or +lookdown\n" "Will not work while mlook is active or freelook is 1."); @@ -799,4 +805,13 @@ V_Init_Cvars (void) "How much you lean when hit"); v_kickpitch = Cvar_Get ("v_kickpitch", "0.6", CVAR_NONE, NULL, "How much you look up when hit"); + cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL, + "Show bonus flash on item pickup"); + cl_cshift_contents = Cvar_Get ("cl_cshift_content", "1", CVAR_ARCHIVE, + NULL, "Shift view colors for contents " + "(water, slime, etc)"); + cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL, + "Shift view colors on damage"); + cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL, + "Shift view colors for powerups"); } diff --git a/libs/client/hud.c b/libs/client/hud.c new file mode 100644 index 000000000..2d8f880ed --- /dev/null +++ b/libs/client/hud.c @@ -0,0 +1,36 @@ +/* + hud.c + + Heads-up display bar + + Copyright (C) 1996-1997 Id Software, Inc. + Copyright (C) 2022 Bill Currie + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "QF/cvar.h" + +cvar_t *hud_sbar; +cvar_t *hud_scoreboard_gravity; +cvar_t *hud_swap; diff --git a/nq/include/client.h b/nq/include/client.h index 3aed4fb9e..6437cf81f 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -226,8 +226,6 @@ extern struct cvar_s *cl_autofire; extern struct cvar_s *cl_shownet; extern struct cvar_s *cl_nolerp; -extern struct cvar_s *hud_sbar; - extern struct cvar_s *cl_pitchdriftspeed; extern struct cvar_s *cl_name; @@ -297,12 +295,6 @@ void CL_ParseServerMessage (void); void CL_NewTranslation (int slot, struct skin_s *skin); -// view -void V_UpdatePalette (void); -void V_Register (void); -void V_ParseDamage (viewstate_t *vs); -void V_PrepBlend (viewstate_t *vs); - // cl_tent void CL_SignonReply (void); void CL_RelinkEntities (void); diff --git a/nq/include/host.h b/nq/include/host.h index 8a6ab52c9..70c7327f9 100644 --- a/nq/include/host.h +++ b/nq/include/host.h @@ -30,8 +30,6 @@ #include "QF/qtypes.h" -extern qboolean noclip_anglehack; - typedef struct { int argc; diff --git a/nq/source/Makemodule.am b/nq/source/Makemodule.am index 0c05bb277..4d1a88955 100644 --- a/nq/source/Makemodule.am +++ b/nq/source/Makemodule.am @@ -72,7 +72,7 @@ nq_server_LIB_DEPS=$(nq_server_LIBFILES) $(nq_common_LIBFILES) nq_source_libnq_client_a_SOURCES= \ nq/source/cl_cmd.c nq/source/cl_demo.c nq/source/cl_ents.c nq/source/cl_input.c nq/source/cl_main.c \ - nq/source/cl_screen.c nq/source/cl_parse.c nq/source/cl_view.c nq/source/sbar.c + nq/source/cl_screen.c nq/source/cl_parse.c nq/source/sbar.c nq_source_libnq_server_a_SOURCES= \ nq/source/host.c nq/source/host_cmd.c nq/source/sv_cl_phys.c nq/source/sv_cvar.c nq/source/sv_main.c \ diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index 80b97fe01..ca17c7d9d 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -76,11 +76,6 @@ cvar_t *cl_writecfg; cvar_t *cl_shownet; cvar_t *cl_nolerp; -cvar_t *cl_cshift_bonus; -cvar_t *cl_cshift_contents; -cvar_t *cl_cshift_damage; -cvar_t *cl_cshift_powerup; - cvar_t *hud_fps; cvar_t *hud_time; @@ -171,14 +166,6 @@ CL_InitCvars (void) Chase_Init_Cvars (); V_Init_Cvars (); - cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL, - "Show bonus flash on item pickup"); - cl_cshift_contents = Cvar_Get ("cl_cshift_content", "1", CVAR_ARCHIVE, - NULL, "Shift view colors for contents " - "(water, slime, etc)"); - cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL, - "Shift view colors on damage"); - cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL, "Shift view colors for powerups"); cl_name = Cvar_Get ("_cl_name", "player", CVAR_ARCHIVE, NULL, "Player name"); cl_color = Cvar_Get ("_cl_color", "0", CVAR_ARCHIVE, NULL, "Player color"); @@ -582,7 +569,7 @@ CL_Init (cbuf_t *cbuf) CL_TEnts_Init (); CL_ClearState (); - V_Init (); + V_Init (&cl.viewstate); Cmd_AddCommand ("pointfile", pointfile_f, "Load a pointfile to determine map leaks."); diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index 76d9f8021..595bec0a7 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -1054,7 +1054,7 @@ CL_ParseServerMessage (void) break; case svc_damage: - V_ParseDamage (&cl.viewstate); + V_ParseDamage (net_message, &cl.viewstate); // put sbar face into pain frame cl.faceanimtime = cl.time + 0.2; break; diff --git a/nq/source/cl_view.c b/nq/source/cl_view.c deleted file mode 100644 index 42db23b44..000000000 --- a/nq/source/cl_view.c +++ /dev/null @@ -1,773 +0,0 @@ -/* - cl_view.c - - player eye positioning - - Copyright (C) 1996-1997 Id Software, Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to: - - Free Software Foundation, Inc. - 59 Temple Place - Suite 330 - Boston, MA 02111-1307, USA - -*/ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "QF/cmd.h" -#include "QF/cvar.h" -#include "QF/msg.h" -#include "QF/screen.h" - -#include "QF/simd/vec4f.h" - -#include "QF/plugin/vid_render.h" -#include "QF/scene/entity.h" - -#include "compat.h" - -#include "client/chase.h" - -#include "nq/include/client.h" -#include "nq/include/host.h" - -/* - The view is allowed to move slightly from it's true position for bobbing, - but if it exceeds 8 pixels linear distance (spherical, not box), the list - of entities sent from the server may not include everything in the pvs, - especially when crossing a water boudnary. -*/ - -cvar_t *scr_ofsx; -cvar_t *scr_ofsy; -cvar_t *scr_ofsz; - -cvar_t *cl_rollspeed; -cvar_t *cl_rollangle; - -cvar_t *cl_bob; -cvar_t *cl_bobcycle; -cvar_t *cl_bobup; - -cvar_t *v_centermove; -cvar_t *v_centerspeed; - -cvar_t *v_kicktime; -cvar_t *v_kickroll; -cvar_t *v_kickpitch; - -cvar_t *v_iyaw_cycle; -cvar_t *v_iroll_cycle; -cvar_t *v_ipitch_cycle; -cvar_t *v_iyaw_level; -cvar_t *v_iroll_level; -cvar_t *v_ipitch_level; - -cvar_t *v_idlescale; - -float v_dmg_time, v_dmg_roll, v_dmg_pitch; - -vec4f_t v_idle_yaw; -vec4f_t v_idle_roll; -vec4f_t v_idle_pitch; - -static cshift_t cshift_empty = { {130, 80, 50}, 0}; -static cshift_t cshift_water = { {130, 80, 50}, 128}; -static cshift_t cshift_slime = { { 0, 25, 5}, 150}; -static cshift_t cshift_lava = { {255, 80, 0}, 150}; -static cshift_t cshift_bonus = { {215, 186, 60}, 50}; - -static cshift_t armor_blood[] = { - { {255, 0, 0} }, // blood - { {220, 50, 50} }, // armor + blood - { {200, 100, 100} }, // armor > blood need two for logic - { {200, 100, 100} }, // armor > blood need two for logic -}; - -static cshift_t powerup[] = { - { { 0, 0, 0}, 0}, - { {100, 100, 100}, 100}, // IT_INVISIBILITY - { {255, 255, 0}, 30}, // IT_INVULNERABILITY - { {255, 255, 0}, 30}, // IT_INVULNERABILITY - { { 0, 255, 0}, 20}, // IT_SUIT - { { 0, 255, 0}, 20}, // IT_SUIT - { { 0, 255, 0}, 20}, // IT_SUIT - { { 0, 255, 0}, 20}, // IT_SUIT - { { 0, 0, 255}, 30}, // IT_QUAD - { { 0, 0, 255}, 30}, // IT_QUAD - { {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD - { {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD - { {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD - { {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD - { {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD - { {255, 0, 255}, 30}, // IT_INVULNERABILITY | IT_QUAD -}; - -#define sqr(x) ((x) * (x)) - -float -V_CalcRoll (const vec3_t angles, vec4f_t velocity) -{ - float side, sign, value; - vec3_t forward, right, up; - - AngleVectors (angles, forward, right, up); - side = DotProduct (velocity, right); - sign = side < 0 ? -1 : 1; - side = fabs (side); - - value = cl_rollangle->value; - - if (side < cl_rollspeed->value) - side = side * value / cl_rollspeed->value; - else - side = value; - - return side * sign; -} - -static float -V_CalcBob (viewstate_t *vs) -{ - vec4f_t velocity = vs->velocity; - float cycle; - static double bobtime; - static float bob; - - if (!vs->bob_enabled) - return 0; - - if (vs->onground == -1) - return bob; // just use old value - - bobtime += vs->frametime; - cycle = bobtime - (int) (bobtime / cl_bobcycle->value) * - cl_bobcycle->value; - cycle /= cl_bobcycle->value; - if (cycle < cl_bobup->value) - cycle = cycle / cl_bobup->value; - else - cycle = 1 + (cycle - cl_bobup->value) / (1.0 - cl_bobup->value); - - // bob is proportional to velocity in the xy plane - // (don't count Z, or jumping messes it up) - velocity[2] = 0; - bob = sqrt (dotf (velocity, velocity)[0]) * cl_bob->value; - bob = bob * 0.3 + bob * 0.7 * sin (cycle * M_PI); - if (bob > 4) - bob = 4; - else if (bob < -7) - bob = -7; - return bob; -} - -void -V_StartPitchDrift (viewstate_t *vs) -{ - if (vs->laststop == vs->time) { - return; // something else is keeping it from drifting - } - - if (vs->nodrift || !vs->pitchvel) { - vs->pitchvel = v_centerspeed->value; - vs->nodrift = false; - vs->driftmove = 0; - } -} - -static void -V_StartPitchDrift_f (void *data) -{ - V_StartPitchDrift (data); -} - -void -V_StopPitchDrift (viewstate_t *vs) -{ - vs->laststop = vs->time; - vs->nodrift = true; - vs->pitchvel = 0; -} - -/* - V_DriftPitch - - Moves the client pitch angle towards vs->idealpitch sent by the server. - - If the user is adjusting pitch manually, either with lookup/lookdown, - mlook and mouse, or klook and keyboard, pitch drifting is constantly - stopped. - - Drifting is enabled when the center view key is hit, mlook is released - and lookspring is non 0, or when -*/ -static void -V_DriftPitch (viewstate_t *vs) -{ - float delta, move; - float forwardmove = vs->movecmd[0]; - - if (noclip_anglehack || vs->onground == -1 || !vs->drift_enabled) { - vs->driftmove = 0; - vs->pitchvel = 0; - return; - } - - // don't count small mouse motion - if (vs->nodrift) { - if (fabs (forwardmove) < cl_forwardspeed->value) - vs->driftmove = 0; - else - vs->driftmove += vs->frametime; - - if (vs->driftmove > v_centermove->value) { - V_StartPitchDrift (vs); - } - return; - } - - delta = vs->idealpitch - vs->angles[PITCH]; - - if (!delta) { - vs->pitchvel = 0; - return; - } - - move = vs->frametime * vs->pitchvel; - vs->pitchvel += vs->frametime * v_centerspeed->value; - - if (delta > 0) { - if (move > delta) { - vs->pitchvel = 0; - move = delta; - } - vs->angles[PITCH] += move; - } else if (delta < 0) { - if (move > -delta) { - vs->pitchvel = 0; - move = -delta; - } - vs->angles[PITCH] -= move; - } -} - -/* PALETTE FLASHES */ - -void -V_ParseDamage (viewstate_t *vs) -{ - float count, side; - int armor, blood; - vec4f_t origin = vs->origin; - vec_t *angles = vs->angles; - vec3_t from, forward, right, up; - - armor = MSG_ReadByte (net_message); - blood = MSG_ReadByte (net_message); - MSG_ReadCoordV (net_message, from); - - count = blood * 0.5 + armor * 0.5; - if (count < 10) - count = 10; - - if (cl_cshift_damage->int_val - || (vs->force_cshifts & INFO_CSHIFT_DAMAGE)) { - cshift_t *cshift = &vs->cshifts[CSHIFT_DAMAGE]; - int percent = cshift->percent; - *cshift = armor_blood[(2 * (armor > blood)) + (armor > 0)]; - cshift->percent = percent + 3 * count; - cshift->percent = bound (0, cshift->percent, 150); - cshift->initialpct = cshift->percent; - cshift->time = vs->time; - } - - // calculate view angle kicks - VectorSubtract (from, origin, from); - VectorNormalize (from); - - AngleVectors (angles, forward, right, up); - - side = DotProduct (from, right); - v_dmg_roll = count * side * v_kickroll->value; - - side = DotProduct (from, forward); - v_dmg_pitch = count * side * v_kickpitch->value; - - v_dmg_time = v_kicktime->value; -} - -static void -V_cshift_f (void) -{ - cshift_empty.destcolor[0] = atoi (Cmd_Argv (1)); - cshift_empty.destcolor[1] = atoi (Cmd_Argv (2)); - cshift_empty.destcolor[2] = atoi (Cmd_Argv (3)); - cshift_empty.percent = atoi (Cmd_Argv (4)); -} - -/* - V_BonusFlash_f - - When you run over an item, the server sends this command -*/ -static void -V_BonusFlash_f (void *data) -{ - viewstate_t *vs = data; - if (!cl_cshift_bonus->int_val - && !(vs->force_cshifts & INFO_CSHIFT_BONUS)) - return; - - vs->cshifts[CSHIFT_BONUS] = cshift_bonus; - vs->cshifts[CSHIFT_BONUS].initialpct = vs->cshifts[CSHIFT_BONUS].percent; - vs->cshifts[CSHIFT_BONUS].time = vs->time; -} - -/* - V_SetContentsColor - - Underwater, lava, etc each has a color shift -*/ -void -V_SetContentsColor (viewstate_t *vs, int contents) -{ - if (!cl_cshift_contents->int_val - && !(vs->force_cshifts & INFO_CSHIFT_CONTENTS)) { - vs->cshifts[CSHIFT_CONTENTS] = cshift_empty; - return; - } - - switch (contents) { - case CONTENTS_EMPTY: - vs->cshifts[CSHIFT_CONTENTS] = cshift_empty; - break; - case CONTENTS_LAVA: - vs->cshifts[CSHIFT_CONTENTS] = cshift_lava; - break; - case CONTENTS_SOLID: - case CONTENTS_SLIME: - vs->cshifts[CSHIFT_CONTENTS] = cshift_slime; - break; - default: - vs->cshifts[CSHIFT_CONTENTS] = cshift_water; - } -} - -static void -V_CalcPowerupCshift (viewstate_t *vs) -{ - vs->cshifts[CSHIFT_POWERUP] = powerup[vs->powerup_index]; -} - -/* - V_CalcBlend - - LordHavoc made this a real, true alpha blend. Cleaned it up - a bit, but otherwise this is his code. --KB -*/ -static void -V_CalcBlend (viewstate_t *vs) -{ - float a2, a3; - float r = 0, g = 0, b = 0, a = 0; - int i; - - for (i = 0; i < NUM_CSHIFTS; i++) { - a2 = vs->cshifts[i].percent / 255.0; - - if (!a2) - continue; - - a2 = min (a2, 1.0); - r += (vs->cshifts[i].destcolor[0] - r) * a2; - g += (vs->cshifts[i].destcolor[1] - g) * a2; - b += (vs->cshifts[i].destcolor[2] - b) * a2; - - a3 = (1.0 - a) * (1.0 - a2); - a = 1.0 - a3; - } - - // LordHavoc: saturate color - if (a) { - a2 = 1.0 / a; - r *= a2; - g *= a2; - b *= a2; - } - - r_data->vid->cshift_color[0] = min (r, 255.0) / 255.0; - r_data->vid->cshift_color[1] = min (g, 255.0) / 255.0; - r_data->vid->cshift_color[2] = min (b, 255.0) / 255.0; - r_data->vid->cshift_color[3] = bound (0.0, a, 1.0); -} - -static void -V_DropCShift (cshift_t *cs, double time, float droprate) -{ - if (cs->time < 0) { - cs->percent = 0; - } else { - cs->percent = cs->initialpct - (time - cs->time) * droprate; - if (cs->percent <= 0) { - cs->percent = 0; - cs->time = -1; - } - } -} - -void -V_PrepBlend (viewstate_t *vs) -{ - int i, j; - - if (cl_cshift_powerup->int_val - || (vs->force_cshifts & INFO_CSHIFT_POWERUP)) - V_CalcPowerupCshift (vs); - - r_data->vid->cshift_changed = false; - - for (i = 0; i < NUM_CSHIFTS; i++) { - if (vs->cshifts[i].percent != vs->prev_cshifts[i].percent) { - r_data->vid->cshift_changed = true; - vs->prev_cshifts[i].percent = vs->cshifts[i].percent; - } - for (j = 0; j < 3; j++) { - if (vs->cshifts[i].destcolor[j] != vs->prev_cshifts[i].destcolor[j]) - { - r_data->vid->cshift_changed = true; - vs->prev_cshifts[i].destcolor[j] = vs->cshifts[i].destcolor[j]; - } - } - } - - // drop the damage value - V_DropCShift (&vs->cshifts[CSHIFT_DAMAGE], vs->time, 150); - // drop the bonus value - V_DropCShift (&vs->cshifts[CSHIFT_BONUS], vs->time, 100); - - if (!r_data->vid->cshift_changed && !r_data->vid->recalc_refdef) - return; - - V_CalcBlend (vs); -} - -/* VIEW RENDERING */ - -static void -CalcGunAngle (viewstate_t *vs) -{ - vec4f_t rotation = r_data->refdef->viewrotation; - //FIXME make child of camera - Transform_SetWorldRotation (vs->weapon_entity->transform, rotation); -} - -static void -V_BoundOffsets (viewstate_t *vs) -{ - vec4f_t offset = r_data->refdef->viewposition - vs->origin; - - // absolutely bound refresh reletive to entity clipping hull - // so the view can never be inside a solid wall - - offset[0] = bound (-14, offset[0], 14); - offset[1] = bound (-14, offset[1], 14); - offset[2] = bound (-22, offset[2], 30); - r_data->refdef->viewposition = vs->origin + offset; -} - -static vec4f_t -idle_quat (vec4f_t axis, cvar_t *cycle, cvar_t *level, double time) -{ - vec4f_t identity = { 0, 0, 0, 1 }; - if (!level || !cycle) { - return identity; - } - float scale = sin (time * cycle->value); - float ang = scale * level->value * v_idlescale->value; - float c = cos (ang * M_PI / 360); - float s = sin (ang * M_PI / 360); - return axis * s + identity * c; -} - -/* - V_AddIdle - - Idle swaying -*/ -static void -V_AddIdle (viewstate_t *vs) -{ - vec4f_t roll = idle_quat ((vec4f_t) { 1, 0, 0, 0}, - v_iroll_cycle, v_iroll_level, vs->time); - vec4f_t pitch = idle_quat ((vec4f_t) { 0, 1, 0, 0}, - v_ipitch_cycle, v_ipitch_level, vs->time); - vec4f_t yaw = idle_quat ((vec4f_t) { 0, 0, 1, 0}, - v_iyaw_cycle, v_iyaw_level, vs->time); - vec4f_t rot = normalf (qmulf (yaw, qmulf (pitch, roll))); - - // rotate the view - r_data->refdef->viewrotation = qmulf (rot, r_data->refdef->viewrotation); - - // counter-rotate the weapon - rot = qmulf (qconjf (rot), - Transform_GetWorldRotation (vs->weapon_entity->transform)); - Transform_SetWorldRotation (vs->weapon_entity->transform, rot); -} - -/* - V_CalcViewRoll - - Roll is induced by movement and damage -*/ -static void -V_CalcViewRoll (viewstate_t *vs) -{ - vec_t *angles = vs->angles; - vec4f_t velocity = vs->velocity; - vec3_t ang = { }; - - ang[ROLL] = V_CalcRoll (angles, velocity); - - if (v_dmg_time > 0) { - ang[ROLL] += v_dmg_time / v_kicktime->value * v_dmg_roll; - ang[PITCH] += v_dmg_time / v_kicktime->value * v_dmg_pitch; - v_dmg_time -= vs->frametime; - } - - if (vs->flags & VF_DEAD) { // VF_GIB will also set VF_DEAD - ang[ROLL] = 80; // dead view angle - } - - vec4f_t rot; - AngleQuat (ang, &rot[0]);//FIXME - r_data->refdef->viewrotation = qmulf (r_data->refdef->viewrotation, rot); -} - -static void -V_CalcIntermissionRefdef (viewstate_t *vs) -{ - // vs->player_entity is the player model (visible when out of body) - entity_t *ent = vs->player_entity; - entity_t *view; - float old; - vec4f_t origin = Transform_GetWorldPosition (ent->transform); - vec4f_t rotation = Transform_GetWorldRotation (ent->transform); - - // view is the weapon model (visible only from inside body) - view = vs->weapon_entity; - - r_data->refdef->viewposition = origin; - r_data->refdef->viewrotation = rotation; - view->renderer.model = NULL; - - // always idle in intermission - old = v_idlescale->value; - Cvar_SetValue (v_idlescale, 1); - V_AddIdle (vs); - Cvar_SetValue (v_idlescale, old); -} - -static void -V_CalcRefdef (viewstate_t *vs) -{ - // view is the weapon model (visible only from inside body) - entity_t *view = vs->weapon_entity; - float bob; - static float oldz = 0; - vec4f_t forward = {}, right = {}, up = {}; - vec4f_t origin = vs->origin; - vec_t *viewangles = vs->angles; - - V_DriftPitch (vs); - - bob = V_CalcBob (vs); - - // refresh position - r_data->refdef->viewposition = origin; - r_data->refdef->viewposition[2] += vs->height + bob; - - // never let it sit exactly on a node line, because a water plane can - // disappear when viewed with the eye exactly on it. - // server protocol specifies to only 1/8 pixel, so add 1/16 in each axis - r_data->refdef->viewposition += (vec4f_t) { 1.0/16, 1.0/16, 1.0/16, 0}; - - AngleQuat (vs->angles, &r_data->refdef->viewrotation[0]);//FIXME - V_CalcViewRoll (vs); - V_AddIdle (vs); - - // offsets - //FIXME semi-duplicates AngleQuat (also, vec3_t vs vec4f_t) - AngleVectors (viewangles, &forward[0], &right[0], &up[0]); - - // don't allow cheats in multiplayer - // FIXME check for dead - if (vs->voffs_enabled) { - r_data->refdef->viewposition += scr_ofsx->value * forward - + scr_ofsy->value * right - + scr_ofsz->value * up; - } - - V_BoundOffsets (vs); - - // set up gun position - CalcGunAngle (vs); - - origin += (vec4f_t) { 0, 0, vs->height, 0 }; - origin += forward * bob * 0.4f + (vec4f_t) { 0, 0, bob, 0 }; - - // fudge position around to keep amount of weapon visible - // roughly equal with different FOV - if (hud_sbar->int_val == 0 && r_data->scr_viewsize->int_val >= 100) { - ; - } else if (r_data->scr_viewsize->int_val == 110) { - origin += (vec4f_t) { 0, 0, 1, 0}; - } else if (r_data->scr_viewsize->int_val == 100) { - origin += (vec4f_t) { 0, 0, 2, 0}; - } else if (r_data->scr_viewsize->int_val == 90) { - origin += (vec4f_t) { 0, 0, 1, 0}; - } else if (r_data->scr_viewsize->int_val == 80) { - origin += (vec4f_t) { 0, 0, 0.5, 0}; - } - - model_t *model = vs->weapon_model; - if (view->renderer.model != model) { - view->animation.pose2 = -1; - } - view->renderer.model = model; - view->animation.frame = vs->weaponframe; - view->renderer.skin = 0; - - // set up the refresh position - r_data->refdef->viewrotation = qmulf (vs->punchangle, - r_data->refdef->viewrotation); - - // smooth out stair step ups - if ((vs->onground != -1) && (origin[2] - oldz > 0)) { - float steptime; - - steptime = vs->frametime; - - oldz += steptime * 80; - if (oldz > origin[2]) - oldz = origin[2]; - if (origin[2] - oldz > 12) - oldz = origin[2] - 12; - r_data->refdef->viewposition[2] += oldz - origin[2]; - origin[2] += oldz - origin[2]; - } else { - oldz = origin[2]; - } - { - // FIXME sort out the alias model specific negation - vec3_t ang = {-viewangles[0], viewangles[1], viewangles[2]}; - CL_TransformEntity (view, 1, ang, origin); - } - - if (vs->chase && chase_active->int_val) { - Chase_Update (vs->chasestate); - } -} - -/* - V_RenderView - - The player's clipping box goes from (-16 -16 -24) to (16 16 32) from - the entity origin, so any view position inside that will be valid -*/ -void -V_RenderView (viewstate_t *vs) -{ - if (!vs->active) { - r_data->refdef->viewposition = (vec4f_t) { 0, 0, 0, 1 }; - r_data->refdef->viewrotation = (vec4f_t) { 0, 0, 0, 1 }; - return; - } - - if (vs->intermission) { // intermission / finale rendering - V_CalcIntermissionRefdef (vs); - } else { - V_CalcRefdef (vs); - } -} - -void -V_Init (void) -{ - Cmd_AddDataCommand ("bf", V_BonusFlash_f, &cl.viewstate, - "Background flash, used when you pick up an item"); - Cmd_AddDataCommand ("centerview", V_StartPitchDrift_f, &cl.viewstate, - "Centers the player's " - "view ahead after +lookup or +lookdown\n" - "Will not work while mlook is active or freelook is 1."); - Cmd_AddCommand ("v_cshift", V_cshift_f, "This adjusts all of the colors " - "currently being displayed.\n" - "Used when you are underwater, hit, have the Ring of " - "Shadows, or Quad Damage. (v_cshift r g b intensity)"); -} - -void -V_Init_Cvars (void) -{ - v_centermove = Cvar_Get ("v_centermove", "0.15", CVAR_NONE, NULL, - "How far the player must move forward before the " - "view re-centers"); - v_centerspeed = Cvar_Get ("v_centerspeed", "500", CVAR_NONE, NULL, - "How quickly you return to a center view after " - "a lookup or lookdown"); - v_iyaw_cycle = Cvar_Get ("v_iyaw_cycle", "2", CVAR_NONE, NULL, - "How far you tilt right and left when " - "v_idlescale is enabled"); - v_iroll_cycle = Cvar_Get ("v_iroll_cycle", "0.5", CVAR_NONE, NULL, - "How quickly you tilt right and left when " - "v_idlescale is enabled"); - v_ipitch_cycle = Cvar_Get ("v_ipitch_cycle", "1", CVAR_NONE, NULL, - "How quickly you lean forwards and backwards " - "when v_idlescale is enabled"); - v_iyaw_level = Cvar_Get ("v_iyaw_level", "0.3", CVAR_NONE, NULL, - "How far you tilt right and left when " - "v_idlescale is enabled"); - v_iroll_level = Cvar_Get ("v_iroll_level", "0.1", CVAR_NONE, NULL, - "How far you tilt right and left when " - "v_idlescale is enabled"); - v_ipitch_level = Cvar_Get ("v_ipitch_level", "0.3", CVAR_NONE, NULL, - "How far you lean forwards and backwards when " - "v_idlescale is enabled"); - v_idlescale = Cvar_Get ("v_idlescale", "0", CVAR_NONE, NULL, - "Toggles whether the view remains idle"); - - scr_ofsx = Cvar_Get ("scr_ofsx", "0", CVAR_NONE, NULL, "None"); - scr_ofsy = Cvar_Get ("scr_ofsy", "0", CVAR_NONE, NULL, "None"); - scr_ofsz = Cvar_Get ("scr_ofsz", "0", CVAR_NONE, NULL, "None"); - cl_rollspeed = Cvar_Get ("cl_rollspeed", "200", CVAR_NONE, NULL, - "How quickly you straighten out after strafing"); - cl_rollangle = Cvar_Get ("cl_rollangle", "2.0", CVAR_NONE, NULL, - "How much your screen tilts when strafing"); - cl_bob = Cvar_Get ("cl_bob", "0.02", CVAR_NONE, NULL, - "How much your weapon moves up and down when walking"); - cl_bobcycle = Cvar_Get ("cl_bobcycle", "0.6", CVAR_NONE, NULL, - "How quickly your weapon moves up and down when " - "walking"); - cl_bobup = Cvar_Get ("cl_bobup", "0.5", CVAR_NONE, NULL, - "How long your weapon stays up before cycling when " - "walking"); - v_kicktime = Cvar_Get ("v_kicktime", "0.5", CVAR_NONE, NULL, - "How long the kick from an attack lasts"); - v_kickroll = Cvar_Get ("v_kickroll", "0.6", CVAR_NONE, NULL, - "How much you lean when hit"); - v_kickpitch = Cvar_Get ("v_kickpitch", "0.6", CVAR_NONE, NULL, - "How much you look up when hit"); -} diff --git a/nq/source/sbar.c b/nq/source/sbar.c index 3bef29f54..af78bea47 100644 --- a/nq/source/sbar.c +++ b/nq/source/sbar.c @@ -57,6 +57,8 @@ #include "compat.h" #include "sbar.h" +#include "client/hud.h" + #include "nq/include/client.h" #include "nq/include/game.h" #include "nq/include/server.h" @@ -105,9 +107,6 @@ int hipweapons[4] = { HIT_LASER_CANNON_BIT, HIT_MJOLNIR_BIT, 4, HIT_PROXIMITY_GUN_BIT }; qpic_t *hsb_items[2]; // MED 01/04/97 added hipnotic items array -cvar_t *hud_sbar; -cvar_t *hud_swap; -cvar_t *hud_scoreboard_gravity; cvar_t *scr_centertime; cvar_t *scr_printspeed; diff --git a/qw/include/client.h b/qw/include/client.h index cc2e586d2..e6410ecaa 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -270,9 +270,6 @@ extern struct cvar_s *cl_netgraph_box; extern struct cvar_s *cl_draw_locs; extern struct cvar_s *cl_shownet; -extern struct cvar_s *hud_sbar; -extern struct cvar_s *hud_sbar_separator; -extern struct cvar_s *hud_swap; extern struct cvar_s *cl_pitchdriftspeed; @@ -316,10 +313,6 @@ void CL_UpdateScreen (double realtime); void CL_SetState (cactive_t state); -void V_ParseDamage (viewstate_t *vs); - -void V_PrepBlend (viewstate_t *vs); - void CL_Cmd_ForwardToServer (void); void CL_Cmd_Init (void); diff --git a/qw/include/host.h b/qw/include/host.h index d7a290284..ccf759a26 100644 --- a/qw/include/host.h +++ b/qw/include/host.h @@ -38,8 +38,6 @@ #define MAX_NUM_ARGVS 50 -extern qboolean noclip_anglehack; - extern struct cvar_s *sys_ticrate; extern struct cvar_s *password; diff --git a/qw/source/Makemodule.am b/qw/source/Makemodule.am index 86228215b..145c4a540 100644 --- a/qw/source/Makemodule.am +++ b/qw/source/Makemodule.am @@ -106,7 +106,6 @@ qw_source_libqw_client_a_SOURCES= \ qw/source/cl_cam.c qw/source/cl_chat.c qw/source/cl_cmd.c qw/source/cl_cvar.c qw/source/cl_demo.c \ qw/source/cl_entparse.c qw/source/cl_ents.c qw/source/cl_http.c qw/source/cl_input.c qw/source/cl_main.c qw/source/cl_ngraph.c \ qw/source/cl_parse.c qw/source/cl_pred.c qw/source/cl_rss.c qw/source/cl_screen.c qw/source/cl_skin.c qw/source/cl_slist.c \ - qw/source/cl_view.c \ qw/source/sbar.c qw/source/teamplay.c # Software-rendering clients diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 8a4c02512..c4a809f68 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -151,11 +151,6 @@ cvar_t *cl_quakerc; cvar_t *cl_maxfps; cvar_t *cl_usleep; -cvar_t *cl_cshift_bonus; -cvar_t *cl_cshift_contents; -cvar_t *cl_cshift_damage; -cvar_t *cl_cshift_powerup; - cvar_t *cl_model_crcs; cvar_t *cl_predict_players; @@ -1221,7 +1216,7 @@ CL_Init (void) CL_Skin_Init (); Locs_Init (); - V_Init (); + V_Init (&cl.viewstate); Info_SetValueForStarKey (cls.userinfo, "*ver", QW_VERSION, 0); @@ -1368,15 +1363,6 @@ CL_Init_Cvars (void) "exec autoexec.cfg on gamedir change"); cl_quakerc = Cvar_Get ("cl_quakerc", "1", CVAR_NONE, NULL, "exec quake.rc on startup"); - cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL, - "Show bonus flash on item pickup"); - cl_cshift_contents = Cvar_Get ("cl_cshift_content", "1", CVAR_ARCHIVE, - NULL, "Shift view colors for contents " - "(water, slime, etc)"); - cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL, - "Shift view colors on damage"); - cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL, - "Shift view colors for powerups"); cl_fb_players = Cvar_Get ("cl_fb_players", "0", CVAR_ARCHIVE, NULL, "fullbrightness of player models. " "server must allow (via fbskins serverinfo)."); cl_writecfg = Cvar_Get ("cl_writecfg", "1", CVAR_NONE, NULL, diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 5e72ccee8..d8d2dd5e2 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -1506,7 +1506,7 @@ CL_ParseServerMessage (void) // svc_particle case svc_damage: - V_ParseDamage (&cl.viewstate); + V_ParseDamage (net_message, &cl.viewstate); // put sbar face into pain frame cl.faceanimtime = cl.time + 0.2; break; diff --git a/qw/source/cl_screen.c b/qw/source/cl_screen.c index 29af9187a..ff4006437 100644 --- a/qw/source/cl_screen.c +++ b/qw/source/cl_screen.c @@ -48,6 +48,7 @@ #include "sbar.h" +#include "client/hud.h" #include "client/view.h" #include "qw/include/client.h" diff --git a/qw/source/sbar.c b/qw/source/sbar.c index d8dde4f52..6f60de764 100644 --- a/qw/source/sbar.c +++ b/qw/source/sbar.c @@ -57,6 +57,8 @@ #include "compat.h" +#include "client/hud.h" + #include "qw/bothdefs.h" #include "qw/include/cl_cam.h" #include "qw/include/cl_parse.h" @@ -96,9 +98,6 @@ static qboolean largegame = false; cvar_t *fs_fraglog; cvar_t *cl_fraglog; -cvar_t *hud_sbar; -cvar_t *hud_swap; -cvar_t *hud_scoreboard_gravity; cvar_t *hud_scoreboard_uid; cvar_t *scr_centertime; cvar_t *scr_printspeed;