Thread: PK3 read errors
View Single Post
Old 01-13-2019   #4
Nev3r
Developer
 
Nev3r's Avatar
Default

I wasn't aware of that fix; seems to fix an ugly bug (oops, sorry about that one) related to comments and extra fields; that may have been what was causing problems for WinRAR-generated archives.

Regardless, the sorted central directory still seems to be a requirement, so you'll still get odd behaviors when not using SLADE.


I apologize for not explaining this properly before: SRB2 currently loads PK3s in a slightly similar way as WADs: instead of looking for FF_START, FF_END, it looks for the first entry called, for example, "Sprites/*", and assumes it is the folder entry, and treats it as the start marker. If found, then it looks for the next entry which DOESN'T have "Sprites/*" in its name, and treats it as the end marker. The rest of entries in between are loaded almost (if not exactly, I forget) identically to WADs.
What SLADE does is to organize those entries in a tree-like structure, just as I posted earlier. This is not a necessity in PKZip's specs, but it's required in SRB2 because of the way lumps are loaded as data. What WinRAR does, for example, is to place the latest added entry to the end of the list, instead of sorting them. This isn't a problem for SLADE, WinRAR, nor any other file explorers, but since it is unsorted, SRB2's "find start/end" method fails, and leads to entries not being loaded.


It could be possible to, instead of using markers, check every single entry individually and compare their names, without assuming folder limits. This would fix the problem for most resources, however I'm unsure about sprites; as I recall, either the markers or lump/entry ordering is a necessity of some sort due to the way they're loaded (I may be wrong, it's been a long time), and if that's the case, that bit of code would be required to be rewritten too.


EDIT2: Just in case, folders are ASSUMED to exist as entries in the PKZip central directories in SRB2; I have no clue if they're a requirement, but as far as I know, they're always generated by all of the programs I've tested.

Last edited by Nev3r; 01-13-2019 at 01:40 PM. Reason: typo
Nev3r is offline   Reply With Quote