added back r_speeds2, with masses of information (6 lines high), and made it print...
[xonotic/darkplaces.git] / cl_main.c
index cb2ea33..56d77ab 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -27,12 +27,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 // these two are not intended to be set directly
 cvar_t cl_name = {"_cl_name", "player", true};
 cvar_t cl_color = {"_cl_color", "0", true};
+cvar_t cl_pmodel = {"_cl_pmodel", "0", true};
 
 cvar_t cl_shownet = {"cl_shownet","0"};        // can be 0, 1, or 2
 cvar_t cl_nolerp = {"cl_nolerp","0"};
 
-cvar_t maxfps = {"maxfps", "100"};
-
 cvar_t lookspring = {"lookspring","0", true};
 cvar_t lookstrafe = {"lookstrafe","0", true};
 cvar_t sensitivity = {"sensitivity","3", true};
@@ -199,13 +198,19 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
                MSG_WriteString (&cls.message, "prespawn");
                break;
                
-       case 2:         
+       case 2:
                MSG_WriteByte (&cls.message, clc_stringcmd);
                MSG_WriteString (&cls.message, va("name \"%s\"\n", cl_name.string));
-       
+
                MSG_WriteByte (&cls.message, clc_stringcmd);
                MSG_WriteString (&cls.message, va("color %i %i\n", ((int)cl_color.value)>>4, ((int)cl_color.value)&15));
        
+               if (cl_pmodel.value)
+               {
+                       MSG_WriteByte (&cls.message, clc_stringcmd);
+                       MSG_WriteString (&cls.message, va("pmodel %f\n", cl_pmodel.value));
+               }
+
                MSG_WriteByte (&cls.message, clc_stringcmd);
                sprintf (str, "spawn %s", cls.spawnparms);
                MSG_WriteString (&cls.message, str);
@@ -220,7 +225,7 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
        case 4:
                SCR_EndLoadingPlaque ();                // allow normal screen updates
                // LordHavoc: debugging purposes
-               Con_DPrintf("GLQuake texture slots in use: %i : %i : %i texels\n", texture_extension_number, numgltextures, texels);
+               Con_DPrintf("Texture slots in use: %i : %i : %i texels\n", texture_extension_number, numgltextures, texels);
                break;
        }
 }
@@ -283,49 +288,6 @@ void CL_PrintEntities_f (void)
 
 /*
 ===============
-SetPal
-
-Debugging tool, just flashes the screen
-===============
-*/
-void SetPal (int i)
-{
-#if 0
-       static int old;
-       byte    pal[768];
-       int             c;
-       
-       if (i == old)
-               return;
-       old = i;
-
-       if (i==0)
-               VID_SetPalette (host_basepal);
-       else if (i==1)
-       {
-               for (c=0 ; c<768 ; c+=3)
-               {
-                       pal[c] = 0;
-                       pal[c+1] = 255;
-                       pal[c+2] = 0;
-               }
-               VID_SetPalette (pal);
-       }
-       else
-       {
-               for (c=0 ; c<768 ; c+=3)
-               {
-                       pal[c] = 0;
-                       pal[c+1] = 0;
-                       pal[c+2] = 255;
-               }
-               VID_SetPalette (pal);
-       }
-#endif
-}
-
-/*
-===============
 CL_AllocDlight
 
 ===============
@@ -388,7 +350,9 @@ void CL_DecayLights (void)
        {
                if (dl->die < cl.time || !dl->radius)
                        continue;
-               
+
+               c_dlights++; // count every dlight in use
+
                dl->radius -= time*dl->decay;
                if (dl->radius < 0)
                        dl->radius = 0;
@@ -427,7 +391,6 @@ float       CL_LerpPoint (void)
        {
                if (frac < -0.01)
                {
-SetPal(1);
                        cl.time = cl.mtime[1];
 //                             Con_Printf ("low frac\n");
                }
@@ -437,14 +400,11 @@ SetPal(1);
        {
                if (frac > 1.01)
                {
-SetPal(2);
                        cl.time = cl.mtime[0];
 //                             Con_Printf ("high frac\n");
                }
                frac = 1;
        }
-       else
-               SetPal(0);
                
        return frac;
 }
@@ -508,9 +468,31 @@ void CL_RelinkEntities (void)
                if (ent->msgtime != cl.mtime[0])
                {
                        ent->model = NULL;
+                       // LordHavoc: free on the same frame, not the next
+                       if (ent->forcelink)
+                               R_RemoveEfrags (ent);   // just became empty
                        continue;
                }
 
+               // LordHavoc: animation interpolation, note: framegroups partially override this in the renderer
+               /*
+               if (ent->model != ent->lerp_model || ent->lerp_time > cl.time)
+               {
+                       ent->lerp_frame1 = ent->lerp_frame2 = ent->frame;
+                       ent->lerp_time = cl.time;
+                       ent->lerp = 0;
+               }
+               else if (ent->frame != ent->lerp_frame2)
+               {
+                       ent->lerp_frame1 = ent->lerpframe2;
+                       ent->lerp_frame2 = ent->frame;
+                       ent->lerp_time = cl.time;
+                       ent->lerp = 0;
+               }
+               else
+                       ent->lerp = bound(0, (cl.time - ent->lerp_time) * 10.0f, 1);
+               */
+
                VectorCopy (ent->origin, oldorg);
 
                if (ent->forcelink)
