r2787 - trunk/misc

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jul 8 06:44:20 EDT 2007


Author: div0
Date: 2007-07-08 06:44:20 -0400 (Sun, 08 Jul 2007)
New Revision: 2787

Added:
   trunk/misc/bsp2ent
Modified:
   trunk/misc/nexuiz-map-compiler
Log:
add tool bsp2ent to create ent file from BSP


Added: trunk/misc/bsp2ent
===================================================================
--- trunk/misc/bsp2ent	                        (rev 0)
+++ trunk/misc/bsp2ent	2007-07-08 10:44:20 UTC (rev 2787)
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Fcntl qw/:seek/;
+
+sub get($$)
+{
+	my ($fh, $n) = @_;
+	read $fh, my $v, $n
+		or die "read: $!";
+	return $v;
+}
+
+use constant LUMP_ENTITIES => 0;
+
+if(!@ARGV)
+{
+	die "Usage: bsp2ent BSPFILE > ENTFILE\n";
+}
+
+my $bspfile = $ARGV[0];
+open my $fh, '<', $bspfile
+	or die "open $bspfile: $!";
+get($fh, 4) eq 'IBSP'
+	or die "$bspfile is no IBSP";
+unpack('V', get($fh, 4)) == 0x2e
+	or die "$bspfile is no Q3 BSP";
+my @directory = map
+{
+	[unpack('VV', get($fh, 8))] # offset, length
+}
+0..16;
+
+seek($fh, $directory[LUMP_ENTITIES][0], SEEK_SET);
+my $ent = get($fh, $directory[LUMP_ENTITIES][1]);
+$ent =~ s/\000//g;
+
+print $ent;


Property changes on: trunk/misc/bsp2ent
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/misc/nexuiz-map-compiler
===================================================================
--- trunk/misc/nexuiz-map-compiler	2007-07-07 16:21:43 UTC (rev 2786)
+++ trunk/misc/nexuiz-map-compiler	2007-07-08 10:44:20 UTC (rev 2787)
@@ -74,6 +74,14 @@
 	{
 		$options->{scale} = (shift @ARGV) || 1;
 	}
+	elsif($_ eq '-novis')
+	{
+		$options->{vis} = undef;
+	}
+	elsif($_ eq '-nolight')
+	{
+		$options->{light} = undef;
+	}
 	elsif($_ =~ /^-/ and $curmode eq 'maps')
 	{
 		$curmode = 'bsp';
@@ -171,10 +179,16 @@
 			rename "${m}_s.bsp", "$m.bsp"
 				or die "rename ${m}_s.bsp $m.bsp: $!";
 		}
-		q3map2 '-vis',          @{$options->{vis}},   "$m.map"
-			or die "-vis: $?";
-		q3map2 '-light',        @{$options->{light}}, "$m.map"
-			or die "-light: $?";
+		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($postscale != 1)
 		{
 			q3map2 '-scale', $postscale, "$m.bsp"




More information about the nexuiz-commits mailing list