From 83d6dd7262924357d86e330c550f5808e519c787 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 31 May 2012 08:11:39 +0900 Subject: [PATCH] Fix idealpitch and viewheight in qw. For certain values of "fix" ;). Both are brought back to life but idealpitch is never set (always 0) and veiwheight is set in V_RenderView(). However, this brings the rest of the code in cl_view.c just that little bit closer to merged :) --- include/qw/protocol.h | 2 ++ qw/include/client.h | 2 ++ qw/source/cl_view.c | 27 +++++++++++++-------------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/qw/protocol.h b/include/qw/protocol.h index 2a895f151..40edeab27 100644 --- a/include/qw/protocol.h +++ b/include/qw/protocol.h @@ -290,6 +290,8 @@ #define TE_EXPLOSION2 16 #define TE_BEAM 17 // PGM 01/21/97 +#define DEFAULT_VIEWHEIGHT 22 + // ELEMENTS COMMUNICATED ACROSS THE NET ======================================= #define MAX_CLIENTS 32 diff --git a/qw/include/client.h b/qw/include/client.h index 7ec5942de..5c0609c16 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -240,12 +240,14 @@ typedef struct { vec3_t simangles; // pitch drifting vars + float idealpitch; float pitchvel; qboolean nodrift; float driftmove; double laststop; int onground; // -1 when in air + float viewheight; float crouch; // local amount for smoothing stepups qboolean paused; // send over by server diff --git a/qw/source/cl_view.c b/qw/source/cl_view.c index 3f2fd523e..674dd5e81 100644 --- a/qw/source/cl_view.c +++ b/qw/source/cl_view.c @@ -207,7 +207,7 @@ V_DriftPitch (void) return; } - delta = 0 - cl.viewangles[PITCH]; + delta = cl.idealpitch - cl.viewangles[PITCH]; if (!delta) { cl.pitchvel = 0; @@ -591,12 +591,8 @@ V_CalcRefdef (void) float bob; static float oldz = 0; int i; - int zofs = 22; vec3_t forward, right, up; - if (cl.stdver) - zofs = cl.stats[STAT_VIEWHEIGHT]; - V_DriftPitch (); // view is the weapon model (visible only from inside body) @@ -606,7 +602,7 @@ V_CalcRefdef (void) // refresh position from simulated origin VectorCopy (cl.simorg, r_data->refdef->vieworg); - r_data->refdef->vieworg[2] += bob; + r_data->refdef->vieworg[2] += cl.viewheight + bob; // never let it sit exactly on a node line, because a water plane can // disappear when viewed with the eye exactly on it. @@ -619,13 +615,6 @@ V_CalcRefdef (void) V_CalcViewRoll (); V_AddIdle (); - if (view_message->pls.flags & PF_GIB) - r_data->refdef->vieworg[2] += 8; // gib view height - else if (view_message->pls.flags & PF_DEAD) - r_data->refdef->vieworg[2] -= 16; // corpse view height - else - r_data->refdef->vieworg[2] += zofs; // view height - if (view_message->pls.flags & PF_DEAD) // PF_GIB will also set PF_DEAD r_data->refdef->viewangles[ROLL] = 80; // dead view angle @@ -638,7 +627,7 @@ V_CalcRefdef (void) CalcGunAngle (); VectorCopy (cl.simorg, view->origin); - view->origin[2] += zofs; + view->origin[2] += cl.viewheight; for (i = 0; i < 3; i++) { view->origin[i] += forward[i] * bob * 0.4; @@ -716,6 +705,16 @@ V_RenderView (void) view_frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK]; view_message = &view_frame->playerstate[cl.playernum]; + if (view_message->pls.flags & PF_GIB) + cl.viewheight = 8; // gib view height + else if (view_message->pls.flags & PF_DEAD) + cl.viewheight = -16; // corpse view height + else { + cl.viewheight = DEFAULT_VIEWHEIGHT; // view height + if (cl.stdver) + cl.viewheight = cl.stats[STAT_VIEWHEIGHT]; + } + DropPunchAngle (); if (cl.intermission) { // intermission / finale rendering V_CalcIntermissionRefdef ();