7 # change these to match your system, or define them in ~/.nexuiz-map-compiler
8 # (just copy paste this part to the file ~/.nexuiz-map-compiler)
10 # Path to Nexuiz (where the data directory is in)
11 our $NEXUIZDIR = '/home/polzer/Nexvn/nexuiz';
13 # Path to your q3map2 program. You find it in your GtkRadiant/install
15 our $Q3MAP2 = '/home/users4/ommz/polzer/bin/q3map2.x86';
17 # General flags for q3map2 (for example -threads 4)
18 our $Q3MAP2FLAGS = '';
20 # Default flags for the -bsp stage
21 our $BSPFLAGS = '-samplesize 8';
23 # Default flags for the -vis stage
26 # Default flags for the -light stage
27 our $LIGHTFLAGS = '-deluxe -patchshadows -samples 3';
29 # end of user changable part
31 do "$ENV{HOME}/.nexuiz-map-compiler";
37 $0 mapname [-bsp bspflags...] [-vis visflags...] [-light lightflags...]
44 bsp => [split /\s+/, $BSPFLAGS],
45 vis => [split /\s+/, $VISFLAGS],
46 light => [split /\s+/, $LIGHTFLAGS],
56 my $enterflags = undef;
57 if($_ eq '-bsp' or $_ eq '-meta')
67 $enterflags = 'light';
75 $options->{scale} = (shift @ARGV) || 1;
77 elsif($_ =~ /^-/ and $curmode eq 'maps')
80 push @{$options->{$curmode}}, $_;
84 push @{$options->{$curmode}}, $_;
86 if(defined $enterflags)
88 $curmode = $enterflags;
95 $options->{$curmode} = [];
103 return !system $Q3MAP2, '-game', 'quake3', '-fs_basepath', $NEXUIZDIR, '-fs_game', 'data', '-v', @_;
106 (my $mapdir = getcwd()) =~ s!/[^/]*(?:$)!!;
108 unlink "$ENV{HOME}/.q3a/data";
109 mkdir "$ENV{HOME}/.q3a";
110 symlink "$mapdir", "$ENV{HOME}/.q3a/data"
111 or die "Setting up directory structure, $mapdir -> $ENV{HOME}/.q3a/data: $!";
113 for my $m(@{$options->{maps}})
115 if($options->{scale} != 1)
117 open my $checkfh, "<", "$m.map"
118 or die "open $m.map: $!";
122 /^\s*"_keeplights"\s+"1"\s*$/
127 die "$m does not define _keeplights to 1"
131 my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
132 open my $shaderlist, "+<", "$NEXUIZDIR/data/scripts/shaderlist.txt"
133 or die "open $NEXUIZDIR/data/scripts/shaderlist.txt: $!";
134 my $previous_shaderlist = "";
137 $previous_shaderlist .= $_;
141 my $restore_shaderlist = sub
143 open $shaderlist, ">", "$NEXUIZDIR/data/scripts/shaderlist.txt";
144 print $shaderlist $previous_shaderlist;
147 local $SIG{INT} = sub
149 print "SIGINT caught, cleaning up...\n";
150 $restore_shaderlist->();
157 print $shaderlist "$_\n";
161 q3map2 '-bsp', '-meta', @{$options->{bsp}}, "$m.map"
163 if($options->{scale} != 1)
165 q3map2 '-scale', $options->{scale}, "$m.bsp"
167 rename "${m}_s.bsp", "$m.bsp"
168 or die "rename ${m}_s.bsp $m.bsp: $!";
170 q3map2 '-vis', @{$options->{vis}}, "$m.map"
172 q3map2 '-light', @{$options->{light}}, "$m.map"
177 $restore_shaderlist->();
182 $restore_shaderlist->();