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);