@@ -557,8 +539,7 @@ void CL_RelinkEntities (void)
                        AngleVectors (ent->angles, fv, rv, uv);
                         
                        VectorMA (dl->origin, 18, fv, dl->origin);
-                       dl->radius = 200 + (rand()&31);
-                       dl->minlight = 32;
+                       dl->radius = 100 + (rand()&31);
                        dl->die = cl.time + 0.1;
                        dl->color[0] = 1.0;dl->color[1] = 1.0;dl->color[2] = 1.0;
                }
@@ -644,21 +625,12 @@ void CL_RelinkEntities (void)
                {
                        dl = CL_AllocDlight (i);
                        VectorCopy (ent->origin, dl->origin);
-                       dl->dark = ent->glowsize < 0; // darklight
                        dl->radius = ent->glowsize;
-                       if (dl->dark)
-                       {
-                               if (ent->glowtrail) // LordHavoc: all darklights leave black trails
-                                       R_RocketTrail2 (oldorg, ent->origin, 0, ent);
-                               dl->radius = -ent->glowsize;
-                       }
-                       else if (ent->glowtrail) // LordHavoc: customizable glow and trail
-                               R_RocketTrail2 (oldorg, ent->origin, ent->glowcolor, ent);
                        dl->die = cl.time + 0.001;
                        tempcolor = (byte *)&d_8to24table[ent->glowcolor];
                        dl->color[0] = tempcolor[0]*(1.0/255.0);dl->color[1] = tempcolor[1]*(1.0/255.0);dl->color[2] = tempcolor[2]*(1.0/255.0);
                }
-               else if (ent->glowtrail) // LordHavoc: customizable glow and trail
+               if (ent->glowtrail) // LordHavoc: customizable glow and trail
                        R_RocketTrail2 (oldorg, ent->origin, ent->glowcolor, ent);
 
                ent->forcelink = false;
@@ -774,6 +746,57 @@ void CL_PauseDemo_f (void)
                Con_Printf("Demo unpaused\n");
 }
 
+/*
+======================
+CL_PModel_f
+LordHavoc: Intended for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
+======================
+*/
+void CL_PModel_f (void)
+{
+       int i;
+       eval_t *val;
+
+       if (Cmd_Argc () == 1)
+       {
+               Con_Printf ("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
+               return;
+       }
+       i = atoi(Cmd_Argv(1));
+
+       if (cmd_source == src_command)
+       {
+               if (cl_pmodel.value == i)
+                       return;
+               Cvar_SetValue ("_cl_pmodel", i);
+               if (cls.state == ca_connected)
+                       Cmd_ForwardToServer ();
+               return;
+       }
+
+       host_client->pmodel = i;
+       if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_pmodel)))
+               val->_float = i;
+}
+
+/*
+======================
+CL_Fog_f
+======================
+*/
+void CL_Fog_f (void)
+{
+       if (Cmd_Argc () == 1)
+       {
+               Con_Printf ("\"fog\" is \"%f %f %f %f\"\n", fog_density, fog_red, fog_green, fog_blue);
+               return;
+       }
+       fog_density = atof(Cmd_Argv(1));
+       fog_red = atof(Cmd_Argv(2));
+       fog_green = atof(Cmd_Argv(3));
+       fog_blue = atof(Cmd_Argv(4));
+}
+
 cvar_t demo_nehahra = {"demo_nehahra", "0"};
 
 /*
@@ -793,6 +816,7 @@ void CL_Init (void)
 //
        Cvar_RegisterVariable (&cl_name);
        Cvar_RegisterVariable (&cl_color);
+       Cvar_RegisterVariable (&cl_pmodel);
        Cvar_RegisterVariable (&cl_upspeed);
        Cvar_RegisterVariable (&cl_forwardspeed);
        Cvar_RegisterVariable (&cl_backspeed);
@@ -803,7 +827,6 @@ void CL_Init (void)
        Cvar_RegisterVariable (&cl_anglespeedkey);
        Cvar_RegisterVariable (&cl_shownet);
        Cvar_RegisterVariable (&cl_nolerp);
-       Cvar_RegisterVariable (&maxfps);
        Cvar_RegisterVariable (&lookspring);
        Cvar_RegisterVariable (&lookstrafe);
        Cvar_RegisterVariable (&sensitivity);
@@ -822,8 +845,12 @@ void CL_Init (void)
        Cmd_AddCommand ("playdemo", CL_PlayDemo_f);
        Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
 
+       Cmd_AddCommand ("fog", CL_Fog_f);
+
        // LordHavoc: added pausedemo
        Cmd_AddCommand ("pausedemo", CL_PauseDemo_f);
+       // LordHavoc: added pmodel command (like name, etc, only intended for Nehahra)
+       Cmd_AddCommand ("pmodel", CL_PModel_f);
        // LordHavoc: added demo_nehahra cvar
        Cvar_RegisterVariable (&demo_nehahra);
        if (nehahra)