]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - view.c
another stack overflow fixed, this one more on the order of 300k+?
[xonotic/darkplaces.git] / view.c
diff --git a/view.c b/view.c
index 9ca7209292966197b044aa65c1a9911ba50c110e..4b46ffc44709a28701bda82d9b45979eb0dfacf5 100644 (file)
--- a/view.c
+++ b/view.c
@@ -78,8 +78,6 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity)
        side = fabs(side);
 
        value = cl_rollangle.value;
-//     if (cl.inwater)
-//             value *= 6;
 
        if (side < cl_rollspeed.value)
                side = side * value / cl_rollspeed.value;
@@ -112,7 +110,6 @@ static float V_CalcBob (void)
        // (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;
-       //Con_Printf ("speed: %5.1f\n", Length(cl.velocity));
        bob = bob*0.3 + bob*0.7*sin(cycle);
        bob = bound(-7, bob, 4);
        return bob;
@@ -121,12 +118,9 @@ static float V_CalcBob (void)
 
 void V_StartPitchDrift (void)
 {
-#if 1
        if (cl.laststop == cl.time)
-       {
                return;         // something else is keeping it from drifting
-       }
-#endif
+
        if (cl.nodrift || !cl.pitchvel)
        {
                cl.pitchvel = v_centerspeed.value;
@@ -192,8 +186,6 @@ static void V_DriftPitch (void)
        move = cl.frametime * cl.pitchvel;
        cl.pitchvel += cl.frametime * v_centerspeed.value;
 
-//Con_Printf ("move: %f (%f)\n", move, cl.frametime);
-
        if (delta > 0)
        {
                if (move > delta)
@@ -215,9 +207,6 @@ static void V_DriftPitch (void)
 }
 
 
-
-
-
 /*
 ==============================================================================
 
@@ -335,7 +324,7 @@ void V_UpdateBlends (void)
        float   r, g, b, a, a2;
        int             j;
 
-       if (cl.worldmodel == NULL)
+       if (cls.signon != SIGNONS)
        {
                cl.cshifts[CSHIFT_DAMAGE].percent = 0;
                cl.cshifts[CSHIFT_BONUS].percent = 0;
@@ -359,7 +348,7 @@ void V_UpdateBlends (void)
                cl.cshifts[CSHIFT_BONUS].percent = 0;
 
        // set contents color
-       switch (Mod_PointInLeaf (r_refdef.vieworg, cl.worldmodel)->contents)
+       switch (Mod_PointContents (r_refdef.vieworg, cl.worldmodel))
        {
        case CONTENTS_EMPTY:
        case CONTENTS_SOLID:
@@ -372,19 +361,19 @@ void V_UpdateBlends (void)
                cl.cshifts[CSHIFT_CONTENTS].destcolor[0] = 255;
                cl.cshifts[CSHIFT_CONTENTS].destcolor[1] = 80;
                cl.cshifts[CSHIFT_CONTENTS].destcolor[2] = 0;
-               cl.cshifts[CSHIFT_CONTENTS].percent = 150;
+               cl.cshifts[CSHIFT_CONTENTS].percent = 150 >> 1;
                break;
        case CONTENTS_SLIME:
                cl.cshifts[CSHIFT_CONTENTS].destcolor[0] = 0;
                cl.cshifts[CSHIFT_CONTENTS].destcolor[1] = 25;
                cl.cshifts[CSHIFT_CONTENTS].destcolor[2] = 5;
-               cl.cshifts[CSHIFT_CONTENTS].percent = 150;
+               cl.cshifts[CSHIFT_CONTENTS].percent = 150 >> 1;
                break;
        default:
                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 = 128;
+               cl.cshifts[CSHIFT_CONTENTS].percent = 128 >> 1;
        }
 
        if (cl.items & IT_QUAD)
@@ -489,7 +478,7 @@ void V_CalcRefdef (void)
        float           bob;
        float           side;
 
-       if (cls.state != ca_connected || !cl.worldmodel)
+       if (cls.state != ca_connected || cls.signon != SIGNONS)
                return;
 
        // ent is the player model (visible when out of body)
@@ -543,7 +532,15 @@ void V_CalcRefdef (void)
 
                r_refdef.vieworg[2] += cl.viewheight + bob;
 
+               // LordHavoc: origin view kick added
+               if (!intimerefresh)
+               {
+                       VectorAdd(r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
+                       VectorAdd(r_refdef.vieworg, cl.punchvector, r_refdef.vieworg);
+               }
+
                // set up gun
+               // (FIXME! this should be in cl_main.c with the other linking code, not view.c!)
                view->state_current.modelindex = cl.stats[STAT_WEAPON];
                view->state_current.frame = cl.stats[STAT_WEAPONFRAME];
                VectorCopy(r_refdef.vieworg, view->render.origin);
@@ -555,20 +552,15 @@ void V_CalcRefdef (void)
                view->render.angles[ROLL] = r_refdef.viewangles[ROLL] - v_idlescale.value * sin(cl.time*v_iroll_cycle.value) * v_iroll_level.value;
                // FIXME: this setup code is somewhat evil (CL_LerpUpdate should be private?)
                CL_LerpUpdate(view);
+               CL_BoundingBoxForEntity(&view->render);
                view->render.colormap = -1; // no special coloring
                view->render.alpha = ent->render.alpha; // LordHavoc: if the player is transparent, so is the gun
                view->render.effects = ent->render.effects;
-               view->render.scale = 1;
+               view->render.scale = 1.0 / 3.0;
 
-               // LordHavoc: origin view kick added
-               if (!intimerefresh)
-               {
-                       VectorAdd(r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
-                       VectorAdd(r_refdef.vieworg, cl.punchvector, r_refdef.vieworg);
-               }
-
-               // copy to refdef
-               r_refdef.viewent = view->render;
+               // link into render entities list
+               if (r_refdef.numentities < r_refdef.maxentities && r_drawviewmodel.integer && !chase_active.integer && !envmap && r_drawentities.integer && !(cl.items & IT_INVISIBILITY) && cl.stats[STAT_HEALTH] > 0 && view->render.model != NULL)
+                       r_refdef.entities[r_refdef.numentities++] = &view->render;
        }
 }
 
@@ -609,4 +601,3 @@ void V_Init (void)
        Cvar_RegisterVariable (&v_kickpitch);
 }
 
-