]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_main.c
eliminated RENDER_NOCULLFACE (now uses MATERIALFLAG_NOCULLFACE on a texture)
[xonotic/darkplaces.git] / cl_main.c
index f7c5ecabde03681bfdf55dba92cb2c1800fae25d..735660494ddec0951117c1b11584fed542005600 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -289,6 +289,8 @@ void CL_Disconnect(void)
        if (cls.state == ca_dedicated)
                return;
 
+       Curl_Clear_forthismap();
+
        Con_DPrintf("CL_Disconnect\n");
 
        CL_VM_ShutDown();
@@ -412,8 +414,7 @@ CL_PrintEntities_f
 static void CL_PrintEntities_f(void)
 {
        entity_t *ent;
-       int i, j;
-       char name[32];
+       int i;
 
        for (i = 0, ent = cl.entities;i < cl.num_entities;i++, ent++)
        {
@@ -426,10 +427,7 @@ static void CL_PrintEntities_f(void)
                        modelname = ent->render.model->name;
                else
                        modelname = "--no model--";
-               strlcpy(name, modelname, 25);
-               for (j = (int)strlen(name);j < 25;j++)
-                       name[j] = ' ';
-               Con_Printf("%3i: %s:%4i (%5i %5i %5i) [%3i %3i %3i] %4.2f %5.3f\n", i, name, ent->render.frame, (int) ent->state_current.origin[0], (int) ent->state_current.origin[1], (int) ent->state_current.origin[2], (int) ent->state_current.angles[0] % 360, (int) ent->state_current.angles[1] % 360, (int) ent->state_current.angles[2] % 360, ent->render.scale, ent->render.alpha);
+               Con_Printf("%3i: %-25s:%4i (%5i %5i %5i) [%3i %3i %3i] %4.2f %5.3f\n", i, modelname, ent->render.frame, (int) ent->state_current.origin[0], (int) ent->state_current.origin[1], (int) ent->state_current.origin[2], (int) ent->state_current.angles[0] % 360, (int) ent->state_current.angles[1] % 360, (int) ent->state_current.angles[2] % 360, ent->render.scale, ent->render.alpha);
        }
 }
 
@@ -500,14 +498,11 @@ static float CL_LerpPoint(void)
 {
        float f;
 
-       // dropped packet, or start of demo
-       if (cl.mtime[1] < cl.mtime[0] - 0.1)
-               cl.mtime[1] = cl.mtime[0] - 0.1;
-
-       cl.time = bound(cl.mtime[1], cl.time, cl.mtime[0]);
+       if (cl_nettimesyncmode.integer == 3)
+               cl.time = bound(cl.mtime[1], cl.time, cl.mtime[0]);
 
        // LordHavoc: lerp in listen games as the server is being capped below the client (usually)
-       if (cl.mtime[0] <= cl.mtime[1] || cl_nolerp.integer || cls.timedemo || (cl.islocalgame && !sv_fixedframeratesingleplayer.integer))
+       if (cl.mtime[0] <= cl.mtime[1])
        {
                cl.time = cl.mtime[0];
                return 1;
@@ -769,7 +764,6 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit)
 {
        const matrix4x4_t *matrix;
        matrix4x4_t blendmatrix, tempmatrix, matrix2;
-       //matrix4x4_t dlightmatrix;
        int j, k, l;
        float origin[3], angles[3], delta[3], lerp, d;
        entity_t *t;
@@ -874,10 +868,10 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit)
        }
 
        // movement lerp
-       // if it's the player entity, update according to client movement
+       // if it's the predicted player entity, update according to client movement
        if (e == cl.entities + cl.playerentity && cl.movement_predicted)
        {
-               lerp = (cl.timenonlerp - cl.movement_time[2]) / (cl.movement_time[0] - cl.movement_time[1]);
+               lerp = (cl.time - cl.movement_time[2]) / (cl.movement_time[0] - cl.movement_time[1]);
                lerp = bound(0, lerp, 1);
                if (cl_nolerp.integer)
                        lerp = 1;
@@ -975,19 +969,13 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit)
        // player model is only shown with chase_active on
        if (e->state_current.number == cl.viewentity)
                e->render.flags |= RENDER_EXTERIORMODEL;
-       // transparent stuff can't be lit during the opaque stage
-       if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
-               e->render.flags |= RENDER_TRANSPARENT;
-       // double sided rendering mode causes backfaces to be visible
-       // (mostly useful on transparent stuff)
-       if (e->render.effects & EF_DOUBLESIDED)
-               e->render.flags |= RENDER_NOCULLFACE;
        // either fullbright or lit
        if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
                e->render.flags |= RENDER_LIGHT;
        // hide player shadow during intermission or nehahra movie
