]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/csqcmodellib/cl_player.qc
save/restore velocity, don't ask why
[xonotic/xonotic-data.pk3dir.git] / qcsrc / csqcmodellib / cl_player.qc
index 66b32befab0ea247f6f219511c7768f86da841d2..62cfddccf8758f593e553ff43e8fce49b6937589 100644 (file)
@@ -99,6 +99,8 @@ void CSQCPlayer_PredictTo(float endframe)
 
        csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
 
+       // FIXME do we really NEED this? dead players have servercommandframe
+       // == 0 and thus won't predict
        if (getstatf(STAT_HEALTH) <= 0)
        {
                csqcplayer_moveframe = clientcommandframe;
@@ -106,15 +108,21 @@ void CSQCPlayer_PredictTo(float endframe)
                return;
        }
 
-       while(csqcplayer_moveframe < endframe)
+       if(csqcplayer_moveframe >= endframe)
        {
-               if (!getinputstate(csqcplayer_moveframe))
+               getinputstate(csqcplayer_moveframe - 1);
+       }
+       else
+       {
+               do
                {
-                       break;
+                       if (!getinputstate(csqcplayer_moveframe))
+                               break;
+                       runstandardplayerphysics(self);
+                       CSQCPlayer_SetMinsMaxs();
+                       csqcplayer_moveframe++;
                }
-               runstandardplayerphysics(self);
-               CSQCPlayer_SetMinsMaxs();
-               csqcplayer_moveframe++;
+               while(csqcplayer_moveframe < endframe);
        }
 
        //add in anything that was applied after (for low packet rate protocols)
@@ -130,6 +138,9 @@ void(entity e, float fl) V_CalcRefdef = #640; // DP_CSQC_V_CALCREFDEF
 
 void CSQCPlayer_SetCamera()
 {
+       vector v0;
+       v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
+
        if(csqcplayer)
        {
                entity oldself;
@@ -161,6 +172,9 @@ void CSQCPlayer_SetCamera()
 
                        // override it back just in case
                        self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT);
+
+                       // set velocity
+                       self.velocity = v0;
                }
                else
                {
@@ -168,12 +182,11 @@ void CSQCPlayer_SetCamera()
                        {
                                vector o, v;
                                o = self.origin;
-                               v = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
                                csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
                                CSQCPlayer_PredictTo(servercommandframe + 1);
                                CSQCPlayer_SetPredictionError(o - self.origin);
                                self.origin = o;
-                               self.velocity = v;
+                               self.velocity = v0;
 
                                // get crouch state from the server
                                if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z)
@@ -209,7 +222,7 @@ void CSQCPlayer_SetCamera()
        view = CSQCModel_server2csqc(player_localentnum);
 #endif
 
-       if(view != csqcplayer)
+       if(view && view != csqcplayer)
        {
                entity oldself = self;
                self = view;
@@ -237,7 +250,22 @@ void CSQCPlayer_SetCamera()
                if(input_buttons & 4)
                        refdefflags |= REFDEFFLAG_JUMPING;
 
+               // note: these two only work in WIP2, but are harmless in WIP1
+               if(getstati(STAT_HEALTH) <= 0)
+                       refdefflags |= REFDEFFLAG_DEAD;
+
+               if(intermission)
+                       refdefflags |= REFDEFFLAG_INTERMISSION;
+
+               // FIXME this is a stupid hack and is only there because
+               // bobfall got unreliable otherwise (it restores the old
+               // behaviour); need to find out why
+               vector vsave = view.velocity;
+               view.velocity = v0;
+
                V_CalcRefdef(view, refdefflags);
+
+               view.velocity = vsave;
        }
        else
        {