Skip to content

Commit

Permalink
Netchan_CreateFileFragments: Fixed a very old and rare bug with dlfil…
Browse files Browse the repository at this point in the history
…e while downloading direct from server, when content of resource size is less than header size first fragment
  • Loading branch information
s1lentq committed Aug 24, 2022
1 parent e9045e3 commit d76b06d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rehlds/engine/net_chan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,10 @@ void Netchan_CreateFileFragmentsFromBuffer(qboolean server, netchan_t *chan, con
MSG_WriteString(&buf->frag_message, filename);
MSG_WriteString(&buf->frag_message, bCompressed ? "bz2" : "uncompressed");
MSG_WriteLong(&buf->frag_message, uncompressed_size);
send -= buf->frag_message.cursize;

// Check if we aren't send more than we should
if ((chunksize - send) < buf->frag_message.cursize)
send -= buf->frag_message.cursize;
}

buf->isbuffer = TRUE;
Expand Down Expand Up @@ -1321,7 +1324,7 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
remaining = filesize;
pos = 0;

while (remaining)
while (remaining > 0)
{
send = min(chunksize, remaining);
buf = Netchan_AllocFragbuf();
Expand Down Expand Up @@ -1353,7 +1356,10 @@ int Netchan_CreateFileFragments_(qboolean server, netchan_t *chan, const char *f
MSG_WriteString(&buf->frag_message, filename);
MSG_WriteString(&buf->frag_message, bCompressed ? "bz2" : "uncompressed");
MSG_WriteLong(&buf->frag_message, uncompressed_size);
send -= buf->frag_message.cursize;

// Check if we aren't send more than we should
if ((chunksize - send) < buf->frag_message.cursize)
send -= buf->frag_message.cursize;
}
buf->isfile = TRUE;
buf->iscompressed = bCompressed;
Expand Down

0 comments on commit d76b06d

Please sign in to comment.