[nexuiz-commits] r6439 - trunk/misc/tools
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Apr 6 02:32:53 EDT 2009
Author: div0
Date: 2009-04-06 02:32:53 -0400 (Mon, 06 Apr 2009)
New Revision: 6439
Modified:
trunk/misc/tools/nexuiz-map-compiler
Log:
improve nexuiz-map-compiler
Modified: trunk/misc/tools/nexuiz-map-compiler
===================================================================
--- trunk/misc/tools/nexuiz-map-compiler 2009-04-05 23:05:49 UTC (rev 6438)
+++ trunk/misc/tools/nexuiz-map-compiler 2009-04-06 06:32:53 UTC (rev 6439)
@@ -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,42 +114,19 @@
}
}
-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 "";
+symlink "$mapdir", "$linkdir/data";
-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.";
-};
-
my ($prescale, $postscale) = ($options->{scale} =~ /^([0-9.]+)(?::([0-9.]+))?$/);
$postscale = 1 if not defined $postscale;
@@ -171,6 +149,12 @@
}
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 @@
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"
More information about the nexuiz-commits
mailing list