]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - view.c
workaround for bounds checking error in loading texture lump
[xonotic/darkplaces.git] / view.c
diff --git a/view.c b/view.c
index 1780fef8820ab832967d0546fd19336109ff9172..22ddf75d48e2ffa049be64c347cc8febb0142dcf 100644 (file)
--- a/view.c
+++ b/view.c
@@ -30,10 +30,6 @@ when crossing a water boudnary.
 
 */
 
-cvar_t scr_ofsx = {"scr_ofsx","0", false};
-cvar_t scr_ofsy = {"scr_ofsy","0", false};
-cvar_t scr_ofsz = {"scr_ofsz","0", false};
-
 cvar_t cl_rollspeed = {"cl_rollspeed", "200"};
 cvar_t cl_rollangle = {"cl_rollangle", "2.0"};
 
@@ -58,7 +54,8 @@ cvar_t        crosshair = {"crosshair", "0", true};
 cvar_t cl_crossx = {"cl_crossx", "0", false};
 cvar_t cl_crossy = {"cl_crossy", "0", false};
 
-cvar_t gl_cshiftpercent = {"gl_cshiftpercent", "100", false};
+//cvar_t       gl_cshiftpercent = {"gl_cshiftpercent", "100", false};
+cvar_t gl_polyblend = {"gl_polyblend", "1", true};
 
 float  v_dmg_time, v_dmg_roll, v_dmg_pitch;
 
@@ -241,7 +238,7 @@ void V_DriftPitch (void)
 /*
 ============================================================================== 
  
-                                               PALETTE FLASHES 
+                                               SCREEN FLASHES 
  
 ============================================================================== 
 */ 
@@ -281,29 +278,32 @@ void V_ParseDamage (void)
 
        cl.faceanimtime = cl.time + 0.2;                // but sbar face into pain frame
 
-       cl.cshifts[CSHIFT_DAMAGE].percent += 3*count;
-       if (cl.cshifts[CSHIFT_DAMAGE].percent < 0)
-               cl.cshifts[CSHIFT_DAMAGE].percent = 0;
-       if (cl.cshifts[CSHIFT_DAMAGE].percent > 150)
-               cl.cshifts[CSHIFT_DAMAGE].percent = 150;
-
-       if (armor > blood)              
-       {
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 200;
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 100;
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 100;
-       }
-       else if (armor)
-       {
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 220;
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 50;
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 50;
-       }
-       else
+       if (gl_polyblend.value)
        {
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 255;
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 0;
-               cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 0;
+               cl.cshifts[CSHIFT_DAMAGE].percent += 3*count;
+               if (cl.cshifts[CSHIFT_DAMAGE].percent < 0)
+                       cl.cshifts[CSHIFT_DAMAGE].percent = 0;
+               if (cl.cshifts[CSHIFT_DAMAGE].percent > 150)
+                       cl.cshifts[CSHIFT_DAMAGE].percent = 150;
+
+               if (armor > blood)              
+               {
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 200;
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 100;
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 100;
+               }
+               else if (armor)
+               {
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 220;
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 50;
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 50;
+               }
+               else
+               {
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 255;
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 0;
+                       cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 0;
+               }
        }
 
 //
