Jump to content

File Packing/Unpacking Utility

Recommended Posts

Hey everyone! Yesterday I actually sat down and worked on a project that's been sitting on the back burner for close to a year. With a little help from Oleg, the creator of ZModeler, I was able to figure out the algorithm used to compress ("Pack") Emergengy 4 files (Thanks Oleg!!). So being a bit on the bored side yesterday, I decided to stretch my programming legs a bit and create a utility that would allow you to Pack/Unpack various file types en masse. After a few hours of pounding on the key boards and losing a few hairs, I've managed to create this very useful utility.

Download Here 


What does it do exactly?
Well, this utility makes packing/unpacking files in emergency 4 much faster. Previously, in order to pack or unpack a file, you had to launch the editor and unpack each file individually. It was a time consuming process. Additionally, Emergency 4 supports the compression ("packing") of .dds texture files and .script files. To pack these files in the editor, you would have to change their extension to .v3o, then use the editor to pack them, and then change the extension from .v3o to whatever type of file it was to begin with. This was an even more annoying process.
This utility allows you to pack or unpack individual files and entire folder and subfolders. What used to take forever, now takes a matter of seconds.
What is Packing and what is it good for?
Packing a file takes the contents of a file and compresses it using a compression algorithm to produce a file which is smaller and uses less space on your hard drive. The Los Angeles Mod v2.1, when completely unpacked, takes up approximately 400MB of space on disk. When completely packed (all .v3o, .dds, and .script packed), the mod only consumes about 310MB which is about a 24% reduction in file size. This test is not to say all uses will result in a space savings of 24%, however significant savings can be seen especially in modification that use high resolution models, textures, or are script heavy.
So Packing files saves me disk space. What's the trade off?
The trade off is definitely in initial mod loading time. If you start your computer and launch an Emergency 4 Modification, you will notice that it always takes up to twice as long to load a mod the first time. With a fully packed Los Angeles Mod, it took approximately 22% longer to load the fully packed version than it did to load the fully unpacked version (an average of 3 trials was used). The time it took to load Freeplay on a fully packed Los Angeles Mod v2.1 Mod was also effected and found to load 32% slower than a fully unpacked version.
So packing my files saves disk space but also makes my game load slower...lame!
This is an overly simplified view of the situation. In testing with the Los Angeles Mod v2.1, only the FIRST LOAD of the modification was effected. Thanks to caching, all subsequent loads of the modification and loads into free play saw no significant difference in time between the fully packed mod and the fully unpacked version. Plus, a difference of 32% in loading freeplay may not be all that significant for your system. In my case, that 32% difference between freeplay load times was a matter of 12 seconds. However since load times are relative to each individual's hardware, that 32% may be more significant. (ie. If it takes you 3 minutes to load a mod, that 32% could mean it could take up to an additional minute to load). The decision is yours to weigh.
Okay, enough talk and stats and junk...how do I use the darn thing?
I've made a whole video on how to use it.
Click to view Demo/Tutorial
This is a command line utility! It must be run through the command prompt!
If your game is installed in your Program Files or Program Files (x86) folder, you MUST run your command prompt as administrator!
How to pack individual files:

> em4packer -pack "C:\path\to\file.v3o" "C:\path\to\file2.dds" ...-or-> em4packer -pack file1.v3o myscript.script "My Model 1.v3o" ...

*Spaces are considered separators between arguments. If your file name or path to your file name has ANY SPACES in it, you need to surround it with double quotes ".

To unpack an individual file, the command is the same as above except for the changing of the "-pack" for a "-unpack".

> em4packer -unpack "C:\path\to\file.v3o" "C:\path\to\file2.dds" ...-or-> em4packer -unpack file1.v3o myscript.script "My Model 1.v3o" ...

 To pack ALL selected files within a folder (including all sub-folders) the commands are a bit different.

> em4packer -dir -pack -files=v3o,dds,script "C:\path\to\em4\mods\mymod"-or-> em4packer -dir -unpack -files=v3o "C:\path\to\em4\mods\mymod"

"-dir" tells the packer that we are in directory packing mode not individual file packing mode. "-pack" states that we want to pack the files. To unpack the files, used "-unpack" instead. "-files=" tells which kind of files we want to process. You can select any combination of v3o, dds, and script separated by commas NO SPACES.



That's it! I hope you guys enjoy it. Let me know if there are any bugs or if you know any improvements.
This utility requires that you have Java 6 or greater installed on your PC. It will not work without Java.



Link to comment
Share on other sites

You can only use the em4packer command by itself if the command prompt is pointed to the same folder as the utility.

Otherwise you will need to define the path to the utility.

Use the "cd" command to move the command prompt around.

"cd C:/path/to/utility/folder/"

Then you can use em4packer command directly.

Alternatively you can use it like:

"C:/path/to/utility/folder/em4packer.exe -unpack file1.v3o"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...