Battlefield 2 Maplist Generation
As evidenced by my last post, I'm playing with a BF2 dedicated server on a daily basis. part of that is me and a roommate finding cool maps and adding them into our rotation. For the last weekish all we have played is Allied Intent Extended because it adds a LOT to an already good game. I went back to the mod's website today and grabbed a bunch of map packs that the dev team had put out, about 16 new maps, to be exact. After tossing these into my dedicated server's AIX directory I decided I did not want to add all of them into my maplist by hand. This would be picking out each new map, and then writing "maplist.append [mapname] [map-type] [max-players]" 16 times. Instead I cooked up a quick perl script that any BF2 server admin can use to make quick maplists. It should be run in the directory of a mod's levels, somewhere like [base-dir]/mods/aix/levels.
my $type = shift(@ARGV) or die("USAGE: perl maplist.pl [type] [players]\n");
my $players = shift(@ARGV) or die("USAGE: perl maplist.pl $type [players]\n");
print "rem Maplist.con generated automatically by Snarky\n";
foreach(<*>) {
if(-d $_) {
print "maplist.append $_ $type $players\n";
}
}
This spits the maplist out to STDOUT and can then be piped into whatever file you want. On a typical UNIX dedicated server it should be run like this (for 32 player maps and a coop map type):
perl maplist.pl gpm_coop 32 > ../settings/maplist.con
Of course, you may redirect wherever you like so as to not overwrite other lists. I keep separate maplists (maplist.coop.con and maplist.cq.con) around for coop and cq (conquest) as you can't add coop maps to conquests lists, and vice versa. Sure, for small additions to my levels directory this is like using a sledge hammer to hammer a nail, but heck, its quick and easy, so I'm happy.