
Replacing the Q2
PAK system with uncompressed ZIP files ala Q3
|
Copyright
info |
|
All
code in this tutorial is protected by the [GPL License]. |
|
Tutorial
by: Nanook |
||||||||||||||||||||||||||||||||||||||||
|
Mailto: mchastain@bendcable.com Files needed
for this tutorial: paktozip.zip
This
modification was made to simplify the method of making changes to the games
propritary PAK file to the more common uncompressed ZIP file. (ala Quake3) First, let's
start by modifiying the qfiles.h file. QFILES.H We will need
to modify the original quake2 header structure to match the structure used by
the file header in a zip.
To...
*** The pragma
is to keep the compiler from padding the data to fit within the 32bit
boundary. Otherwise it mungs the data. *** For more
information about the zip file format visit: http://www.pkware.com/support/appnote.html
Next we will
be changing the original Pack header signature to that of the signature used
by the Zip file to identify a file header and we will be adding the header
signature of the zip's Directory. This...
Becomes
this...
This completes
the modifications to the qfiles.h file! Now we get to the nitty gritty of
changing the FS_LoadPackFile function to load the new zip file! FILES.C Go to the
beginning of the FS_LoadPackFile function so we can make changes to the
declared variables used by the function. Since the
dpackheader_t structure will only be a temporary buffer we can rename it:
This...
Becomes
this...
Next we will
add a variable to keep track of the number of files we have read from the
zip. This...
Becomes
this...
And while we
are at it we can remove the an unused variable and comment out another.
Remove this...
And comment
out...
Enough with
the variables, now we change some code! Since we won't be using the checksum
check in this version we can comment the call to it out.
Next we will
be removing the original header checking code as we will be checking the file
header for each file ever time we read it in to make sure that it is indeed a
file header and that no compress or odd flags have been set. Remove the
following code!
Now we can add
our own loop to build a table of the files in the zip. We read the file
header, check the header signature, and see if the file is compressed or has
any bit flags set. After this code:
Add the
following For Loop:
Now we need to
create an array that will hold all the information about the contents of the
zip file and record the number of items that we read from the zip file. After
the previous for loop, add this code:
Now change the
original code to remove the calls to LittleLong (we don't need them) It
should look like this:
Two last
changes and we are finished!! Now we need to update the last of the original
code to reflect the change in the variables we made at the beginning of this
function. This code...
Becomes...
And this
code...
Changes to
this...
That's it! Now
all you need to do is convert all your pak files to zip files! ;) Of course
there are a few things to keep in mind before you go hog wild with this
modification. 1. For
compatibility I have maintained the maximum number of files you can put in
the zip file at 4096. This was the same for the pack file system. 2. Currently
the checksum function is disabled as I don't need it, but you could re-enable
it if you can match the method used by the zip program to compute it. 3. The zip
format store directories like any other file and my code does not remove
them. This isn't a problem as they take very little space and they are
ignored by the engine. 4. And of
course, your old pack files won't work unless you change them to zip files.
Remember to maintain the original file paths when rebuilding them. 5. Quake2
still looks for the file extension of ".pak" |
Tutorial Originally found at: