X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=misc%2Ftools%2Fxonotic-map-compiler;h=e86fd887096f4de1a7338853c81286f4b3c55013;hb=4c6e2486fffdf31d00e5be9a8348dd0e99247b5e;hp=ae819b07f77905379c8eccca922d81c22f3e7971;hpb=c035255f5a4f394bdbe661d573a163856c37359d;p=xonotic%2Fxonotic.git diff --git a/misc/tools/xonotic-map-compiler b/misc/tools/xonotic-map-compiler index ae819b07..e86fd887 100755 --- a/misc/tools/xonotic-map-compiler +++ b/misc/tools/xonotic-map-compiler @@ -25,7 +25,7 @@ use File::Temp; our $VISFLAGS = ''; # Default flags for the -light stage - our $LIGHTFLAGS = '-deluxe -patchshadows -samples 3 -lightmapsize 512 -bounce 8 -fastbounce -bouncegrid'; + our $LIGHTFLAGS = '-deluxe -patchshadows -samples 3 -lightmapsize 512'; # Default flags for the -minimap stage our $MINIMAPFLAGS = ''; @@ -41,7 +41,7 @@ sub Usage() { print < [split /\s+/, $VISFLAGS], light => [split /\s+/, $LIGHTFLAGS], minimap => [split /\s+/, $MINIMAPFLAGS], + scale => [], # can't have defaults atm order => [split /\s*,\s*/, $ORDER], maps => [], scale => 1 @@ -86,6 +87,7 @@ while(@ARGV) elsif($_ eq '-scale') { $options->{scale} = (shift @ARGV) || 1; + $enterflags = 'scale'; } elsif($_ eq '-novis') { @@ -99,6 +101,10 @@ while(@ARGV) { $options->{minimap} = undef; } + elsif($_ eq '-noshaderlist') + { + $options->{noshaderlist} = 1; + } elsif($_ eq '-order') { $options->{order} = [split /\s*,\s*/, shift @ARGV]; @@ -171,60 +177,73 @@ for my $m(@{$options->{maps}}) my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader"; - my $previous_shaderlist = undef; - my $shaderlist = ""; - if(open my $fh, "<", "$XONOTICDIR/data/xonotic-maps.pk3dir/scripts/shaderlist.txt") + my $restore_shaderlist = sub { }; + if(!$options->{noshaderlist}) { - while(<$fh>) + my $previous_shaderlist = undef; + my $shaderlist = ""; + if(open my $fh, "<", "$XONOTICDIR/data/scripts/shaderlist.txt") { - $shaderlist .= $_; - } + while(<$fh>) + { + $shaderlist .= $_; + } - # we may have to restore the file on exit - $previous_shaderlist = $shaderlist - if "$XONOTICDIR/data" eq $mapdir; - } - else - { - # possibly extract the shader list from a pk3? - local $ENV{N} = $XONOTICDIR; - $shaderlist = `cd "\$N" && for X in "\$N"/data/data*.pk3; do Y=\$X; done; unzip -p "\$Y" scripts/shaderlist.txt`; - } + # we may have to restore the file on exit + $previous_shaderlist = $shaderlist + if "$XONOTICDIR/data" eq $mapdir; + } + else + { + # possibly extract the shader list from a pk3? + local $ENV{N} = $XONOTICDIR; + $shaderlist = `cd "\$N" && for X in "\$N"/data/data*.pk3; do Y=\$X; done; unzip -p "\$Y" scripts/shaderlist.txt`; + } - my $shaderlist_new = ""; - for(split /\r?\n|\r/, $shaderlist) - { - delete $shaders{$_}; - $shaderlist_new .= "$_\n"; - } - if(%shaders) - { - for(sort keys %shaders) + my $shaderlist_new = ""; + for(split /\r?\n|\r/, $shaderlist) { + delete $shaders{$_}; $shaderlist_new .= "$_\n"; } - } - else - { - $shaderlist_new = undef; - } - - my $restore_shaderlist = sub - { - if(defined $shaderlist_new) + if(%shaders) { - if(defined $previous_shaderlist) + for(sort keys %shaders) { - open my $fh, ">", "$mapdir/scripts/shaderlist.txt"; - print $fh $previous_shaderlist; - close $fh; + $shaderlist_new .= "$_\n"; } - else + } + else + { + $shaderlist_new = undef; + } + + $restore_shaderlist = sub + { + if(defined $shaderlist_new) { - unlink "$mapdir/scripts/shaderlist.txt"; + if(defined $previous_shaderlist) + { + open my $fh, ">", "$mapdir/scripts/shaderlist.txt"; + print $fh $previous_shaderlist; + close $fh; + } + else + { + unlink "$mapdir/scripts/shaderlist.txt"; + } } + }; + + if(defined $shaderlist_new) + { + mkdir "$mapdir/scripts"; + open my $fh, ">", "$mapdir/scripts/shaderlist.txt"; + print $fh $shaderlist_new; + close $fh; } - }; + } + local $SIG{INT} = sub { print "SIGINT caught, cleaning up...\n"; @@ -234,20 +253,12 @@ for my $m(@{$options->{maps}}) eval { - if(defined $shaderlist_new) - { - mkdir "$mapdir/scripts"; - open my $fh, ">", "$mapdir/scripts/shaderlist.txt"; - print $fh $shaderlist_new; - close $fh; - } - unlink <$m/lm_*>; # delete old external lightmaps q3map2 '-bsp', @{$options->{bsp}}, "$m.map" or die "-bsp: $?"; if($prescale != 1) { - q3map2 '-scale', $prescale, "$m.bsp" + q3map2 '-scale', @{$options->{scale}}, $prescale, "$m.bsp" or die "-scale: $?"; rename "${m}_s.bsp", "$m.bsp" or die "rename ${m}_s.bsp $m.bsp: $!"; @@ -287,7 +298,7 @@ for my $m(@{$options->{maps}}) if($postscale != 1) { - q3map2 '-scale', $postscale, "$m.bsp" + q3map2 '-scale', @{$options->{scale}}, $postscale, "$m.bsp" or die "-scale: $?"; rename "${m}_s.bsp", "$m.bsp" or die "rename ${m}_s.bsp $m.bsp: $!";