diff --git a/include/netchan.h b/include/netchan.h index 0d7e565af..02c5bb551 100644 --- a/include/netchan.h +++ b/include/netchan.h @@ -138,6 +138,7 @@ typedef struct extern int net_drop; // packets dropped before this one extern int net_nochoke; // don't choke packets extern int net_blocksend; // don't send packets (used by client for demos) +extern double *net_realtime; void Netchan_Init (void); void Netchan_Init_Cvars (void); diff --git a/libs/net/net_chan.c b/libs/net/net_chan.c index 93f736cc4..b3e3a80be 100644 --- a/libs/net/net_chan.c +++ b/libs/net/net_chan.c @@ -106,6 +106,7 @@ static __attribute__ ((unused)) const char rcsid[] = int net_drop; int net_nochoke; int net_blocksend; +double *net_realtime; cvar_t *showpackets; cvar_t *showdrop; cvar_t *qport; @@ -193,7 +194,7 @@ Netchan_Setup (netchan_t *chan, netadr_t adr, int qport, int flags) memset (chan, 0, sizeof (*chan)); chan->remote_address = adr; - chan->last_received = realtime; + chan->last_received = *net_realtime; chan->message.data = chan->message_buf; chan->message.allowoverflow = true; @@ -215,7 +216,7 @@ Netchan_Setup (netchan_t *chan, netadr_t adr, int qport, int flags) qboolean Netchan_CanPacket (netchan_t *chan) { - if (chan->cleartime < realtime + MAX_BACKUP * chan->rate) + if (chan->cleartime < *net_realtime + MAX_BACKUP * chan->rate) return true; return false; } @@ -301,18 +302,18 @@ Netchan_Transmit (netchan_t *chan, int length, byte *data) // send the datagram i = chan->outgoing_sequence & (MAX_LATENT - 1); chan->outgoing_size[i] = send.cursize; - chan->outgoing_time[i] = realtime; + chan->outgoing_time[i] = *net_realtime; // zoid, no input in demo playback mode if (!net_blocksend) Netchan_SendPacket (send.cursize, send.data, chan->remote_address); - if (chan->cleartime < realtime) - chan->cleartime = realtime + send.cursize * chan->rate; + if (chan->cleartime < *net_realtime) + chan->cleartime = *net_realtime + send.cursize * chan->rate; else chan->cleartime += send.cursize * chan->rate; if (net_nochoke) - chan->cleartime = realtime; + chan->cleartime = *net_realtime; if (showpackets->int_val) Con_Printf ("--> s=%i(%i) a=%i(%i) %i\n", chan->outgoing_sequence, @@ -362,7 +363,7 @@ Netchan_Process (netchan_t *chan) double time, rate; i = sequence_ack & (MAX_LATENT - 1); - time = realtime - chan->outgoing_time[i]; + time = *net_realtime - chan->outgoing_time[i]; time -= 0.1; // subtract 100 ms if (time <= 0) { // gotta be a digital link for <100 // ms ping @@ -420,10 +421,10 @@ Netchan_Process (netchan_t *chan) chan->frame_latency = chan->frame_latency * OLD_AVG + (chan->outgoing_sequence - sequence_ack) * (1.0 - OLD_AVG); chan->frame_rate = chan->frame_rate * OLD_AVG - + (realtime - chan->last_received) * (1.0 - OLD_AVG); + + (*net_realtime - chan->last_received) * (1.0 - OLD_AVG); chan->good_count += 1; - chan->last_received = realtime; + chan->last_received = *net_realtime; return true; } diff --git a/qtv/source/qtv.c b/qtv/source/qtv.c index c0249f3fb..9d0224608 100644 --- a/qtv/source/qtv.c +++ b/qtv/source/qtv.c @@ -55,12 +55,9 @@ static plugin_list_t server_plugin_list[] = { SERVER_PLUGIN_LIST }; -double realtime; cvar_t *net_packetlog; void Log_Outgoing_Packet (const char *p, int len, int has_sequence); -void Log_Incoming_Packet (const char *p, int len, int has_sequence); void Log_Outgoing_Packet (const char *p, int len, int has_sequence) { } -void Log_Incoming_Packet (const char *p, int len, int has_sequence) { } cbuf_t *qtv_cbuf; diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 6c570e46d..68740c9d8 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1723,6 +1723,7 @@ Host_Init (void) NET_Init (cl_port->int_val); Netchan_Init (); + net_realtime = &realtime; { static const char *sound_precache[MAX_MODELS]; int i; diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index e383f8bda..1b543bbff 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -2416,6 +2416,7 @@ SV_InitNet (void) NET_Init (port); Netchan_Init (); + net_realtime = &realtime; Net_Log_Init (sv.sound_precache);