7 # change these to match your system
9 # Path to Nexuiz (where the data directory is in)
10 my $NEXUIZDIR = '/home/polzer/Nexvn/nexuiz';
12 # Path to your q3map2 program. You find it in your GtkRadiant/install
14 my $Q3MAP2 = '/home/users4/ommz/polzer/bin/q3map2.x86';
16 # General flags for q3map2 (for example -threads 4)
19 # Default flags for the -bsp stage
20 my $BSPFLAGS = '-samplesize 8';
22 # Default flags for the -vis stage
25 # Default flags for the -light stage
26 my $LIGHTFLAGS = '-deluxe -patchshadows -samples 3';
28 # end of user changable part
34 $0 mapname [-bsp bspflags...] [-vis visflags...] [-light lightflags...]
41 bsp => [split /\s+/, $BSPFLAGS],
42 vis => [split /\s+/, $VISFLAGS],
43 light => [split /\s+/, $LIGHTFLAGS],
53 my $enterflags = undef;
54 if($_ eq '-bsp' or $_ eq '-meta')
64 $enterflags = 'light';
72 $options->{scale} = (shift @ARGV) || 1;
74 elsif($_ =~ /^-/ and $curmode eq 'maps')
77 push @{$options->{$curmode}}, $_;
81 push @{$options->{$curmode}}, $_;
83 if(defined $enterflags)
85 $curmode = $enterflags;
92 $options->{$curmode} = [];
100 return !system $Q3MAP2, '-game', 'quake3', '-fs_basepath', $NEXUIZDIR, '-fs_game', 'data', '-v', @_;
103 (my $mapdir = getcwd()) =~ s!/[^/]*(?:$)!!;
105 unlink "$ENV{HOME}/.q3a/data";
106 mkdir "$ENV{HOME}/.q3a";
107 symlink "$mapdir", "$ENV{HOME}/.q3a/data"
108 or die "Setting up directory structure, $mapdir -> $ENV{HOME}/.q3a/data: $!";
110 for my $m(@{$options->{maps}})
112 if($options->{scale} != 1)
114 open my $checkfh, "<", "$m.map"
115 or die "open $m.map: $!";
119 /^\s*"_keeplights"\s+"1"\s*$/
124 die "$m does not define _keeplights to 1"
128 my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
129 open my $shaderlist, "+<", "$NEXUIZDIR/data/scripts/shaderlist.txt"
130 or die "open $NEXUIZDIR/data/scripts/shaderlist.txt: $!";
138 print $shaderlist "$_\n";
142 q3map2 '-bsp', '-meta', @{$options->{bsp}}, "$m.map"
144 if($options->{scale} != 1)
146 q3map2 '-scale', $options->{scale}, "$m.bsp"
148 rename "${m}_s.bsp", "$m.bsp"
149 or die "rename ${m}_s.bsp $m.bsp: $!";
151 q3map2 '-vis', @{$options->{vis}}, "$m.map"
153 q3map2 '-light', @{$options->{light}}, "$m.map"