From f725b23c4fabf8629a23858aec641bf6db1a29b9 Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Sat, 29 Jan 2011 22:01:55 +0000 Subject: [PATCH] Fix floating point imprecision causing glitches in snapshot sending --- code/server/sv_snapshot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/server/sv_snapshot.c b/code/server/sv_snapshot.c index d84a1895..b2b4b225 100644 --- a/code/server/sv_snapshot.c +++ b/code/server/sv_snapshot.c @@ -555,7 +555,7 @@ static int SV_RateMsec( client_t *client, int messageSize ) { rate = sv_minRate->integer; } - rateMsec = ( messageSize + HEADER_RATE_BYTES ) * 1000 / rate * com_timescale->value; + rateMsec = ( messageSize + HEADER_RATE_BYTES ) * 1000 / ((int) (rate * com_timescale->value)); return rateMsec; } @@ -584,7 +584,7 @@ void SV_SendMessageToClient( msg_t *msg, client_t *client ) { // TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=491 // added sv_lanForceRate check if ( client->netchan.remoteAddress.type == NA_LOOPBACK || (sv_lanForceRate->integer && Sys_IsLANAddress (client->netchan.remoteAddress)) ) { - client->nextSnapshotTime = svs.time + (1000.0 / sv_fps->integer * com_timescale->value); + client->nextSnapshotTime = svs.time + ((int) (1000.0 / sv_fps->integer * com_timescale->value)); return; } @@ -599,15 +599,15 @@ void SV_SendMessageToClient( msg_t *msg, client_t *client ) { client->rateDelayed = qtrue; } - client->nextSnapshotTime = svs.time + rateMsec * com_timescale->value; + client->nextSnapshotTime = svs.time + ((int) (rateMsec * com_timescale->value)); // don't pile up empty snapshots while connecting if ( client->state != CS_ACTIVE ) { // a gigantic connection message may have already put the nextSnapshotTime // more than a second away, so don't shorten it // do shorten if client is downloading - if (!*client->downloadName && client->nextSnapshotTime < svs.time + 1000 * com_timescale->value) - client->nextSnapshotTime = svs.time + 1000 * com_timescale->value; + if (!*client->downloadName && client->nextSnapshotTime < svs.time + ((int) (1000.0 * com_timescale->value))) + client->nextSnapshotTime = svs.time + ((int) (1000 * com_timescale->value)); } }