@@ -349,10 +349,13 @@ When you run over an item, the server sends this command
 */
 void V_BonusFlash_f (void)
 {
-       cl.cshifts[CSHIFT_BONUS].destcolor[0] = 215;
-       cl.cshifts[CSHIFT_BONUS].destcolor[1] = 186;
-       cl.cshifts[CSHIFT_BONUS].destcolor[2] = 69;
-       cl.cshifts[CSHIFT_BONUS].percent = 50;
+       if (gl_polyblend.value)
+       {
+               cl.cshifts[CSHIFT_BONUS].destcolor[0] = 215;
+               cl.cshifts[CSHIFT_BONUS].destcolor[1] = 186;
+               cl.cshifts[CSHIFT_BONUS].destcolor[2] = 69;
+               cl.cshifts[CSHIFT_BONUS].percent = 50;
+       }
 }
 
 /*
@@ -366,6 +369,11 @@ void V_SetContentsColor (int contents)
 {
        cshift_t* c;
        c = &cl.cshifts[CSHIFT_CONTENTS]; // just to shorten the code below
+       if (!gl_polyblend.value)
+       {
+               c->percent = 0;
+               return;
+       }
        switch (contents)
        {
        case CONTENTS_EMPTY:
@@ -406,6 +414,11 @@ V_CalcPowerupCshift
 */
 void V_CalcPowerupCshift (void)
 {
+       if (!gl_polyblend.value)
+       {
+               cl.cshifts[CSHIFT_POWERUP].percent = 0;
+               return;
+       }
        if (cl.items & IT_QUAD)
        {
                cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0;
@@ -454,11 +467,12 @@ void V_CalcBlend (void)
        b = 0;
        a = 0;
 
-       if (gl_cshiftpercent.value)
-       {
+//     if (gl_cshiftpercent.value)
+//     {
                for (j=0 ; j<NUM_CSHIFTS ; j++) 
                {
-                       a2 = ((cl.cshifts[j].percent * gl_cshiftpercent.value) / 100.0) / 255.0;
+//                     a2 = ((cl.cshifts[j].percent * gl_cshiftpercent.value) / 100.0) / 255.0;
+                       a2 = cl.cshifts[j].percent * (1.0f / 255.0f);
 
                        if (!a2)
                                continue;
@@ -477,7 +491,7 @@ void V_CalcBlend (void)
                        g *= a2;
                        b *= a2;
                }
-       }
+//     }
 
        v_blend[0] = bound(0, r * (1.0/255.0), 1);
        v_blend[1] = bound(0, g * (1.0/255.0), 1);
@@ -487,10 +501,10 @@ void V_CalcBlend (void)
 
 /*
 =============
-V_UpdatePalette
+V_UpdateBlends
 =============
 */
-void V_UpdatePalette (void)
+void V_UpdateBlends (void)
 {
        int             i, j;
        qboolean        new;
@@ -710,6 +724,7 @@ V_CalcRefdef
 
 ==================
 */
+extern qboolean intimerefresh;
 void V_CalcRefdef (void)
 {
        entity_t        *ent, *view;
@@ -729,8 +744,11 @@ void V_CalcRefdef (void)
 
 // 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
+       if (!chase_active.value) // LordHavoc: get rid of angle problems in chase_active mode
+       {
+               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 ();
@@ -746,7 +764,10 @@ void V_CalcRefdef (void)
        r_refdef.vieworg[1] += 1.0/32;
        r_refdef.vieworg[2] += 1.0/32;
 
-       VectorCopy (cl.viewangles, r_refdef.viewangles);
+       if (!intimerefresh)
+       {
+               VectorCopy (cl.viewangles, r_refdef.viewangles);
+       }
        V_CalcViewRoll ();
        V_AddIdle ();
 
@@ -758,12 +779,6 @@ void V_CalcRefdef (void)
 
        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
@@ -785,27 +800,15 @@ void V_CalcRefdef (void)
 // 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;
+       view->colormap = -1; // no special coloring
 
 // set up the refresh position
-       VectorAdd (r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
+       if (!intimerefresh)
+       {
+               VectorAdd (r_refdef.viewangles, cl.punchangle, r_refdef.viewangles);
+       }
 
 // smooth out stair step ups
 if (cl.onground && ent->origin[2] - oldz > 0)
@@ -840,21 +843,11 @@ The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
 the entity origin, so any view position inside that will be valid
 ==================
 */
-extern vrect_t scr_vrect;
-
 void V_RenderView (void)
 {
        if (con_forcedup)
                return;
 
-// don't allow cheats in multiplayer
-       if (cl.maxclients > 1)
-       {
-               Cvar_Set ("scr_ofsx", "0");
-               Cvar_Set ("scr_ofsy", "0");
-               Cvar_Set ("scr_ofsz", "0");
-       }
-
        if (cl.intermission)
        {       // intermission / finale rendering
                V_CalcIntermissionRefdef ();    
@@ -865,8 +858,6 @@ void V_RenderView (void)
                        V_CalcRefdef ();
        }
 
-       R_PushDlights ();
-
        R_RenderView ();
 }
 
@@ -897,11 +888,9 @@ void V_Init (void)
        Cvar_RegisterVariable (&crosshair);
        Cvar_RegisterVariable (&cl_crossx);
        Cvar_RegisterVariable (&cl_crossy);
-       Cvar_RegisterVariable (&gl_cshiftpercent);
+//     Cvar_RegisterVariable (&gl_cshiftpercent);
+       Cvar_RegisterVariable (&gl_polyblend);
 
-       Cvar_RegisterVariable (&scr_ofsx);
-       Cvar_RegisterVariable (&scr_ofsy);
-       Cvar_RegisterVariable (&scr_ofsz);
        Cvar_RegisterVariable (&cl_rollspeed);
        Cvar_RegisterVariable (&cl_rollangle);
        Cvar_RegisterVariable (&cl_bob);