static unsigned char olddata[NET_MAXMESSAGE];
void CL_KeepaliveMessage (qboolean readmessages)
{
+ static double lastdirtytime = 0;
static qboolean recursive = false;
- double time;
- static double nextmsg = -1;
- static double nextupdate = -1;
-#if 0
- static double lasttime = -1;
-#endif
+ double dirtytime;
+ double deltatime;
+ static double countdownmsg = 0;
+ static double countdownupdate = 0;
sizebuf_t old;
qboolean thisrecursive;
thisrecursive = recursive;
recursive = true;
- time = Sys_DirtyTime();
+ dirtytime = Sys_DirtyTime();
+ deltatime = dirtytime - lastdirtytime;
+ lastdirtytime = dirtytime;
+ if (deltatime <= 0 || deltatime >= 1800.0)
+ return;
+
+ countdownmsg -= deltatime;
+ countdownupdate -= deltatime;
+
if(!thisrecursive)
{
if(cls.state != ca_dedicated)
{
- if(time >= nextupdate || time < nextupdate) // check if time stepped backwards
+ if(countdownupdate <= 0) // check if time stepped backwards
{
SCR_UpdateLoadingScreenIfShown();
- nextupdate = time + 2;
+ countdownupdate = 2;
}
}
}
// no need if server is local and definitely not if this is a demo
- if (!cls.netcon || cls.protocol == PROTOCOL_QUAKEWORLD || cls.signon >= SIGNONS)
+ if (sv.active || !cls.netcon || cls.protocol == PROTOCOL_QUAKEWORLD || cls.signon >= SIGNONS)
{
recursive = thisrecursive;
return;
memcpy(cl_message.data, olddata, cl_message.cursize);
}
- if (cls.netcon && (time >= nextmsg || time < nextmsg)) // check if time stepped backwards
+ if (cls.netcon && countdownmsg <= 0) // check if time stepped backwards
{
sizebuf_t msg;
unsigned char buf[4];
- nextmsg = time + 5;
+ countdownmsg = 5;
// write out a nop
// LordHavoc: must use unreliable because reliable could kill the sigon message!
Con_Print("--> client to server keepalive\n");
// LordHavoc: making sure the tokenizebuffer doesn't get filled up by repeated crashes
cmd_tokenizebufferpos = 0;
- Cbuf_Execute_Deferred();
while (cmd_text.cursize)
{
// find a \n or ; line break
}
}
+void Cbuf_Frame(void)
+{
+ Cbuf_Execute_Deferred();
+ if (cmd_text.cursize)
+ {
+ SV_LockThreadMutex();
+ Cbuf_Execute();
+ SV_UnlockThreadMutex();
+ }
+}
+
/*
==============================================================================
// otherwise we execute them on client frames
if (sv.active ? sv_timer > 0 : cl_timer > 0)
{
- SV_LockThreadMutex();
// process console commands
// R_TimeReport("preconsole");
CL_VM_PreventInformationLeaks();
- Cbuf_Execute();
+ Cbuf_Frame();
// R_TimeReport("console");
- SV_UnlockThreadMutex();
}
//Con_Printf("%6.0f %6.0f\n", cl_timer * 1000000.0, sv_timer * 1000000.0);