]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
fixed an unused variable warning
[xonotic/darkplaces.git] / cl_parse.c
index c67225d03e813ca94cd5737455b296c3452999a9..5d3b55e0cd51ce4ce2f457790c2a5b49915adf86 100644 (file)
@@ -152,7 +152,7 @@ void CL_ParseStartSoundPacket(int largesoundindex)
 
        MSG_ReadVector(pos, cl.protocol);
 
-       S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation);
+       S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0f, attenuation);
 }
 
 /*
@@ -407,13 +407,7 @@ void CL_ParseServerInfo (void)
        Mod_PurgeUnused();
 
        // do the same for sounds
-       S_ClearUsed();
-       for (i = 1;i < numsounds;i++)
-       {
-               CL_KeepaliveMessage();
-               S_TouchSound(parse_sound_precache[i], true);
-       }
-       S_PurgeUnused();
+       S_ServerSounds (parse_sound_precache, numsounds);
 
        // now we try to load everything that is new
 
@@ -435,7 +429,9 @@ void CL_ParseServerInfo (void)
        for (i=1 ; i<numsounds ; i++)
        {
                CL_KeepaliveMessage();
-               cl.sound_precache[i] = S_PrecacheSound(parse_sound_precache[i], true, true);
+
+               // Don't lock the sfx here, S_ServerSounds already did that 
+               cl.sound_precache[i] = S_PrecacheSound(parse_sound_precache[i], true, true, false);
        }
 
        // local state
@@ -486,7 +482,7 @@ void CL_ValidateState(entity_state_t *s)
                Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\"\n", s->frame, model->name);
                s->frame = 0;
        }
-       if (model && s->skin > 0 && s->skin >= model->numskins)
+       if (model && s->skin > 0 && s->skin >= model->numskins && !(s->lightpflags & PFLAGS_FULLDYNAMIC))
        {
                Con_DPrintf("CL_ValidateState: no such skin %i in \"%s\"\n", s->skin, model->name);
                s->skin = 0;
@@ -499,9 +495,26 @@ void CL_MoveLerpEntityStates(entity_t *ent)
        CL_ValidateState(&ent->state_current);
        VectorSubtract(ent->state_current.origin, ent->persistent.neworigin, odelta);
        VectorSubtract(ent->state_current.angles, ent->persistent.newangles, adelta);
-       if (!ent->state_previous.active || cls.timedemo || DotProduct(odelta, odelta) > 1000*1000 || cl_nolerp.integer)
+       if (!ent->state_previous.active || ent->state_previous.modelindex != ent->state_current.modelindex)
        {
-               // we definitely shouldn't lerp
+               // reset all persistent stuff if this is a new entity
+               ent->persistent.lerpdeltatime = 0;
+               ent->persistent.lerpstarttime = cl.mtime[1];
+               VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
+               VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
+               VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
+               VectorCopy(ent->state_current.angles, ent->persistent.newangles);
+               // reset animation interpolation as well
+               ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_current.frame;
+               ent->render.frame1time = ent->render.frame2time = cl.time;
+               ent->render.framelerp = 1;
+               // reset various persistent stuff
+               ent->persistent.muzzleflash = 0;
+               VectorCopy(ent->state_current.origin, ent->persistent.trail_origin);
+       }
+       else if (cls.timedemo || cl_nolerp.integer || DotProduct(odelta, odelta) > 1000*1000)
+       {
+               // don't interpolate the move
                ent->persistent.lerpdeltatime = 0;
                ent->persistent.lerpstarttime = cl.mtime[1];
                VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
@@ -525,12 +538,12 @@ void CL_MoveLerpEntityStates(entity_t *ent)
        else
        {
                // not a monster
-               ent->persistent.lerpstarttime = cl.mtime[1];
+               ent->persistent.lerpstarttime = ent->state_previous.time;
                // no lerp if it's singleplayer
                if (cl.islocalgame)
                        ent->persistent.lerpdeltatime = 0;
                else
-                       ent->persistent.lerpdeltatime = cl.mtime[0] - cl.mtime[1];
+                       ent->persistent.lerpdeltatime = bound(0, ent->state_current.time - ent->state_previous.time, 0.1);
                VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
                VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
                VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
@@ -777,7 +790,7 @@ void CL_ParseStaticSound (int large)
        vol = MSG_ReadByte ();
        atten = MSG_ReadByte ();
 
-       S_StaticSound (cl.sound_precache[sound_num], org, vol, atten);
+       S_StaticSound (cl.sound_precache[sound_num], org, vol/255.0f, atten);
 }
 
 void CL_ParseEffect (void)
@@ -828,13 +841,13 @@ CL_ParseTEnt
 */
 void CL_InitTEnts (void)
 {
-       cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav", false, true);
-       cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav", false, true);
-       cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav", false, true);
-       cl_sfx_ric1 = S_PrecacheSound ("weapons/ric1.wav", false, true);
-       cl_sfx_ric2 = S_PrecacheSound ("weapons/ric2.wav", false, true);
-       cl_sfx_ric3 = S_PrecacheSound ("weapons/ric3.wav", false, true);
-       cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav", false, true);
+       cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav", false, true, true);
+       cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav", false, true, true);
+       cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav", false, true, true);
+       cl_sfx_ric1 = S_PrecacheSound ("weapons/ric1.wav", false, true, true);
+       cl_sfx_ric2 = S_PrecacheSound ("weapons/ric2.wav", false, true, true);
+       cl_sfx_ric3 = S_PrecacheSound ("weapons/ric3.wav", false, true, true);
+       cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav", false, true, true);
 }
 
 void CL_ParseBeam (model_t *m, int lightning)
@@ -1534,15 +1547,10 @@ void CL_ParseServerMessage(void)
                case svc_setpause:
                        cl.paused = MSG_ReadByte ();
                        if (cl.paused)
-                       {
                                CDAudio_Pause ();
-                               S_PauseGameSounds ();
-                       }
                        else
-                       {
                                CDAudio_Resume ();
-                               S_ResumeGameSounds ();
-                       }
+                       S_PauseGameSounds (cl.paused);
                        break;
 
                case svc_signonnum: