+
+ lag = cl.mtime[0] - cl.cmd.time;
+ frames_per_tic = sv_frametime / cl.realframetime;
+// opportune_moment = lag <= cl.realframetime * 2; // FAIL: can miss the moment with uncapped fps
+// opportune_moment = lag <= cl.realframetime * frames_per_tic * 0.5; // FAIL: too early at high fps, reducing multi causes misses at moderate fps
+ opportune_moment = lag <= cl.realframetime * (frames_per_tic <= 1 ? 1 : sqrt(frames_per_tic)); // perfect
+
+ // Two methods for deciding when to send
+ if (!important)
+ {
+ // Traditional time interval, now used as fallback
+ if (sv_frametime <= 0 || lag > sv_frametime || lag < 0) // unknown ticrate || lag/PL || still connecting
+ {
+ if (cl.timesincepacket < packettime * 0.99999f)
+ {
+// Con_Printf("^6moveft %f realft %f lag %f tic %f inputsince %d\n", cl.cmd.frametime, cl.realframetime, lag, sv_frametime, cl.opt_inputs_since_update);
+ return;
+ }
+ }
+ // Server-synchronised, for better pings
+ // Sends at least once per server frame
+ else // cl.opt_inputs_since_update is usable
+ {
+ if (!opportune_moment || cl.opt_inputs_since_update >= sv_frametime / packettime)
+ {
+// Con_Printf("^1moveft %f realft %f lag %f tic %f inputsince %d\n", cl.cmd.frametime, cl.realframetime, lag, sv_frametime, cl.opt_inputs_since_update);
+ return;
+ }
+ }
+ }
+