mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-13 21:31:32 +00:00
Only reseek if we have to
Makes it act similarly to before if only 1 node needs the file.
This commit is contained in:
parent
cc54d98a39
commit
c332d48e9d
1 changed files with 9 additions and 2 deletions
|
@ -103,6 +103,7 @@ typedef struct fileused_s
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
UINT8 count;
|
UINT8 count;
|
||||||
|
UINT32 position;
|
||||||
} fileused_t;
|
} fileused_t;
|
||||||
|
|
||||||
static fileused_t transferFiles[UINT8_MAX + 1];
|
static fileused_t transferFiles[UINT8_MAX + 1];
|
||||||
|
@ -895,7 +896,7 @@ void SV_FileSendTicker(void)
|
||||||
if (filesize == -1)
|
if (filesize == -1)
|
||||||
I_Error("Error getting filesize of %s", f->id.filename);
|
I_Error("Error getting filesize of %s", f->id.filename);
|
||||||
|
|
||||||
f->size = (UINT32)filesize;
|
f->size = transferFiles[f->fileid].position = (UINT32)filesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer[i].position = 0;
|
transfer[i].position = 0;
|
||||||
|
@ -904,7 +905,11 @@ void SV_FileSendTicker(void)
|
||||||
|
|
||||||
if (!ram)
|
if (!ram)
|
||||||
{
|
{
|
||||||
fseek(transferFiles[f->fileid].file, transfer[i].position, SEEK_SET);
|
// Seek to the right position if we aren't already there.
|
||||||
|
if (transferFiles[f->fileid].position != transfer[i].position)
|
||||||
|
{
|
||||||
|
fseek(transferFiles[f->fileid].file, transfer[i].position, SEEK_SET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a packet containing a file fragment
|
// Build a packet containing a file fragment
|
||||||
|
@ -924,6 +929,8 @@ void SV_FileSendTicker(void)
|
||||||
{
|
{
|
||||||
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s",
|
I_Error("SV_FileSendTicker: can't read %s byte on %s at %d because %s",
|
||||||
sizeu1(size), f->id.filename, transfer[i].position, M_FileError(transferFiles[f->fileid].file));
|
sizeu1(size), f->id.filename, transfer[i].position, M_FileError(transferFiles[f->fileid].file));
|
||||||
|
|
||||||
|
transferFiles[f->fileid].position = (UINT32)(transferFiles[f->fileid].position + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
p->position = LONG(transfer[i].position);
|
p->position = LONG(transfer[i].position);
|
||||||
|
|
Loading…
Reference in a new issue