mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 12:52:46 +00:00
Port a few of Tonik's networking improvements, under different names.
cl_maxnetfps (his cl_c2spps), controls number of frames worth of command packets sent per second. So you can now crank your cl_maxfps, and tweak networking independently. Also, cl_spamimpulse (his cl_c2sImpulseBackup), controls number of duplicate packets spammed to attempt to make impulses reliably reach the server. 3 is default, same as id. Experiment with lowering it at your risk (higher does nothing).
This commit is contained in:
parent
29a8d84806
commit
5a356259f5
1 changed files with 50 additions and 5 deletions
|
@ -57,6 +57,8 @@ static const char rcsid[] =
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
|
||||||
cvar_t *cl_nodelta;
|
cvar_t *cl_nodelta;
|
||||||
|
cvar_t *cl_maxnetfps;
|
||||||
|
cvar_t *cl_spamimpulse;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
KEY BUTTONS
|
KEY BUTTONS
|
||||||
|
@ -75,7 +77,6 @@ cvar_t *cl_nodelta;
|
||||||
state bit 2 is edge triggered on the down to up transition
|
state bit 2 is edge triggered on the down to up transition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
kbutton_t in_left, in_right, in_forward, in_back;
|
kbutton_t in_left, in_right, in_forward, in_back;
|
||||||
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
||||||
kbutton_t in_use, in_jump, in_attack;
|
kbutton_t in_use, in_jump, in_attack;
|
||||||
|
@ -608,10 +609,13 @@ CL_FinishMove (usercmd_t *cmd)
|
||||||
void
|
void
|
||||||
CL_SendCmd (void)
|
CL_SendCmd (void)
|
||||||
{
|
{
|
||||||
byte data[128];
|
byte data[128];
|
||||||
int checksumIndex, lost, seq_hash, i;
|
static float pps_balance = 0.0;
|
||||||
sizebuf_t buf;
|
static int dropcount = 0;
|
||||||
usercmd_t *cmd, *oldcmd;
|
int checksumIndex, lost, seq_hash, i;
|
||||||
|
qboolean dontdrop; // FIXME: needed without cl_c2sImpulseBackup?
|
||||||
|
sizebuf_t buf;
|
||||||
|
usercmd_t *cmd, *oldcmd;
|
||||||
|
|
||||||
if (cls.demoplayback)
|
if (cls.demoplayback)
|
||||||
return; // sendcmds come from the demo
|
return; // sendcmds come from the demo
|
||||||
|
@ -655,18 +659,26 @@ CL_SendCmd (void)
|
||||||
lost = CL_CalcNet ();
|
lost = CL_CalcNet ();
|
||||||
MSG_WriteByte (&buf, (byte) lost);
|
MSG_WriteByte (&buf, (byte) lost);
|
||||||
|
|
||||||
|
dontdrop = false;
|
||||||
|
|
||||||
i = (cls.netchan.outgoing_sequence - 2) & UPDATE_MASK;
|
i = (cls.netchan.outgoing_sequence - 2) & UPDATE_MASK;
|
||||||
cmd = &cl.frames[i].cmd;
|
cmd = &cl.frames[i].cmd;
|
||||||
|
if (cl_spamimpulse->int_val >= 2)
|
||||||
|
dontdrop = dontdrop || cmd->impulse;
|
||||||
MSG_WriteDeltaUsercmd (&buf, &nullcmd, cmd);
|
MSG_WriteDeltaUsercmd (&buf, &nullcmd, cmd);
|
||||||
oldcmd = cmd;
|
oldcmd = cmd;
|
||||||
|
|
||||||
i = (cls.netchan.outgoing_sequence - 1) & UPDATE_MASK;
|
i = (cls.netchan.outgoing_sequence - 1) & UPDATE_MASK;
|
||||||
cmd = &cl.frames[i].cmd;
|
cmd = &cl.frames[i].cmd;
|
||||||
|
if (cl_spamimpulse->int_val >= 3)
|
||||||
|
dontdrop = dontdrop || cmd->impulse;
|
||||||
MSG_WriteDeltaUsercmd (&buf, oldcmd, cmd);
|
MSG_WriteDeltaUsercmd (&buf, oldcmd, cmd);
|
||||||
oldcmd = cmd;
|
oldcmd = cmd;
|
||||||
|
|
||||||
i = (cls.netchan.outgoing_sequence) & UPDATE_MASK;
|
i = (cls.netchan.outgoing_sequence) & UPDATE_MASK;
|
||||||
cmd = &cl.frames[i].cmd;
|
cmd = &cl.frames[i].cmd;
|
||||||
|
if (cl_spamimpulse->int_val >= 1)
|
||||||
|
dontdrop = dontdrop || cmd->impulse;
|
||||||
MSG_WriteDeltaUsercmd (&buf, oldcmd, cmd);
|
MSG_WriteDeltaUsercmd (&buf, oldcmd, cmd);
|
||||||
|
|
||||||
// calculate a checksum over the move commands
|
// calculate a checksum over the move commands
|
||||||
|
@ -691,6 +703,32 @@ CL_SendCmd (void)
|
||||||
if (cls.demorecording)
|
if (cls.demorecording)
|
||||||
CL_WriteDemoCmd (cmd);
|
CL_WriteDemoCmd (cmd);
|
||||||
|
|
||||||
|
if (cl_maxnetfps->int_val) {
|
||||||
|
pps_balance += host_frametime;
|
||||||
|
// never drop more than 2 messages in a row -- that'll cause PL
|
||||||
|
// and don't drop if one of the last two movemessages have an impulse
|
||||||
|
if (pps_balance > 0.0 || dropcount >= 2 || dontdrop) {
|
||||||
|
float pps;
|
||||||
|
|
||||||
|
pps = cl_maxnetfps->int_val;
|
||||||
|
if (pps < 10) pps = 10;
|
||||||
|
if (pps > 72) pps = 72;
|
||||||
|
pps_balance -= 1.0 / pps;
|
||||||
|
pps_balance = bound (-0.1, pps_balance, 0.1);
|
||||||
|
dropcount = 0;
|
||||||
|
} else {
|
||||||
|
// don't count this message when calculating PL
|
||||||
|
cl.frames[i].receivedtime = -3;
|
||||||
|
// drop this message
|
||||||
|
cls.netchan.outgoing_sequence++;
|
||||||
|
dropcount++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pps_balance = 0;
|
||||||
|
dropcount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// deliver the message
|
// deliver the message
|
||||||
Netchan_Transmit (&cls.netchan, buf.cursize, buf.data);
|
Netchan_Transmit (&cls.netchan, buf.cursize, buf.data);
|
||||||
}
|
}
|
||||||
|
@ -777,4 +815,11 @@ CL_Input_Init_Cvars (void)
|
||||||
cl_nodelta = Cvar_Get ("cl_nodelta", "0", CVAR_NONE, NULL,
|
cl_nodelta = Cvar_Get ("cl_nodelta", "0", CVAR_NONE, NULL,
|
||||||
"Disable player delta compression. Set to 1 if you "
|
"Disable player delta compression. Set to 1 if you "
|
||||||
"have a poor ISP and get many U_REMOVE warnings.");
|
"have a poor ISP and get many U_REMOVE warnings.");
|
||||||
|
cl_maxnetfps = Cvar_Get ("cl_maxnetfps", "0", CVAR_ARCHIVE, NULL,
|
||||||
|
"Controls number of command packets sent per "
|
||||||
|
"second. Default 0 is unlimited.");
|
||||||
|
cl_spamimpulse = Cvar_Get ("cl_spamimpulse", "3", CVAR_NONE, NULL,
|
||||||
|
"Controls number of duplicate packets sent if "
|
||||||
|
"an impulse is being sent. Default (id "
|
||||||
|
"behavior) is 3.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue