From 88005f67105b00213aafc3ec47000181699a60a6 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 18 Jun 2011 22:22:47 +0900 Subject: [PATCH] Diff reduction. --- nq/include/client.h | 1 + nq/source/cl_tent.c | 23 ++++++-------- nq/source/cl_view.c | 73 ++++++++++++++++++++++----------------------- qw/source/cl_tent.c | 19 ++++-------- qw/source/cl_view.c | 48 ++++++++++++++--------------- 5 files changed, 74 insertions(+), 90 deletions(-) diff --git a/nq/include/client.h b/nq/include/client.h index 61e5cb67d..8f208fdc7 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -132,6 +132,7 @@ typedef struct struct qsocket_s *netcon; sizebuf_t message; // writing buffer to send to server + int sv_cshifts; } client_static_t; extern client_static_t cls; diff --git a/nq/source/cl_tent.c b/nq/source/cl_tent.c index ad7371b61..5fae66ae0 100644 --- a/nq/source/cl_tent.c +++ b/nq/source/cl_tent.c @@ -134,10 +134,9 @@ CL_Init_Entity (entity_t *ent) memset (ent, 0, sizeof (*ent)); ent->colormap = vid.colormap8; - ent->colormod[0] = ent->colormod[1] = ent->colormod[2] = - ent->colormod[3] = 1.0; + QuatSet (1.0, 1.0, 1.0, 1.0, ent->colormod); ent->scale = 1.0; - ent->lerpflags |= LERP_RESETMOVE|LERP_RESETANIM; + ent->lerpflags |= LERP_RESETMOVE | LERP_RESETANIM; } static tent_t * @@ -326,7 +325,8 @@ CL_ParseTEnt (void) tent_obj_t *to; explosion_t *ex; int colorStart, colorLength; - vec3_t col, pos; + quat_t col; + vec3_t pos; sfx_t *spike_sound[] = { cl_sfx_ric3, cl_sfx_ric3, cl_sfx_ric2, cl_sfx_ric1, }; @@ -389,10 +389,7 @@ CL_ParseTEnt (void) dl->radius = 350; dl->die = cl.time + 0.5; dl->decay = 300; - dl->color[0] = 1.0; - dl->color[1] = 0.5; - dl->color[2] = 0.25; - dl->color[3] = 0.7; + QuatSet (1.0, 0.5, 0.25, 0.7, dl->color); } // sound @@ -466,15 +463,14 @@ CL_ParseTEnt (void) dl->die = cl.time + 0.5; dl->decay = 300; colorStart = (colorStart + (rand () % colorLength)) * 3; - dl->color[0] = vid.palette[colorStart] * (1.0 / 255.0); - dl->color[1] = vid.palette[colorStart + 1] * (1.0 / 255.0); - dl->color[2] = vid.palette[colorStart + 2] * (1.0 / 255.0); + VectorScale (&vid.palette[colorStart], 1.0 / 255.0, dl->color); dl->color[3] = 0.7; break; case TE_EXPLOSION3: // Nehahra colored light explosion MSG_ReadCoordV (net_message, pos); MSG_ReadCoordV (net_message, col); // OUCH! + col[3] = 0.7; R_ParticleExplosion (pos); S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); dl = R_AllocDlight (0); @@ -483,8 +479,7 @@ CL_ParseTEnt (void) dl->radius = 350; dl->die = cl.time + 0.5; dl->decay = 300; - VectorCopy (col, dl->color); - dl->color[3] = 0.7; + QuatCopy (col, dl->color); } break; @@ -494,7 +489,7 @@ CL_ParseTEnt (void) break; default: - Sys_Error ("CL_ParseTEnt: bad type"); + Sys_Error ("CL_ParseTEnt: bad type %d", type); } } diff --git a/nq/source/cl_view.c b/nq/source/cl_view.c index 786892ae9..5384998a5 100644 --- a/nq/source/cl_view.c +++ b/nq/source/cl_view.c @@ -67,6 +67,10 @@ 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; @@ -76,10 +80,6 @@ cvar_t *v_ipitch_level; cvar_t *v_idlescale; -cvar_t *v_kicktime; -cvar_t *v_kickroll; -cvar_t *v_kickpitch; - float v_dmg_time, v_dmg_roll, v_dmg_pitch; float v_blend[4]; @@ -122,9 +122,9 @@ void V_StartPitchDrift (void) { if (cl.laststop == cl.time) { - return; // something else is keeping it from - // drifting + return; // something else is keeping it from drifting } + if (cl.nodrift || !cl.pitchvel) { cl.pitchvel = v_centerspeed->value; cl.nodrift = false; @@ -221,9 +221,9 @@ V_ParseDamage (void) cl.faceanimtime = cl.time + 0.2; // but sbar face into pain frame - if (cl_cshift_damage->int_val) { -// || (atoi (Info_ValueForKey (cl.serverinfo, "cshifts")) & -// INFO_CSHIFT_DAMAGE)) { + if (cl_cshift_damage->int_val + || (cl.sv_cshifts & INFO_CSHIFT_DAMAGE)) { + cl.cshifts[CSHIFT_DAMAGE].percent += 3 * count; cl.cshifts[CSHIFT_DAMAGE].percent = bound (0, cl.cshifts[CSHIFT_DAMAGE].percent, 150); @@ -277,7 +277,8 @@ V_cshift_f (void) static void V_BonusFlash_f (void) { - if (!cl_cshift_bonus->int_val) + if (!cl_cshift_bonus->int_val + && !(cl.sv_cshifts & INFO_CSHIFT_BONUS)) return; cl.cshifts[CSHIFT_BONUS] = cshift_bonus; } @@ -290,14 +291,15 @@ V_BonusFlash_f (void) void V_SetContentsColor (int contents) { - if (!cl_cshift_contents->int_val) { + if (!cl_cshift_contents->int_val + && !(cl.sv_cshifts & INFO_CSHIFT_CONTENTS)) { cl.cshifts[CSHIFT_CONTENTS] = cshift_empty; return; } switch (contents) { case CONTENTS_EMPTY: - cl.cshifts[CSHIFT_CONTENTS] = cshift_empty; + cl.cshifts[CSHIFT_CONTENTS] = cshift_empty; break; case CONTENTS_LAVA: cl.cshifts[CSHIFT_CONTENTS] = cshift_lava; @@ -337,7 +339,7 @@ V_CalcPowerupCshift (void) cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; cl.cshifts[CSHIFT_POWERUP].percent = 30; - } else if (cl.stats[STAT_ITEMS] & IT_SUIT) { + } else if (cl.stats[STAT_ITEMS] & IT_SUIT) { cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; @@ -399,9 +401,8 @@ V_PrepBlend (void) { int i, j; - if (cl_cshift_powerup->int_val) -// || (atoi (Info_ValueForKey (cl.serverinfo, "cshifts")) -// & INFO_CSHIFT_POWERUP)) + if (cl_cshift_powerup->int_val + || (cl.sv_cshifts & INFO_CSHIFT_POWERUP)) V_CalcPowerupCshift (); vid.cshift_changed = false; @@ -450,7 +451,7 @@ angledelta (float a) static void CalcGunAngle (void) { - float yaw, pitch, move; + float yaw, pitch, move; static float oldpitch = 0, oldyaw = 0; yaw = r_refdef.viewangles[YAW]; @@ -527,15 +528,12 @@ V_BoundOffsets (void) static void V_AddIdle (void) { - r_refdef.viewangles[ROLL] += - v_idlescale->value * sin (cl.time * v_iroll_cycle->value) * - v_iroll_level->value; - r_refdef.viewangles[PITCH] += - v_idlescale->value * sin (cl.time * v_ipitch_cycle->value) * - v_ipitch_level->value; - r_refdef.viewangles[YAW] += - v_idlescale->value * sin (cl.time * v_iyaw_cycle->value) * - v_iyaw_level->value; + r_refdef.viewangles[ROLL] += v_idlescale->value * + sin (cl.time * v_iroll_cycle->value) * v_iroll_level->value; + r_refdef.viewangles[PITCH] += v_idlescale->value * + sin (cl.time * v_ipitch_cycle->value) * v_ipitch_level->value; + r_refdef.viewangles[YAW] += v_idlescale->value * + sin (cl.time * v_iyaw_cycle->value) * v_iyaw_level->value; } /* @@ -612,7 +610,7 @@ V_CalcRefdef (void) r_refdef.vieworg[2] += cl.viewheight + bob; // never let it sit exactly on a node line, because a water plane can - // dissapear when viewed with the eye exactly on it. + // disappear when viewed with the eye exactly on it. // server protocol specifies to only 1/16 pixel, so add 1/32 in each axis r_refdef.vieworg[0] += 1.0 / 32; r_refdef.vieworg[1] += 1.0 / 32; @@ -648,8 +646,8 @@ V_CalcRefdef (void) for (i = 0; i < 3; i++) { view->origin[i] += forward[i] * bob * 0.4; -// view->origin[i] += right[i]*bob*0.4; -// view->origin[i] += up[i]*bob*0.8; +// view->origin[i] += right[i] * bob * 0.4; +// view->origin[i] += up[i] * bob * 0.8; } view->origin[2] += bob; @@ -727,23 +725,23 @@ V_RenderView (void) void V_Init (void) { - 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)"); Cmd_AddCommand ("bf", V_BonusFlash_f, "Background flash, used when you " "pick up an item"); Cmd_AddCommand ("centerview", V_StartPitchDrift, "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"); + "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"); @@ -780,8 +778,9 @@ V_Init_Cvars (void) 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"); + 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, diff --git a/qw/source/cl_tent.c b/qw/source/cl_tent.c index 72853c8bc..8f51ae6ad 100644 --- a/qw/source/cl_tent.c +++ b/qw/source/cl_tent.c @@ -140,8 +140,7 @@ CL_Init_Entity (entity_t *ent) memset (ent, 0, sizeof (*ent)); ent->colormap = vid.colormap8; - VectorSet (1.0, 1.0, 1.0, ent->colormod); - ent->colormod[3] = 1.0; + QuatSet (1.0, 1.0, 1.0, 1.0, ent->colormod); ent->scale = 1.0; ent->lerpflags |= LERP_RESETMOVE | LERP_RESETANIM; } @@ -396,10 +395,7 @@ CL_ParseTEnt (void) dl->radius = 350; dl->die = cl.time + 0.5; dl->decay = 300; - dl->color[0] = 0.86; - dl->color[1] = 0.31; - dl->color[2] = 0.24; - dl->color[3] = 0.7; + QuatSet (0.86, 0.31, 0.24, 0.7, dl->color); } // sound @@ -469,9 +465,7 @@ CL_ParseTEnt (void) dl->die = cl.time + 0.5; dl->decay = 300; colorStart = (colorStart + (rand () % colorLength)) * 3; - dl->color[0] = vid.palette[colorStart] * (1.0 / 255.0); - dl->color[1] = vid.palette[colorStart + 1] * (1.0 / 255.0); - dl->color[2] = vid.palette[colorStart + 2] * (1.0 / 255.0); + VectorScale (&vid.palette[colorStart], 1.0 / 255.0, dl->color); dl->color[3] = 0.7; break; @@ -497,10 +491,7 @@ CL_ParseTEnt (void) dl->radius = 150; dl->die = cl.time + 0.1; dl->decay = 200; - dl->color[0] = 0.25; - dl->color[1] = 0.40; - dl->color[2] = 0.65; - dl->color[3] = 1; + QuatSet (0.25, 0.40, 0.65, 1, dl->color); } R_LightningBloodEffect (pos); @@ -525,6 +516,8 @@ CL_UpdateBeams (void) // update lightning for (to = &cl_beams; *to; ) { b = &(*to)->to.beam; + if (!b->endtime) + continue; if (!b->model || b->endtime < cl.time) { tent_obj_t *_to; b->endtime = 0; diff --git a/qw/source/cl_view.c b/qw/source/cl_view.c index e8a9de14c..9fbde1eae 100644 --- a/qw/source/cl_view.c +++ b/qw/source/cl_view.c @@ -41,6 +41,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/vid.h" #include "qw/bothdefs.h" +#include "cl_cam.h" #include "cl_main.h" #include "client.h" #include "compat.h" @@ -187,7 +188,7 @@ V_StopPitchDrift (void) static void V_DriftPitch (void) { - float delta, move; + float delta, move; if (view_message->onground == -1 || cls.demoplayback) { cl.driftmove = 0; @@ -246,8 +247,7 @@ V_ParseDamage (void) armor = MSG_ReadByte (net_message); blood = MSG_ReadByte (net_message); - for (i = 0; i < 3; i++) - from[i] = MSG_ReadCoord (net_message); + MSG_ReadCoordV (net_message, from); count = blood * 0.5 + armor * 0.5; if (count < 10) @@ -375,7 +375,7 @@ V_CalcPowerupCshift (void) cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; cl.cshifts[CSHIFT_POWERUP].percent = 30; - } else if (cl.stats[STAT_ITEMS] & IT_SUIT) { + } else if (cl.stats[STAT_ITEMS] & IT_SUIT) { cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; @@ -399,12 +399,12 @@ V_CalcPowerupCshift (void) void V_CalcBlend (void) { - float a2, a3; - float r = 0, g = 0, b = 0, a = 0; - int i; + float a2, a3; + float r = 0, g = 0, b = 0, a = 0; + int i; for (i = 0; i < NUM_CSHIFTS; i++) { - a2 = cl.cshifts[i].percent * (1.0 / 255.0); + a2 = cl.cshifts[i].percent / 255.0; if (!a2) continue; @@ -426,16 +426,16 @@ V_CalcBlend (void) b *= a2; } - v_blend[0] = min (r, 255.0) * (1.0 / 255.0); - v_blend[1] = min (g, 255.0) * (1.0 / 255.0); - v_blend[2] = min (b, 255.0) * (1.0 / 255.0); + v_blend[0] = min (r, 255.0) / 255.0; + v_blend[1] = min (g, 255.0) / 255.0; + v_blend[2] = min (b, 255.0) / 255.0; v_blend[3] = bound (0.0, a, 1.0); } void V_PrepBlend (void) { - int i, j; + int i, j; if (cl_cshift_powerup->int_val || (cl.sv_cshifts & INFO_CSHIFT_POWERUP)) @@ -487,8 +487,8 @@ angledelta (float a) static void CalcGunAngle (void) { - float yaw, pitch, move; - static float oldpitch = 0, oldyaw = 0; + float yaw, pitch, move; + static float oldpitch = 0, oldyaw = 0; yaw = r_refdef.viewangles[YAW]; pitch = -r_refdef.viewangles[PITCH]; @@ -553,7 +553,7 @@ V_AddIdle (void) static void V_CalcViewRoll (void) { - float side; + float side; side = V_CalcRoll (cl.simangles, cl.simvel); r_refdef.viewangles[ROLL] += side; @@ -574,7 +574,7 @@ V_CalcIntermissionRefdef (void) entity_t *view; float old; - // view is the weapon model + // view is the weapon model (visible only from inside body) view = &cl.viewent; VectorCopy (cl.simorg, r_refdef.vieworg); @@ -588,18 +588,15 @@ V_CalcIntermissionRefdef (void) Cvar_SetValue (v_idlescale, old); } -#include "cl_cam.h" - - static void V_CalcRefdef (void) { entity_t *view; - float bob; + float bob; static float oldz = 0; - int i; - int zofs = 22; - vec3_t forward, right, up; + int i; + int zofs = 22; + vec3_t forward, right, up; if (cl.stdver) zofs = cl.stats[STAT_VIEWHEIGHT]; @@ -650,7 +647,7 @@ V_CalcRefdef (void) for (i = 0; i < 3; i++) { view->origin[i] += forward[i] * bob * 0.4; -// view->origin[i] += right[i] * bob *0.4; +// view->origin[i] += right[i] * bob * 0.4; // view->origin[i] += up[i] * bob * 0.8; } view->origin[2] += bob; @@ -733,14 +730,13 @@ V_RenderView (void) R_RenderView (); } - void V_Init (void) { Cmd_AddCommand ("bf", V_BonusFlash_f, "Background flash, used when you " "pick up an item"); Cmd_AddCommand ("centerview", V_StartPitchDrift, "Centers the player's " - "view ahead after +lookup or +lookdown \n" + "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"