-       if (!(e->render.effects & EF_NOSHADOW)
-        && !(e->render.flags & (RENDER_VIEWMODEL | RENDER_TRANSPARENT))
+       if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST))
+        && (e->render.alpha >= 1)
+        && !(e->render.flags & RENDER_VIEWMODEL)
         && (!(e->render.flags & RENDER_EXTERIORMODEL) || (!cl.intermission && cls.protocol != PROTOCOL_NEHAHRAMOVIE && !cl_noplayershadow.integer)))
                e->render.flags |= RENDER_SHADOW;
 }
@@ -995,7 +983,6 @@ void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit)
 // creates light and trails from an entity
 void CL_UpdateNetworkEntityTrail(entity_t *e)
 {
-       //matrix4x4_t dlightmatrix;
        effectnameindex_t trailtype;
        vec3_t origin;
 
@@ -1007,6 +994,8 @@ void CL_UpdateNetworkEntityTrail(entity_t *e)
                VectorMAM(0.5f, e->render.model->normalmins, 0.5f, e->render.model->normalmaxs, o);
                Matrix4x4_Transform(&e->render.matrix, o, origin);
        }
+       else
+               Matrix4x4_OriginFromMatrix(&e->render.matrix, origin);
 
        // handle particle trails and such effects now that we know where this
        // entity is in the world...
@@ -1233,7 +1222,7 @@ void CL_LinkNetworkEntity(entity_t *e)
                trace_t trace;
                matrix4x4_t tempmatrix;
                Matrix4x4_Transform(&e->render.matrix, muzzleflashorigin, v2);
-               trace = CL_TraceBox(origin, vec3_origin, vec3_origin, v2, true, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, false);
+               trace = CL_Move(origin, vec3_origin, vec3_origin, v2, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_SKY, true, false, NULL, false);
                Matrix4x4_Normalize(&tempmatrix, &e->render.matrix);
                Matrix4x4_SetOrigin(&tempmatrix, trace.endpos[0], trace.endpos[1], trace.endpos[2]);
                Matrix4x4_Scale(&tempmatrix, 150, 1);
@@ -1336,14 +1325,11 @@ static void CL_RelinkStaticEntities(void)
                // need to re-fetch the model pointer
                e->render.model = cl.model_precache[e->state_baseline.modelindex];
                CL_UpdateRenderEntity(&e->render);
-               // transparent stuff can't be lit during the opaque stage
-               if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
-                       e->render.flags |= RENDER_TRANSPARENT;
                // either fullbright or lit
                if (!(e->render.effects & EF_FULLBRIGHT) && !r_fullbright.integer)
                        e->render.flags |= RENDER_LIGHT;
                // hide player shadow during intermission or nehahra movie
-               if (!(e->render.effects & EF_NOSHADOW) && !(e->render.flags & RENDER_TRANSPARENT))
+               if (!(e->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (e->render.alpha >= 1))
                        e->render.flags |= RENDER_SHADOW;
                VectorSet(e->render.colormod, 1, 1, 1);
                R_LerpAnimation(&e->render);
@@ -1632,8 +1618,6 @@ CL_ReadFromServer
 Read all incoming data from the server
 ===============
 */
-extern void CL_StairSmoothing(void);//view.c
-
 int CL_ReadFromServer(void)
 {
        CL_ReadDemoMessage();
@@ -1662,8 +1646,6 @@ int CL_ReadFromServer(void)
                CL_RelinkLightFlashes();
                CSQC_RelinkAllEntities(ENTMASK_ENGINE | ENTMASK_ENGINEVIEWMODELS);
 
-               CL_StairSmoothing();
-
                // move particles
                CL_MoveParticles();
                R_MoveExplosions();
@@ -1732,6 +1714,11 @@ static void CL_TimeRefresh_f (void)
        Con_Printf("%f seconds (%f fps)\n", timedelta, 128/timedelta);
 }
 
+void CL_AreaStats_f(void)
+{
+       World_PrintAreaStats(&cl.world, "client");
+}
+
 /*
 ===========
 CL_Shutdown
@@ -1806,6 +1793,8 @@ void CL_Init (void)
        // LordHavoc: added pausedemo
        Cmd_AddCommand ("pausedemo", CL_PauseDemo_f, "pause demo playback (can also safely pause demo recording if using QUAKE, QUAKEDP or NEHAHRAMOVIE protocol, useful for making movies)");
 
+       Cmd_AddCommand ("cl_areastats", CL_AreaStats_f, "prints statistics on entity culling during collision traces");
+
        Cvar_RegisterVariable(&r_draweffects);
        Cvar_RegisterVariable(&cl_explosions_alpha_start);
        Cvar_RegisterVariable(&cl_explosions_alpha_end);