mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Use the proper numbers to adjust lump's offset position
This commit is contained in:
parent
f7cf8e50f8
commit
ee9aa86ecd
1 changed files with 16 additions and 1 deletions
17
src/w_wad.c
17
src/w_wad.c
|
@ -529,6 +529,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
|
|||
zend_t zend;
|
||||
zentry_t* zentries;
|
||||
zentry_t* zentry;
|
||||
zlentry_t zlentry;
|
||||
|
||||
UINT16 numlumps = *nlmp;
|
||||
lumpinfo_t* lumpinfo;
|
||||
|
@ -580,7 +581,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
lump_p->position = zentry->offset + zentry->namelen + sizeof(zlentry_t);
|
||||
lump_p->position = zentry->offset; // NOT ACCURATE YET: we still need to read the local entry to find our true position
|
||||
lump_p->disksize = zentry->compsize;
|
||||
lump_p->size = zentry->size;
|
||||
|
||||
|
@ -642,6 +643,20 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
|
|||
|
||||
free(zentries);
|
||||
|
||||
// Adjust lump position values properly
|
||||
for (i = 0, lump_p = lumpinfo; i < numlumps; i++, lump_p++)
|
||||
{
|
||||
// skip and ignore comments/extra fields
|
||||
if ((fseek(handle, lump_p->position, SEEK_SET) != 0) || (fread(&zlentry, 1, sizeof(zlentry_t), handle) < sizeof(zlentry_t)))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Local headers for lump %s are corrupt\n", lump_p->name2);
|
||||
Z_Free(lumpinfo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lump_p->position += sizeof(zlentry_t) + zlentry.namelen + zlentry.xtralen;
|
||||
}
|
||||
|
||||
*nlmp = numlumps;
|
||||
return lumpinfo;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue