- if (oldyaw - move > yaw)
- yaw = oldyaw - move;
- }
-
- if (pitch > oldpitch)
- {
- if (oldpitch + move < pitch)
- pitch = oldpitch + move;
- }
- else
- {
- if (oldpitch - move > pitch)
- pitch = oldpitch - move;
- }
-
- oldyaw = yaw;
- oldpitch = pitch;
-
- cl.viewent.angles[YAW] = r_refdef.viewangles[YAW] + yaw;
- cl.viewent.angles[PITCH] = - (r_refdef.viewangles[PITCH] + pitch);
-
- cl.viewent.angles[ROLL] -= v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
- cl.viewent.angles[PITCH] -= v_idlescale.value * sin(cl.time*v_ipitch_cycle.value) * v_ipitch_level.value;
- cl.viewent.angles[YAW] -= v_idlescale.value * sin(cl.time*v_iyaw_cycle.value) * v_iyaw_level.value;
-}
-
-/*
-==============
-V_BoundOffsets
-==============
-*/
-void V_BoundOffsets (void)
-{
- entity_t *ent;
-
- ent = &cl_entities[cl.viewentity];
-
-// absolutely bound refresh reletive to entity clipping hull
-// so the view can never be inside a solid wall
-
- if (r_refdef.vieworg[0] < ent->origin[0] - 14)
- r_refdef.vieworg[0] = ent->origin[0] - 14;
- else if (r_refdef.vieworg[0] > ent->origin[0] + 14)
- r_refdef.vieworg[0] = ent->origin[0] + 14;
- if (r_refdef.vieworg[1] < ent->origin[1] - 14)
- r_refdef.vieworg[1] = ent->origin[1] - 14;
- else if (r_refdef.vieworg[1] > ent->origin[1] + 14)
- r_refdef.vieworg[1] = ent->origin[1] + 14;
- if (r_refdef.vieworg[2] < ent->origin[2] - 22)
- r_refdef.vieworg[2] = ent->origin[2] - 22;
- else if (r_refdef.vieworg[2] > ent->origin[2] + 30)
- r_refdef.vieworg[2] = ent->origin[2] + 30;
-}
-
-/*
-==============
-V_AddIdle
-
-Idle swaying
-==============
-*/
-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;
-}
-
-
-/*
-==============
-V_CalcViewRoll
-
-Roll is induced by movement and damage
-==============
-*/
-void V_CalcViewRoll (void)
-{
- float side;
-
- side = V_CalcRoll (cl_entities[cl.viewentity].angles, cl.velocity);
- r_refdef.viewangles[ROLL] += side;
-
- if (v_dmg_time > 0)
- {
- r_refdef.viewangles[ROLL] += v_dmg_time/v_kicktime.value*v_dmg_roll;
- r_refdef.viewangles[PITCH] += v_dmg_time/v_kicktime.value*v_dmg_pitch;
- v_dmg_time -= host_frametime;
- }
-
- if (cl.stats[STAT_HEALTH] <= 0)
- {
- r_refdef.viewangles[ROLL] = 80; // dead view angle
- return;
- }
-
-}
-
-
-/*
-==================
-V_CalcIntermissionRefdef
-
-==================
-*/
-void V_CalcIntermissionRefdef (void)
-{
- entity_t *ent, *view;
- float old;
-
-// ent is the player model (visible when out of body)
- ent = &cl_entities[cl.viewentity];
-// view is the weapon model (only visible from inside body)
- view = &cl.viewent;
-
- VectorCopy (ent->origin, r_refdef.vieworg);
- VectorCopy (ent->angles, r_refdef.viewangles);
- view->model = NULL;
-
-// allways idle in intermission
- old = v_idlescale.value;
- v_idlescale.value = 1;
- V_AddIdle ();
- v_idlescale.value = old;
-}
-
-/*
-==================
-V_CalcRefdef
-
-==================
-*/
-void V_CalcRefdef (void)
-{
- entity_t *ent, *view;
- int i;
- vec3_t forward, right, up;
- vec3_t angles;
- float bob;
- static float oldz = 0;
-
- V_DriftPitch ();
-
-// ent is the player model (visible when out of body)
- ent = &cl_entities[cl.viewentity];
-// view is the weapon model (only visible from inside body)
- view = &cl.viewent;
-
-
-// transform the view offset by the model's matrix to get the offset from
-// model origin for the view
- ent->angles[YAW] = cl.viewangles[YAW]; // the model should face the view dir
- ent->angles[PITCH] = -cl.viewangles[PITCH]; // the model should face the view dir
-
-
- bob = V_CalcBob ();
-
-// refresh position
- VectorCopy (ent->origin, r_refdef.vieworg);
- 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.
-// the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis
- r_refdef.vieworg[0] += 1.0/32;
- r_refdef.vieworg[1] += 1.0/32;
- r_refdef.vieworg[2] += 1.0/32;
-
- VectorCopy (cl.viewangles, r_refdef.viewangles);
- V_CalcViewRoll ();
- V_AddIdle ();
-
-// offsets
- angles[PITCH] = -ent->angles[PITCH]; // because entity pitches are
- // actually backward
- angles[YAW] = ent->angles[YAW];
- angles[ROLL] = ent->angles[ROLL];
-
- AngleVectors (angles, forward, right, up);
-
- for (i=0 ; i<3 ; i++)
- r_refdef.vieworg[i] += scr_ofsx.value*forward[i]
- + scr_ofsy.value*right[i]
- + scr_ofsz.value*up[i];
-
-
- V_BoundOffsets ();
-
-// set up gun position
- VectorCopy (cl.viewangles, view->angles);
-
- CalcGunAngle ();
-
- VectorCopy (ent->origin, view->origin);
- view->origin[2] += cl.viewheight;
-
- 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[2] += bob;
-
-// fudge position around to keep amount of weapon visible
-// roughly equal with different FOV
-
-#if 0
- if (cl.model_precache[cl.stats[STAT_WEAPON]] && strcmp (cl.model_precache[cl.stats[STAT_WEAPON]]->name, "progs/v_shot2.mdl"))
-#endif
-// LordHavoc: everyone hates the gun moving around
-/*
- if (scr_viewsize.value == 110)
- view->origin[2] += 1;
- else if (scr_viewsize.value == 100)
- view->origin[2] += 2;
- else if (scr_viewsize.value == 90)
- view->origin[2] += 1;
- else if (scr_viewsize.value == 80)
- view->origin[2] += 0.5;
-*/
-
- view->model = cl.model_precache[cl.stats[STAT_WEAPON]];
- view->frame = cl.stats[STAT_WEAPONFRAME];
- view->colormap = vid.colormap;
-
-// set up the refresh position
- VectorAdd (r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
-
-// smooth out stair step ups
-if (cl.onground && ent->origin[2] - oldz > 0)
-{
- float steptime;
-
- steptime = cl.time - cl.oldtime;
- if (steptime < 0)
-//FIXME I_Error ("steptime < 0");
- steptime = 0;
-
- oldz += steptime * 80;
- if (oldz > ent->origin[2])
- oldz = ent->origin[2];
- if (ent->origin[2] - oldz > 12)
- oldz = ent->origin[2] - 12;
- r_refdef.vieworg[2] += oldz - ent->origin[2];
- view->origin[2] += oldz - ent->origin[2];
-}
-else
- oldz = ent->origin[2];
-
- if (chase_active.value)
- Chase_Update ();
-}
-
-/*
-==================
-V_RenderView
+ // set contents color
+ int supercontents;
+ vec3_t vieworigin;
+ Matrix4x4_OriginFromMatrix(&r_refdef.viewentitymatrix, vieworigin);
+ supercontents = CL_PointSuperContents(vieworigin);
+ if (supercontents & SUPERCONTENTS_LIQUIDSMASK)
+ {
+ r_refdef.fovscale_x *= 1 - (((sin(cl.time * 4.7) + 1) * 0.015) * r_waterwarp.value);
+ r_refdef.fovscale_y *= 1 - (((sin(cl.time * 3.0) + 1) * 0.015) * r_waterwarp.value);
+ if (supercontents & SUPERCONTENTS_LAVA)
+ {
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[0] = 255;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[1] = 80;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[2] = 0;
+ }
+ else if (supercontents & SUPERCONTENTS_SLIME)
+ {
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[0] = 0;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[1] = 25;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[2] = 5;
+ }
+ else
+ {
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[0] = 130;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[1] = 80;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[2] = 50;
+ }
+ cl.cshifts[CSHIFT_CONTENTS].percent = 150 >> 1;
+ }
+ else
+ {
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[0] = 0;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[1] = 0;
+ cl.cshifts[CSHIFT_CONTENTS].destcolor[2] = 0;
+ cl.cshifts[CSHIFT_CONTENTS].percent = 0;
+ }