A small tweek that tracks download sizes proprly with chunked/file downloads.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1411 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2005-10-04 18:06:49 +00:00
parent 18ecdd5ca4
commit c815c72a23

View file

@ -77,6 +77,8 @@ typedef struct {
int bufferused; int bufferused;
int bufferlen; int bufferlen;
int totalreceived; //useful when we're just dumping to a file.
qboolean chunking; qboolean chunking;
int chunksize; int chunksize;
int chunked; int chunked;
@ -309,6 +311,7 @@ static qboolean HTTP_CL_Run(http_con_t *con)
} }
con->totalreceived+=con->chunked;
if (con->file && con->chunked) //we've got a chunk in the buffer if (con->file && con->chunked) //we've got a chunk in the buffer
{ //write it { //write it
IWebFWrite(con->buffer, con->chunked, 1, con->file); IWebFWrite(con->buffer, con->chunked, 1, con->file);
@ -320,6 +323,7 @@ static qboolean HTTP_CL_Run(http_con_t *con)
} }
else else
{ {
con->totalreceived+=ammount;
if (con->file) //we've got a chunk in the buffer if (con->file) //we've got a chunk in the buffer
{ //write it { //write it
IWebFWrite(con->buffer, con->bufferused, 1, con->file); IWebFWrite(con->buffer, con->bufferused, 1, con->file);
@ -399,7 +403,7 @@ void HTTP_CL_Think(void)
else if (con->contentlength <= 0) else if (con->contentlength <= 0)
cls.downloadpercent = 50; cls.downloadpercent = 50;
else else
cls.downloadpercent = con->bufferused*100.0f/con->contentlength; cls.downloadpercent = con->totalreceived*100.0f/con->contentlength;
} }
} }
} }