]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - view.c
fix stupid typo in Cvar_RegisterVariable call
[xonotic/darkplaces.git] / view.c
diff --git a/view.c b/view.c
index 599fce42722e0eb4fcba3548bdad8f7a41e80dda..136bac93ce81e0b9757fb240e1f3adc13fa46a46 100644 (file)
--- a/view.c
+++ b/view.c
@@ -64,6 +64,8 @@ cvar_t chase_active = {CVAR_SAVE, "chase_active", "0"};
 // GAME_GOODVSBAD2
 cvar_t chase_stevie = {0, "chase_stevie", "0"};
 
+cvar_t v_deathtilt = {0, "v_deathtilt", "1"};
+
 float  v_dmg_time, v_dmg_roll, v_dmg_pitch;
 
 
@@ -248,7 +250,7 @@ void V_ParseDamage (void)
        }
 
        // calculate view angle kicks
-       if (cl.viewentity >= 0 && cl.viewentity < MAX_EDICTS && cl_entities[cl.viewentity].state_current.active)
+       if (cl_entities[cl.viewentity].state_current.active)
        {
                ent = &cl_entities[cl.viewentity];
                Matrix4x4_Transform(&ent->render.inversematrix, from, localfrom);
@@ -313,6 +315,7 @@ void V_CalcRefdef (void)
        static float oldz;
        entity_t *ent;
        float vieworg[3], viewangles[3];
+       trace_t trace;
        Matrix4x4_CreateIdentity(&viewmodelmatrix);
        Matrix4x4_CreateIdentity(&r_refdef.viewentitymatrix);
        if (cls.state == ca_connected && cls.signon == SIGNONS)
@@ -352,7 +355,7 @@ void V_CalcRefdef (void)
                        if (chase_active.value)
                        {
                                // observing entity from third person
-                               vec_t camback, camup, dist, forward[3], stop[3], chase_dest[3], normal[3];
+                               vec_t camback, camup, dist, forward[3], chase_dest[3];
 
                                camback = bound(0, chase_back.value, 128);
                                if (chase_back.value != camback)
@@ -377,19 +380,17 @@ void V_CalcRefdef (void)
                                chase_dest[0] = vieworg[0] + forward[0] * dist;
                                chase_dest[1] = vieworg[1] + forward[1] * dist;
                                chase_dest[2] = vieworg[2] + forward[2] * dist + camup;
-                               CL_TraceLine(vieworg, chase_dest, stop, normal, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY);
-                               vieworg[0] = stop[0] + forward[0] * 8 + normal[0] * 4;
-                               vieworg[1] = stop[1] + forward[1] * 8 + normal[1] * 4;
-                               vieworg[2] = stop[2] + forward[2] * 8 + normal[2] * 4;
+                               trace = CL_TraceBox(vieworg, vec3_origin, vec3_origin, chase_dest, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false);
+                               VectorMAMAM(1, trace.endpos, 8, forward, 4, trace.plane.normal, vieworg);
                        }
                        else
                        {
                                // first person view from entity
                                // angles
-                               if (cl.stats[STAT_HEALTH] <= 0 && gamemode != GAME_FNIGGIUM)
+                               if (cl.stats[STAT_HEALTH] <= 0 && v_deathtilt.integer)
                                        viewangles[ROLL] = 80;  // dead view angle
                                VectorAdd(viewangles, cl.punchangle, viewangles);
-                               viewangles[ROLL] += V_CalcRoll(cl.viewangles, cl.velocity);
+                               viewangles[ROLL] += V_CalcRoll(cl.viewangles, cl.movement_velocity);
                                if (v_dmg_time > 0)
                                {
                                        viewangles[ROLL] += v_dmg_time/v_kicktime.value*v_dmg_roll;
@@ -414,7 +415,7 @@ void V_CalcRefdef (void)
                                                cycle = sin(M_PI + M_PI * (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)
-                                       bob = sqrt(cl.velocity[0]*cl.velocity[0] + cl.velocity[1]*cl.velocity[1]) * cl_bob.value;
+                                       bob = sqrt(cl.movement_velocity[0]*cl.movement_velocity[0] + cl.movement_velocity[1]*cl.movement_velocity[1]) * cl_bob.value;
                                        bob = bob*0.3 + bob*0.7*cycle;
                                        vieworg[2] += bound(-7, bob, 4);
                                }
@@ -597,5 +598,7 @@ void V_Init (void)
        Cvar_RegisterVariable (&chase_active);
        if (gamemode == GAME_GOODVSBAD2)
                Cvar_RegisterVariable (&chase_stevie);
+
+       Cvar_RegisterVariable (&v_deathtilt);
 }