]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_input.c
protocol/dp8: Implement parting messages
[xonotic/darkplaces.git] / cl_input.c
index 922db005dc558c382a3e2548c07f5db542e7b4cf..7c5598ca54960ff1666673a5efaeb4ca52060193 100644 (file)
@@ -1757,7 +1757,6 @@ void CL_SendMove(void)
        sizebuf_t buf;
        unsigned char data[1024];
        float packettime;
-       int msecdelta;
        qbool quemove;
        qbool important;
 
@@ -1813,12 +1812,14 @@ void CL_SendMove(void)
        // set viewangles
        VectorCopy(cl.viewangles, cl.cmd.viewangles);
 
-       msecdelta = (int)(floor(cl.cmd.time * 1000) - floor(cl.movecmd[1].time * 1000));
-       cl.cmd.msec = (unsigned char)bound(0, msecdelta, 255);
+       // bones_was_here: previously cl.cmd.frametime was floored to nearest millisec
+       // this meant the smoothest async movement required integer millisec
+       // client and server frame times (eg 125fps)
+       cl.cmd.frametime = bound(0.0, cl.cmd.time - cl.movecmd[1].time, 0.255);
        // ridiculous value rejection (matches qw)
-       if (cl.cmd.msec > 250)
-               cl.cmd.msec = 100;
-       cl.cmd.frametime = cl.cmd.msec * (1.0 / 1000.0);
+       if (cl.cmd.frametime > 0.25)
+               cl.cmd.frametime = 0.1;
+       cl.cmd.msec = (unsigned char)floor(cl.cmd.frametime * 1000);
 
        switch(cls.protocol)
        {
@@ -1828,6 +1829,7 @@ void CL_SendMove(void)
                break;
        case PROTOCOL_DARKPLACES6:
        case PROTOCOL_DARKPLACES7:
+       case PROTOCOL_DARKPLACES8:
                cl.cmd.predicted = cl_movement.integer != 0;
                break;
        default:
@@ -1859,6 +1861,7 @@ void CL_SendMove(void)
                break;
        case PROTOCOL_DARKPLACES6:
        case PROTOCOL_DARKPLACES7:
+       case PROTOCOL_DARKPLACES8:
                // FIXME: cl.cmd.buttons & 16 is +button5, Nexuiz/Xonotic specific
                cl.cmd.crouch = (cl.cmd.buttons & 16) != 0;
                break;
@@ -1937,6 +1940,7 @@ void CL_SendMove(void)
        // PROTOCOL_DARKPLACES5  clc_move = 19 bytes total
        // PROTOCOL_DARKPLACES6  clc_move = 52 bytes total
        // PROTOCOL_DARKPLACES7  clc_move = 56 bytes total per move (can be up to 16 moves)
+       // PROTOCOL_DARKPLACES8  clc_move = 56 bytes total per move (can be up to 16 moves)
        // PROTOCOL_QUAKEWORLD   clc_move = 34 bytes total (typically, but can reach 43 bytes, or even 49 bytes with roll)
 
        // set prydon cursor info
@@ -2038,6 +2042,7 @@ void CL_SendMove(void)
                        MSG_WriteByte (&buf, cl.cmd.impulse);
                case PROTOCOL_DARKPLACES6:
                case PROTOCOL_DARKPLACES7:
+               case PROTOCOL_DARKPLACES8:
                        // set the maxusercmds variable to limit how many should be sent
                        maxusercmds = bound(1, cl_netrepeatinput.integer + 1, min(3, CL_MAX_USERCMDS));
                        // when movement prediction is off, there's not much point in repeating old input as it will just be ignored
@@ -2162,13 +2167,7 @@ void CL_SendMove(void)
        in_impulse = 0;
 
        if (cls.netcon->message.overflowed)
-       {
-               Con_Print("CL_SendMove: lost server connection\n");
-               CL_Disconnect();
-               SV_LockThreadMutex();
-               SV_Shutdown();
-               SV_UnlockThreadMutex();
-       }
+               CL_Disconnect(true, "Lost connection to server");
 }
 
 /*