X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=misc%2Ftools%2Fxonotic-map-compiler;h=8938cdc6f36e2965aa5f32121af041ee05d1cacc;hb=64d24e80a3dd10cb78bf18a730c138cb9a1c6bae;hp=7834af0da8b28298baf58c6864947b4cbfcded97;hpb=100c8c4a3327809ed6c999d0dcbf226545883229;p=xonotic%2Fxonotic.git diff --git a/misc/tools/xonotic-map-compiler b/misc/tools/xonotic-map-compiler index 7834af0d..8938cdc6 100755 --- a/misc/tools/xonotic-map-compiler +++ b/misc/tools/xonotic-map-compiler @@ -9,11 +9,11 @@ use File::Temp; # (just copy paste this part to the file ~/.xonotic-map-compiler) # Path to Xonotic (where the data directory is in) - our $XONOTICDIR = '.'; + our $XONOTICDIR = getcwd(); # Path to your q3map2 program. You find it in your GtkRadiant/install # directory. - our $Q3MAP2 = './netradiant/install/q3map2.x86'; + our $Q3MAP2 = getcwd() . '/netradiant/install/q3map2'; # General flags for q3map2 (for example -threads 4) our $Q3MAP2FLAGS = '-fs_forbiddenpath xonotic*-data*.pk3* -fs_forbiddenpath xonotic*-nexcompat*.pk3*'; @@ -25,13 +25,13 @@ use File::Temp; our $VISFLAGS = ''; # Default flags for the -light stage - our $LIGHTFLAGS = '-lightmapsearchpower 3 -deluxe -patchshadows -randomsamples -samples 4 -lightmapsize 512 -fast -fastbounce -dirty -bouncegrid -fill'; + our $LIGHTFLAGS = '-lightmapsize 1024 -lightmapsearchpower 4 -deluxe -patchshadows -randomsamples -samples 4 -fast -fastbounce -dirty -bouncegrid -fill'; # Default flags for the -minimap stage our $MINIMAPFLAGS = ''; # Default order of commands - our $ORDER = 'vis,light'; + our $ORDER = 'vis,scale,light'; # end of user changable part @@ -60,7 +60,8 @@ my $options = vis_timeout => 0, light_timeout => 0, minimap_timeout => 0, - scale_timeout => 0 + scale_timeout => 0, + timeout_stealing => 0, }; my $curmode = 'maps'; @@ -126,6 +127,10 @@ while(@ARGV) { $options->{scale_timeout} = shift @ARGV; } + elsif($_ eq '-timeout_stealing') + { + $options->{timeout_stealing} = shift @ARGV; + } elsif($_ eq '-order') { $options->{order} = [split /\s*,\s*/, shift @ARGV]; @@ -184,6 +189,8 @@ while(@ARGV) } my $linkdir = File::Temp::tempdir("xonotic-map-compiler.XXXXXX", TMPDIR => 1, CLEANUP => 1); +my $starttime = time; +my $endtime = time; sub q3map2(@) { @@ -195,8 +202,15 @@ sub q3map2(@) $timeout = $options->{minimap_timeout} if $mode eq '-minimap'; $timeout = $options->{scale_timeout} if $mode eq '-scale'; die "Invalid call: not a standard q3map2 stage" if not defined $timeout; + $endtime += $timeout; + my $stolen_timeout = $endtime - time; + if ($stolen_timeout > $timeout) + { + $timeout += ($stolen_timeout - $timeout) * $options->{timeout_stealing}; + } my @args = ($Q3MAP2, split(/\s+/, $Q3MAP2FLAGS), '-game', 'xonotic', '-fs_basepath', $XONOTICDIR, '-fs_basepath', $linkdir, '-v', @_); print "\$ @args\n"; + print "Using timeout: $timeout\n"; defined(my $pid = fork()) or die "fork: $!"; if($pid) # parent @@ -218,9 +232,15 @@ sub q3map2(@) } } -my ($prescale, $postscale) = ($options->{scalefactor} =~ /^([0-9.]+)(?::([0-9.]+))?$/); -$prescale = 1 if not defined $prescale; -$postscale = 1 if not defined $postscale; +if ($options->{scalefactor} =~ /^([0-9.]+):([0-9.]+)$/) +{ + die "Two-scale isn't supported" + if $1 != 1 and $2 != 1; + $options->{scalefactor} = $1 + if $2 == 1; + $options->{scalefactor} = $2 + if $1 == 1; +} my $origcwd = getcwd(); for my $m(@{$options->{maps}}) @@ -238,10 +258,8 @@ for my $m(@{$options->{maps}}) $m =~ s/\.(?:map|bsp)$//; - if($prescale != 1) - { - unshift @{$options->{bsp}}, "-keeplights"; - } + # never hurts, may help with rtlights + unshift @{$options->{bsp}}, "-keeplights"; local $SIG{INT} = sub { @@ -252,15 +270,8 @@ for my $m(@{$options->{maps}}) unlink <$m/lm_*>; # delete old external lightmaps q3map2 '-bsp', @{$options->{bsp}}, "$m.map" or die "-bsp: $?"; - if($prescale != 1) - { - q3map2 '-scale', @{$options->{scale}}, $prescale, "$m.bsp" - or die "-scale: $?"; - rename "${m}_s.bsp", "$m.bsp" - or die "rename ${m}_s.bsp $m.bsp: $!"; - } my @o = @{$options->{order}}; - push @o, qw/light vis/; + push @o, qw/vis scale light/; my %o = (); for(@o) @@ -282,14 +293,16 @@ for my $m(@{$options->{maps}}) or die "-vis: $?"; } } - } - - if($postscale != 1) - { - q3map2 '-scale', @{$options->{scale}}, $postscale, "$m.bsp" - or die "-scale: $?"; - rename "${m}_s.bsp", "$m.bsp" - or die "rename ${m}_s.bsp $m.bsp: $!"; + if($_ eq 'scale') + { + if ($options->{scalefactor} != 1) + { + q3map2 '-scale', @{$options->{scale}}, $options->{scalefactor}, "$m.bsp" + or die "-scale: $?"; + rename "${m}_s.bsp", "$m.bsp" + or die "rename ${m}_s.bsp $m.bsp: $!"; + } + } } if(defined $options->{minimap})