From 5c0b7731112f3f9ce8e530bfc8d4898c8ef523df Mon Sep 17 00:00:00 2001 From: TimeServ Date: Wed, 2 Aug 2006 05:34:17 +0000 Subject: [PATCH] added cl_dlemptyterminate, when set to 1 the client will assume downloads are finished when a empty (0 size) svc_download is received (defaults to 1), ensure server treats percent value properly with downloads git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2368 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_main.c | 2 ++ engine/client/cl_parse.c | 7 +++++++ engine/server/sv_user.c | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index b080e695d..21d223308 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -141,6 +141,8 @@ cvar_t msg_filter = SCVAR("msg_filter", "0"); //0 for neither, 1 for mm1, 2 for cvar_t cl_standardmsg = SCVARF("cl_standardmsg", "0", CVAR_ARCHIVE); cvar_t cl_parsewhitetext = SCVAR("cl_parsewhitetext", "1"); +cvar_t cl_dlemptyterminate = SCVAR("cl_dlemptyterminate", "1"); + cvar_t host_mapname = FCVAR("host_mapname", "mapname", "", 0); extern cvar_t cl_hightrack; diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 3a83cf93f..ec938101e 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1155,6 +1155,7 @@ A download message has been received from the server */ void CL_ParseDownload (void) { + extern cvar_t cl_dlemptyterminate; int size, percent; qbyte name[1024]; @@ -1255,6 +1256,12 @@ void CL_ParseDownload (void) if (cls.downloadmethod == DL_QWPENDING) cls.downloadmethod = DL_QW; + if (size == 0 && cl_dlemptyterminate.value) + { + Con_Printf("Client received empty svc_download, assuming EOF\n"); + percent = 100; + } + if (percent != 100) { // change display routines by zoid diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 28339171a..39018993b 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -1475,9 +1475,17 @@ void SV_NextDownload_f (void) host_client->downloadcount += r; size = host_client->downloadsize; - if (!size) - size = 1; - percent = host_client->downloadcount*100/size; + + if (host_client->downloadcount < size) + { + if (!size) + size = 1; + + percent = (double)host_client->downloadcount*100.0/size; + percent = bound(0, percent, 99); + } + else + percent = 100; #ifdef PEXT_ZLIBDL if (host_client->fteprotocolextensions & PEXT_ZLIBDL) @@ -1492,7 +1500,7 @@ void SV_NextDownload_f (void) ClientReliableWrite_SZ (host_client, buffer, r); } - if (host_client->downloadcount != host_client->downloadsize) + if (host_client->downloadcount < host_client->downloadsize) return; VFS_CLOSE (host_client->download);