Creating Compressed Archives

Making compressed map archives from the command line.

Packing the maps from the command line means you can create a batch file to pack all the maps in a mod. It also makes them 30-40% smaller than winRFA or the others. Here's how:

Copy the unpacked map into the game directory so that the directroy tree looks like this:

<game dir>\Bf1942\Levels\<map name>

Where <game dir> is the folder where BF is installed, usually in:

C:\Program Files\EA GAMES\Battlefield 1942\

And is the name of the map and is called the map's root folder. The map's root folder should contain all the files you want to include in the archive, like the init.con and the GameTypes folder to name a couple. If you use winRFA to unpack a map, then unpack it directly into the game folder.

From a console window, change directories into the game folder and run this command:

bf1942_r +makeArchive Bf1942/Levels/<map name> 1 1

This will create a compressed archive and place it in:

<game dir>\Bf1942\Levels\

You can actually play any unpacked map without the rfa installed, but only single player game mode. Thats also why you should remove the map folder when you are done. While in place, it will load before any packed map, no matter what mod is being played. This fact also makes it an excellent place to unpack a map for editing.

I've written a batch file, packrfa.bat, that will create the rfa for you. The files still need to be located off the game root folder, i.e. if you wanted to repack the Sounds.rfa, you place the unpacked sounds off the game folder like this:
<game dir>\Sounds

Run the packrfa.bat from a console or from the start->run toolbar, like this:

packrfa Sounds

This will move it to the DesertCombat mod folder:

packrfa Sounds DesertCombat

And this will add the 001 extention, then move it to the DesertCombat mod folder:

packrfa Sounds DesertCombat 001

If you are packing a map for a mod, you do not need to include the "Bf1942\Levels\" in the path. To repack midway:
packrfa Midway BF1942 001
will pack the map, add the 001 extention and put it into the BF1942 levels folder.

Here is the packrfa.bat file:


@echo off

set gamedir="c:\program files\ea games\battlefield 1942"
set debug=bf1942_r
set base=Bf1942
set dummy=

rem *** change into the battlefield game directory
if not exist %gamedir% goto err1
cd %gamedir%

rem *** set up the archive name
if x%1==x goto usage
set gp=%1
set gp=%gp:/=\%
set up=%gp:\=/%

if exist %gp% goto packit
if not exist %base%\Levels\%1 goto err2
set gp=%base%\Levels\%1
set up=%gp:\=/%

:packit
echo Packing %gp%
%debug% +makeArchive %up% 1 1 %dummy%

:wait
if not exist %gp%.lst goto wait

del /q %gp%.lst

if x%2==x goto end

set fp=%gp%

if x%3==x goto skip
move /y %gp%.rfa %gp%_%3.rfa
set fp=%gp%_%3
:skip

if not exist Mods\%2 goto err3
move /y %fp%.rfa Mods\%2\Archives\%fp%.rfa
goto end

:err1
echo Plese edit this file and set the gamedir var to point to the battlefield base folder
goto usage

:err2
echo Folder %gp% does not exist in the game root folder
goto usage

:err3
echo The mod %2 does not exist

:usage
echo ***********************************************************************
echo * Usage: *
echo * packrfa folder_name [mod_name] [extention] *
echo * If mod_name is given, then the packed rfa will be moved into it *
echo * If an extention is provided, the packed archive will add it to *
echo * the name *
echo ***********************************************************************

:end