From 11153191bc11343f7c39eb5b88b1f7e0f0fb58ed Mon Sep 17 00:00:00 2001 From: div0 Date: Mon, 6 Apr 2009 06:32:53 +0000 Subject: [PATCH] improve nexuiz-map-compiler git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6439 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- misc/tools/nexuiz-map-compiler | 46 +++++++++++----------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/misc/tools/nexuiz-map-compiler b/misc/tools/nexuiz-map-compiler index d928ba73d..a422e0ca0 100755 --- a/misc/tools/nexuiz-map-compiler +++ b/misc/tools/nexuiz-map-compiler @@ -3,6 +3,7 @@ use strict; use warnings; use POSIX; +use File::Temp; # change these to match your system, or define them in ~/.nexuiz-map-compiler # (just copy paste this part to the file ~/.nexuiz-map-compiler) @@ -113,41 +114,18 @@ while(@ARGV) } } -my $game = 'compile.' . int rand 99999999; # mktemp on win32? +my $linkdir = File::Temp::tempdir("nexuiz-map-compiler", TMPDIR => 1, CLEANUP => 1); sub q3map2(@) { - my @args = ($Q3MAP2, split(/\s+/, $Q3MAP2FLAGS), '-game', 'nexuiz', '-fs_basepath', $NEXUIZDIR, '-fs_game', $game, '-v', @_); + my @args = ($Q3MAP2, split(/\s+/, $Q3MAP2FLAGS), '-game', 'nexuiz', '-fs_basepath', $NEXUIZDIR, '-fs_basepath', $linkdir, '-v', @_); print "\$ @args\n"; return !system @args; } (my $mapdir = getcwd()) =~ s!/[^/]*(?:$)!!; $mapdir = "/" if $mapdir eq ""; - -unlink "$NEXUIZDIR/$game"; -mkdir "$NEXUIZDIR"; -eval -{ - symlink "$mapdir", "$NEXUIZDIR/$game" - or die "THROW: Setting up directory structure, $mapdir -> $NEXUIZDIR/$game: $!"; - 1; -} -or do -{ - die $1 - if $@ =~ /^THROW: (.*)/s; - # if we get here, symlinks do not work, as symlink() itself raised the exception - # this should only happen on Win32 - if($^O ne "MSWin32") - { - die "Symlinks not supported ($@) but invalid OS signature, this must be MSWin32, but $^O got reported"; - } - - # TODO support Windows here somehow - # maybe by copying all files and copying back the finished compile? (ugh) - die "Windows is not supported yet."; -}; +symlink "$mapdir", "$linkdir/data"; my ($prescale, $postscale) = ($options->{scale} =~ /^([0-9.]+)(?::([0-9.]+))?$/); $postscale = 1 if not defined $postscale; @@ -171,6 +149,12 @@ for my $m(@{$options->{maps}}) } my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader"; + if(!-f "$NEXUIZDIR/data/scripts/shaderlist.txt") + { + # possibly extract the shader list from a pk3? + local $ENV{D} = $NEXUIZDIR; + system q{cd "$D" && for X in data/data*.pk3; do unzip -o "$X" scripts/shaderlist.txt; done}; + } open my $shaderlist, "+<", "$NEXUIZDIR/data/scripts/shaderlist.txt" or die "open $NEXUIZDIR/data/scripts/shaderlist.txt: $!"; my $previous_shaderlist = ""; @@ -210,16 +194,16 @@ for my $m(@{$options->{maps}}) rename "${m}_s.bsp", "$m.bsp" or die "rename ${m}_s.bsp $m.bsp: $!"; } - if(defined $options->{vis}) - { - q3map2 '-vis', @{$options->{vis}}, "$m.map" - or die "-vis: $?"; - } if(defined $options->{light}) { q3map2 '-light', @{$options->{light}}, "$m.map" or die "-light: $?"; } + if(defined $options->{vis}) + { + q3map2 '-vis', @{$options->{vis}}, "$m.map" + or die "-vis: $?"; + } if($postscale != 1) { q3map2 '-scale', $postscale, "$m.bsp" -- 2.39.2