r1ch.net forums
* Home Help Search Login Register
r1ch.net  |  r1ch.net stuff  |  R1Q2  |  Topic: pakoptimz - .pak optimization tool
Pages: [1] 2 3  All
Print
Author Topic: pakoptimz - .pak optimization tool  (Read 131380 times)
R1CH
Administrator
Member

Posts: 2625



« on: January 04, 2005, 07:56:00 pm »

It just occured to me I never even posted about my latest tool, pakoptimz.

Due to how the .pak structure works, it's possible to save space by pointing references to dupicated data at the first actual instance of the data. Smaller pak files of course give faster load times and reduced download sizes... what more could you ask for? And yes, the resulting pak is completely compatible with Q2.

WARNING: Some pak editors will unfortunately corrupt the pak data if you attempt to edit an optimized pak as they do not expect the new file structure. PakExplorer in particular is known to damage optimized pak files. If the "Recover free space automatically" is enabled, simply viewing an optimized pak in PakExplorer can cause it to become corrupted. It is strongly recommended you keep an unoptimized pak available for any editing work you wish to do and only use pakoptimz to produce the "final" pak.

Runs from the command line:
Usage: pakoptimz pak.pak [new.pak]

Win32 Binary:
http://ftp://ftp.planetgloom.com/r1q2/utils/pakoptimz.zip

Source (builds on Win32 and Linux):
http://ftp://ftp.planetgloom.com/r1q2/utils/pakoptimz-src.zip
« Last Edit: January 21, 2005, 10:53:07 pm by R1CH » Logged
mortalmatt
Member

Posts: 37


« Reply #1 on: January 06, 2005, 09:38:59 pm »

does pakscape do this automatically? it didn't effect any of my pak files.
http://quake2ctf.info/tools/
Logged
R1CH
Administrator
Member

Posts: 2625



« Reply #2 on: January 06, 2005, 10:07:54 pm »

No, to my knowledge no pak editor does this by itself. I guess your pak files don't have any duplicates Smiley.
Logged
JackC
Member

Posts: 9


« Reply #3 on: January 07, 2005, 07:34:44 am »

i think at least Servant Salamander do it:

http://www.altap.cz/salam_en/index.html
Logged
R1CH
Administrator
Member

Posts: 2625



« Reply #4 on: January 07, 2005, 12:30:32 pm »

That looks like it supports "free space" optimization that just makes sure there are no gaps in the data, it doesn't look like it removes duplicate references. pakoptimz will do both Smiley. In fact I think most pak edits do free space optimization when you save a pak.
Logged
mortalmatt
Member

Posts: 37


« Reply #5 on: January 07, 2005, 02:39:56 pm »

r1ch, i'm not sure if i understand the nice feature of the program. by removing duplicates, it will remove a file from a pak (pak2.pak) if the exact file exists in a previous pak (pak1.pak)?
Logged
ItsJustAGame
Guest
« Reply #6 on: January 07, 2005, 03:19:00 pm »

now this is a sweet tool, thanks a lot! Cheesy   I have talked about this with a clanmate before, but have never been able to find anything...  I dunno if he knew about and was referring to your app or another similar one, but this is exaclty what it's supposed to do... you rock! Cool
Logged
R1CH
Administrator
Member

Posts: 2625



« Reply #7 on: January 07, 2005, 03:57:38 pm »

Quote from: mortalmatt
r1ch, i'm not sure if i understand the nice feature of the program. by removing duplicates, it will remove a file from a pak (pak2.pak) if the exact file exists in a previous pak (pak1.pak)?

It optimizes how duplicates are stored in a single pak file. Say for example you have a custom sound pack that uses the same sound effect for each of the machine gun firing sounds (machgf1a.wav, machgf2a.wav, machgf3a.wav, etc). A normal pak editor will store that same sound effect data every time for each file. Pakoptimz will spot that machgf1a.wav data is the same as machgf2a.wav data and thus remove the duplicated file data, replacing future occurances with a "reference" to the first data.

Maybe diagrams help Smiley.
Logged
R1CH
Administrator
Member

Posts: 2625



« Reply #8 on: January 07, 2005, 04:02:57 pm »

Quote from: mortalmatt
r1ch, i'm not sure if i understand the nice feature of the program. by removing duplicates, it will remove a file from a pak (pak2.pak) if the exact file exists in a previous pak (pak1.pak)?

It optimizes how duplicates are stored in a single pak file. Say for example you have a custom sound pack that uses the same sound effect for each of the machine gun firing sounds (machgf1a.wav, machgf2a.wav, machgf3a.wav, etc). A normal pak editor will store that same sound effect data every time for each file. Pakoptimz will spot that machgf1a.wav data is the same as machgf2a.wav data and thus remove the duplicated file data, replacing future occurances with a "reference" to the first data.

Maybe diagrams help Smiley.

Unoptimized pak:


After running pakoptimz:
Logged
mortalmatt
Member

Posts: 37


« Reply #9 on: January 07, 2005, 04:55:32 pm »

ah brilliant.. this will help on some of my texture paks i'm sure. thanks for the explanation. Cheesy
Logged
_DOA_DEATH_JUMP
Guest
« Reply #10 on: January 07, 2005, 11:23:59 pm »

This is great R1CH. What about if you have 2 files that have the same name, but a different file size, will it still try to remove the "duplicate" file?
Logged
_DOA_DEATH_JUMP
Guest
« Reply #11 on: January 07, 2005, 11:40:11 pm »

Ahhh, I just tried it, it doesn't remove files with the same name and different file size. Good deal. One last question though, what happens when you remove the main file?  Do all the duplicate files disappear as well?
Logged
mortalmatt
Member

Posts: 37


« Reply #12 on: January 08, 2005, 12:32:34 am »

notice the diagram. the files are not removed. they are merely all pointing to the same data. rather than having duplicates of the data. if the files were removed that contained the same data, the pak file would be ruined. also notice the arrows, they are pointing to the data -- not the 'main file'. so if you delete a file that contains the same data as another file in the pak, the remaining file will not be effected by deletion of the other file.

pakscape.exe found at http://quake2ctf.info/tools/
Logged
R1CH
Administrator
Member

Posts: 2625



« Reply #13 on: January 08, 2005, 01:04:54 am »

Quote from: _DOA_DEATH_JUMP
Ahhh, I just tried it, it doesn't remove files with the same name and different file size. Good deal. One last question though, what happens when you remove the main file?  Do all the duplicate files disappear as well?

It bases duplicate detection on the actual file data rather than names or sizes so it won't cause a problem there. Once you open up a pak file in an editor, all optimizations are lost and internally the pak editor stores it as file1 -> data1, file2 -> data2 again, so if you delete the "main file" it won't have any effect other than deleting one of the files as the pak editor will be treating it as an unoptimized pak. Note, this is only my experience so far with some pak editors. It's possible other pak editors may not do this. I'd recommend using PakScape as your pak editor where possible as I've never had any issues with it and optimized paks, unlike some others.
Logged
FragBait
Member

Posts: 5


« Reply #14 on: January 08, 2005, 08:26:28 am »

nifty lill thingie, great work R1CH!
Logged
Pages: [1] 2 3  All
Print
r1ch.net  |  r1ch.net stuff  |  R1Q2  |  Topic: pakoptimz - .pak optimization tool
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines