11 for my $sf(<scripts/*.shader>)
13 my $curshader = undef;
28 my @line = map { s/"//g; $_; } split /\s+/, $_;
34 elsif($line[0] eq '}')
40 if(defined $curshader)
42 $shaders{lc $curshader} = { shaderfile => $sf, textures => [ @tex ] };
49 $curshader = $line[0];
52 elsif($level == 1 and lc $line[0] eq 'qer_editorimage')
56 elsif($level == 1 and lc $line[0] eq 'qer_lightimage')
60 elsif($level == 1 and lc $line[0] eq 'skyparms')
62 for(qw/rt lf ft bk up dn/)
64 push @tex, "$line[1]_$_";
65 push @tex, "$line[3]_$_";
68 elsif($level == 2 and lc $line[0] eq 'map')
72 elsif($level == 2 and lc $line[0] eq 'animmap')
95 $tex =~ s/\.ogg$|\.wav$//i;
98 AddFile "sound/$tex.ogg" or
99 AddFile "sound/$tex.wav";
105 $tex =~ s/\.jpg$|\.tga$|\.png$//i;
106 AddFile "$tex.jpg" or
107 AddFile "$tex.tga" or
110 for('_shirt', '_pants', '_glow', '_norm', '_bump', '_gloss')
112 AddFile "$tex$_.jpg" or
113 AddFile "$tex$_.tga" or
114 AddFile "$tex$_.png";
122 $shader =~ s/\.jpg$|\.tga$|\.png$//i;
123 my $si = $shaders{lc $shader};
127 or warn "Unknown shader used: $shader";
131 AddFile $si->{shaderfile};
133 for @{$si->{textures}};
137 sub AddMapDependencies($)
140 for(/^"noise.*" "(.*)"/gm)
144 for(/^"sound.*" "(.*)"/gm)
148 for(/^"music" "(.*)"/gm)
152 for(/^"model" "(.*)"/gm)
154 # TODO make this AddModel
155 # TODO and find the shaders the model uses
158 for(/^"lodmodel.*" "(.*)"/gm)
164 sub AddMapinfoDependencies($)
167 for($data =~ /^cdtrack (.*)$/gm)
169 AddSound "sound/cdtracks/$1";
173 sub AddCfgDependencies($)
176 for($data =~ /^cd loop "?(.*?)"?$/gm)
178 AddSound "sound/cdtracks/$1";
182 sub AddShaderDependencies($)
186 my $n = length($data) / 72;
189 my $s = substr $data, $_ * 72, 64;
195 sub AddFaceDependencies($$)
197 my ($base, $data) = @_;
199 my $n = length($data) / 104;
202 my $l = unpack "V", substr $data, $_ * 104 + 28, 4;
203 AddTexture sprintf "maps/%s/lm_%04d", $base, $l;
204 AddTexture sprintf "maps/%s/lm_%04d", $base, $l | 1; # deluxe
221 AddMapDependencies $data;
228 m!^maps/(.*)\.bsp! or die "perl is stupid";
230 AddFile "maps/$b.mapinfo";
231 AddFile "maps/$b.jpg";
232 AddFile "maps/$b.cfg";
233 AddFile "maps/$b.waypoints";
234 AddFile "maps/$b.rtlights";
235 AddTexture "gfx/$b\_radar.tga";
236 AddTexture "gfx/$b\_mini.tga";
240 open my $fh, "<", "maps/$b.mapinfo"
241 or warn "<maps/$b.mapinfo: $!";
244 AddMapinfoDependencies $data;
248 open my $fh, "<", "maps/$b.cfg"
249 or warn "<maps/$b.cfg: $!";
252 AddCfgDependencies $data;
256 open my $fh, "-|", 'bsptool.pl', $_, '-xentities'
260 AddMapDependencies $data;
264 open my $fh, "-|", 'bsptool.pl', $_, '-xfaces'
268 AddFaceDependencies $b, $data;
272 open my $fh, "-|", 'bsptool.pl', $_, '-xtextures'
276 AddShaderDependencies $data;
292 warn "Unused file: $dir"
303 for sort keys %files;