From 095e88ef8734aafdeaee17a8de7827a6adc47002 Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 18 Jan 2007 10:39:02 +0000 Subject: [PATCH] fixed problems with cl.time stepping backwards causing a black fade-in and other problems git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6698 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 8 ++++---- cl_particles.c | 2 +- view.c | 9 ++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cl_main.c b/cl_main.c index 01a98318..0bfb1545 100644 --- a/cl_main.c +++ b/cl_main.c @@ -658,7 +658,7 @@ void CL_DecayLights(void) dlight_t *dl; float time, f; - time = cl.time - cl.oldtime; + time = bound(0, cl.time - cl.oldtime, 0.1); oldmax = cl.num_dlights; cl.num_dlights = 0; for (i = 0, dl = cl.dlights;i < oldmax;i++, dl++) @@ -1050,9 +1050,9 @@ void CL_UpdateNetworkEntity(entity_t *e) dlightcolor[2] += 1.50f; } if (e->render.effects & EF_FLAME) - CL_ParticleEffect(EFFECT_EF_FLAME, cl.time - cl.oldtime, origin, origin, vec3_origin, vec3_origin, NULL, 0); + CL_ParticleEffect(EFFECT_EF_FLAME, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0); if (e->render.effects & EF_STARDUST) - CL_ParticleEffect(EFFECT_EF_STARDUST, cl.time - cl.oldtime, origin, origin, vec3_origin, vec3_origin, NULL, 0); + CL_ParticleEffect(EFFECT_EF_STARDUST, bound(0, cl.time - cl.oldtime, 0.1), origin, origin, vec3_origin, vec3_origin, NULL, 0); if (e->render.effects & (EF_FLAG1QW | EF_FLAG2QW)) { // these are only set on player entities @@ -1067,7 +1067,7 @@ void CL_UpdateNetworkEntity(entity_t *e) tempmatrix = e->render.matrix; Matrix4x4_SetOrigin(&tempmatrix, trace.endpos[0], trace.endpos[1], trace.endpos[2]); CL_AllocDlight(NULL, &tempmatrix, 100, e->persistent.muzzleflash, e->persistent.muzzleflash, e->persistent.muzzleflash, 0, 0, 0, -1, true, 0, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE); - e->persistent.muzzleflash -= (cl.time - cl.oldtime) * 10; + e->persistent.muzzleflash -= bound(0, cl.time - cl.oldtime, 0.1) * 10; } // LordHavoc: if the model has no flags, don't check each if (e->render.model && e->render.model->flags && (!e->state_current.tagentity && !(e->render.flags & RENDER_VIEWMODEL))) diff --git a/cl_particles.c b/cl_particles.c index cf1e2718..4da00b2f 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -1421,7 +1421,7 @@ void CL_MoveParticles (void) return; } - frametime = cl.time - cl.oldtime; + frametime = bound(0, cl.time - cl.oldtime, 0.1); gravity = frametime * sv_gravity.value; dvel = 1+4*frametime; decalfade = frametime * 255 / cl_decals_fadetime.value; diff --git a/view.c b/view.c index 9506c948..4d0de9c8 100644 --- a/view.c +++ b/view.c @@ -322,17 +322,17 @@ CL_StairSmoothing void CL_StairSmoothing (void) { if (v_dmg_time > 0) - v_dmg_time -= (cl.time - cl.oldtime); + v_dmg_time -= bound(0, cl.time - cl.oldtime, 0.1); // stair smoothing if (cl.onground && cl.stairoffset < 0) { - cl.stairoffset += (cl.time - cl.oldtime) * cl_stairsmoothspeed.value; + cl.stairoffset += bound(0, cl.time - cl.oldtime, 0.1) * cl_stairsmoothspeed.value; cl.stairoffset = bound(-16, cl.stairoffset, 0); } else if (cl.onground && cl.stairoffset > 0) { - cl.stairoffset -= (cl.time - cl.oldtime) * cl_stairsmoothspeed.value; + cl.stairoffset -= bound(0, cl.time - cl.oldtime, 0.1) * cl_stairsmoothspeed.value; cl.stairoffset = bound(0, cl.stairoffset, 16); } else @@ -538,6 +538,9 @@ void V_CalcRefdef (void) void V_FadeViewFlashs(void) { + // don't flash if time steps backwards + if (cl.time <= cl.oldtime) + return; // drop the damage value cl.cshifts[CSHIFT_DAMAGE].percent -= (cl.time - cl.oldtime)*150; if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0) -- 2.39.2