r5541 - in trunk: . data misc misc/mediasource misc/mediasource/graphics misc/tools

esteel at icculus.org esteel at icculus.org
Thu Jan 15 06:30:45 EST 2009


Author: esteel
Date: 2009-01-15 06:30:44 -0500 (Thu, 15 Jan 2009)
New Revision: 5541

Added:
   trunk/misc/artwork/
   trunk/misc/mediasource/
   trunk/misc/mediasource/graphics/
   trunk/misc/mediasource/graphics/sb-flag-carrying.svg
   trunk/misc/mediasource/graphics/sb-flag-dropped.svg
   trunk/misc/mediasource/graphics/sb-flag-shielded.svg
   trunk/misc/mediasource/graphics/sb-flag-taken.svg
   trunk/misc/mediasource/menuskins/
   trunk/misc/mediasource/models/
   trunk/misc/tools/
   trunk/misc/tools/assault-circuit-board-creator.pl
   trunk/misc/tools/autoshader.sh
   trunk/misc/tools/brightspot.c
   trunk/misc/tools/brightspot.sh
   trunk/misc/tools/bsp2ent
   trunk/misc/tools/bsptool.pl
   trunk/misc/tools/crc16.c
   trunk/misc/tools/csqcarchive.sh
   trunk/misc/tools/democonv-15-20.pl
   trunk/misc/tools/demosplit.pl
   trunk/misc/tools/demotc-race-record-extractor.sh
   trunk/misc/tools/demotc.pl
   trunk/misc/tools/dependencies.pl
   trunk/misc/tools/entmerge.pl
   trunk/misc/tools/fiximage.pl
   trunk/misc/tools/hslimage.c
   trunk/misc/tools/jpeg-if-not-alpha.sh
   trunk/misc/tools/makebuild.sh
   trunk/misc/tools/nexuiz-map-compiler
   trunk/misc/tools/polycount.pl
   trunk/misc/tools/spherefunc2skybox.c
   trunk/misc/tools/testbuild.sh
   trunk/misc/tools/ttf2conchars/
   trunk/misc/tools/zipdiff
Removed:
   trunk/artwork/
   trunk/graphicssource/
   trunk/misc/assault-circuit-board-creator.pl
   trunk/misc/autoshader.sh
   trunk/misc/brightspot.c
   trunk/misc/brightspot.sh
   trunk/misc/bsp2ent
   trunk/misc/bsptool.pl
   trunk/misc/crc16.c
   trunk/misc/csqcarchive.sh
   trunk/misc/democonv-15-20.pl
   trunk/misc/demosplit.pl
   trunk/misc/demotc-race-record-extractor.sh
   trunk/misc/demotc.pl
   trunk/misc/dependencies.pl
   trunk/misc/entmerge.pl
   trunk/misc/fiximage.pl
   trunk/misc/hslimage.c
   trunk/misc/jpeg-if-not-alpha.sh
   trunk/misc/makebuild.sh
   trunk/misc/nexuiz-map-compiler
   trunk/misc/polycount.pl
   trunk/misc/sb-flag-carrying.svg
   trunk/misc/sb-flag-dropped.svg
   trunk/misc/sb-flag-shielded.svg
   trunk/misc/sb-flag-taken.svg
   trunk/misc/spherefunc2skybox.c
   trunk/misc/testbuild.sh
   trunk/misc/ttf2conchars/
   trunk/misc/zipdiff
   trunk/modelsource/
   trunk/tools/
Modified:
   trunk/data/build-compat-pack.sh
Log:
somewhat huge directory restructuring, all non nexuizXX.zip files are stored in trunk/misc including artwork and mediasources like models, skins, flag icons, all tool stuff got moved to misc/tools, 

Modified: trunk/data/build-compat-pack.sh
===================================================================
--- trunk/data/build-compat-pack.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/data/build-compat-pack.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -638,7 +638,7 @@
 
 cd pack
 
-find . -type f -print0 | qual=85 scaledown=256x256 xargs -0 ../../misc/jpeg-if-not-alpha.sh
+find . -type f -print0 | qual=85 scaledown=256x256 xargs -0 ../../misc/tools/jpeg-if-not-alpha.sh
 
 find . -name \*.ogg | while IFS= read -r NAME; do
 	c=`vorbiscomment -l "$NAME"`

Copied: trunk/misc/artwork (from rev 5536, trunk/artwork)

Deleted: trunk/misc/assault-circuit-board-creator.pl
===================================================================
--- trunk/misc/assault-circuit-board-creator.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/assault-circuit-board-creator.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,278 +0,0 @@
-#!/usr/bin/perl
-
-# script that creates an "assault circuit"
-
-use strict;
-use warnings;
-
-my @objectives = @ARGV;
-
-if(!@objectives)
-{
-	print STDERR <<EOF;
-Assault Circuit Board Creator
-
-Usage: 
-  [brushprimit=1 \\]
-  [ofs_x=offset \\]
-  [ofs_y=offset \\]
-  [ofs_z=offset \\]
-  perl $0 breakables1[,buttons1] breakables2[,buttons2] breakables3[,buttons3] ... \\
-  > file.map
-
-Example:
-  ofs_z=1024 perl $0 1 1 3,2 1 > assault.map
-EOF
-	exit 1;
-}
-
-my $bp = $ENV{brushprimit};
-my @ofs = ($ENV{ofs_x} || 0, $ENV{ofs_y} || 0, $ENV{ofs_z} || 0);
-
-my $BRUSHDEF_START = $bp ? "{\nbrushDef\n{" : "{";
-my $BRUSHDEF_END   = $bp ? "}\n}" : "}";
-my $BRUSHDEF_PRE   = $bp ? "( ( 0.03125 0 -0 ) ( -0 0.03125 0 ) ) " : "";
-my $BRUSHDEF_POST  = $bp ? " 0 0 0" : " 0 0 0 0.500000 0.500000 0 0 0";
-
-sub BrushRectangle($@@)
-{
-    my ($shader, $x0, $y0, $z0, $x1, $y1, $z1) = @_;
-    return <<EOF;
-$BRUSHDEF_START
-( $x1 $y1 $z1 ) ( $x1 $y0 $z1 ) ( $x0 $y1 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
-( $x1 $y1 $z1 ) ( $x0 $y1 $z1 ) ( $x1 $y1 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
-( $x1 $y1 $z1 ) ( $x1 $y1 $z0 ) ( $x1 $y0 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
-( $x0 $y0 $z0 ) ( $x1 $y0 $z0 ) ( $x0 $y1 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
-( $x0 $y0 $z0 ) ( $x0 $y0 $z1 ) ( $x1 $y0 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
-( $x0 $y0 $z0 ) ( $x0 $y1 $z0 ) ( $x0 $y0 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
-$BRUSHDEF_END
-EOF
-}
-
-sub Entity(%)
-{
-	my (%h) = @_;
-	my @brushes = ();
-	if(ref $h{model} eq 'ARRAY')
-	{
-		@brushes = @{$h{model}};
-		delete $h{model};
-	}
-	return join "", ("{\n", (map { qq{"$_" "$h{$_}"\n} } keys %h), @brushes, "}\n");
-	# "
-}
-
-sub FindDamage($)
-{
-	my ($cnt) = @_;
-
-	my $dmg;
-
-	# 1. divisible by 10?
-	$dmg = (1 + int(10 / $cnt)) * 10;
-	return $dmg
-		if $dmg * ($cnt - 1) < 100;
-
-	# 2. divisible by 5?
-	$dmg = (1 + int(20 / $cnt)) * 5;
-	return $dmg
-		if $dmg * ($cnt - 1) < 100;
-
-	# 3. divisible by 2?
-	$dmg = (1 + int(50 / $cnt)) * 2;
-	return $dmg
-		if $dmg * ($cnt - 1) < 100;
-
-	# 4. divisible by 1?
-	$dmg = (1 + int(100 / $cnt));
-	return $dmg
-		if $dmg * ($cnt - 1) < 100;
-
-	# 5. give up
-	return (100 / $cnt + 100 / ($cnt + 1)) / 2;
-}
-
-sub ObjectiveSpawns($@)
-{
-	my ($target, $x, $y, $z) = @_;
-
-	my @l = ();
-
-	$z -= 64;
-
-	for(1..6)
-	{
-		my $xx = $x - 32;
-		my $yy = $y + ($_ - 3.5) * 64;
-		my $zz = $z - 8 - 32; # align feet to 64-grid
-		push @l, Entity
-			classname => "info_player_attacker",
-			target => $target,
-			origin => "$xx $yy $zz";
-
-		$xx = $x + 32;
-		push @l, Entity
-			classname => "info_player_defender",
-			target => $target,
-			origin => "$xx $yy $zz";
-	}
-
-	return @l;
-}
-
-my @assault_entities = ();
-
-my $obj_prev = undef;
-my $des_prev = undef;
-
-my @prevorigin = @ofs;
-
-for my $i(0.. at objectives - 1)
-{
-	my @origin =
-	(
-		$ofs[0] + ($i + 1) * 256,
-		$ofs[1] + 0,
-		$ofs[2] + 0
-	);
-
-	my $count = $objectives[$i];
-	$count =~ /^(\d+)(?:,(\d+))?$/s
-		or die "Invalid count spec: must be number or number,number";
-	my $count_destroy = $1;
-	my $count_push = $2 || 0;
-	$count = $count_destroy + $count_push;
-
-	my $obj = "obj$i";
-	my $des = "obj$i\_destructible";
-	my $dec = "obj$i\_decrease";
-
-	if($i == 0)
-	{
-		push @assault_entities, Entity
-			classname => "target_assault_roundstart",
-			target => $obj,
-			target2 => $des,
-			origin => "@prevorigin";
-	}
-	else
-	{
-		push @assault_entities, Entity
-			classname => "target_objective",
-			targetname => $obj_prev,
-			target => $obj,
-			target2 => $des,
-			origin => "@prevorigin";
-
-		push @assault_entities, ObjectiveSpawns $obj_prev, @prevorigin;
-
-		push @assault_entities, Entity
-			classname => "func_assault_wall",
-			target => $obj_prev,
-			model => [
-				BrushRectangle
-					"dsi/dsiglass",
-					$origin[0] - 128 - 32,
-					$origin[1] - 512,
-					$origin[2] - 512,
-					$origin[0] - 128 + 32,
-					$origin[1] + 512,
-					$origin[2] + 512
-			];
-	}
-
-	@prevorigin = @origin;
-
-	$origin[2] += 64;
-
-	my $dmg = FindDamage($count);
-
-	push @assault_entities, Entity
-		classname => "target_objective_decrease",
-		targetname => $dec,
-		target => $obj,
-		dmg => $dmg,
-		origin => "@origin";
-
-	$origin[2] += 64;
-
-	for(1..$count_destroy)
-	{
-		push @assault_entities, Entity
-			classname => "func_assault_destructible",
-			targetname => $des,
-			target => $dec,
-			health => 1000,
-			mdl => "rocket_explode",
-			count => 1,
-			noise => "weapons/rocket_impact.wav",
-			dmg => 50,
-			dmg_edge => 0,
-			dmg_radius => 150,
-			dmg_force => 200,
-			model => [
-				BrushRectangle
-					"dsi/cretebase",
-					$origin[0] - 16,
-					$origin[1] - 16,
-					$origin[2] - 16,
-					$origin[0] + 16,
-					$origin[1] + 16,
-					$origin[2] + 16
-			];
-
-		$origin[2] += 64;
-	}
-
-	for(1..$count_push)
-	{
-		push @assault_entities, Entity
-			classname => "func_button",
-			target => $dec,
-			angle => -2,
-			model => [
-				BrushRectangle
-					"dsi/dablue",
-					$origin[0] - 16,
-					$origin[1] - 16,
-					$origin[2] - 16,
-					$origin[0] + 16,
-					$origin[1] + 16,
-					$origin[2] + 16
-			];
-
-		$origin[2] += 64;
-	}
-
-	$obj_prev = $obj;
-	$des_prev = $des;
-}
-
-my $obj = "roundend";
-my @origin =
-(
-	$ofs[0] + (@objectives + 1) * 256,
-	$ofs[1] + 0,
-	$ofs[2] + 0
-);
-
-push @assault_entities, Entity
-	classname => "target_objective",
-	targetname => $obj_prev,
-	target => $obj,
-	origin => "@prevorigin";
-
-push @assault_entities, ObjectiveSpawns $obj_prev, @prevorigin;
-
-push @assault_entities, Entity
-	classname => "target_assault_roundend",
-	targetname => $obj,
-	origin => "@origin";
-
-my $map = join "",
-(
-	Entity(classname => "worldspawn"),
-	@assault_entities
-);
-
-print $map;

Deleted: trunk/misc/autoshader.sh
===================================================================
--- trunk/misc/autoshader.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/autoshader.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,195 +0,0 @@
-#!/bin/sh
-
-if ! [ -d "textures" ] && ! [ -d "env" ]; then
-	echo "Sorry, must be run from a directory with a textures subfolder. Giving up."
-	exit 1
-fi
-
-case "$0" in
-	*/*)
-		mydir=${0%/*}
-		;;
-	*)
-		mydir=.
-		;;
-esac
-
-makeshader()
-{
-	s=`texnormalize "$1"`
-	dir=${s#textures/}
-	dir=${dir%%/*}
-	echo scripts/$dir.shader
-	mkdir -p scripts
-	cat <<EOF >>"scripts/$dir.shader"
-$s
-{
-	qer_editorimage $1
-	qer_trans 0.5
-	// maybe: surfaceparm nonsolid
-	surfaceparm trans
-	surfaceparm alphashadow
-	surfaceparm nomarks
-	cull disable
-	{
-		map $s
-		blendfunc blend
-		// or: alphafunc GE128
-	}
-	{
-		map \$lightmap
-		blendfunc filter
-		rgbGen identity
-	}
-}
-EOF
-}
-
-makeskyshader()
-{
-	coords=`sh "$mydir/brightspot.sh" "$1"`
-	s=`texnormalize "$1"`
-	case "$coords" in
-		*\ *)
-			;;
-		*)
-			coords="-42 -42"
-			echo >&2 "NOTE: brightspot tool did not work"
-			;;
-	esac
-	s=${s%_up}
-	s=${s#env/}
-	dir=${s%%/*}
-	echo >&2 "appending to scripts/$dir.shader"
-	echo scripts/$dir.shader
-	mkdir -p scripts
-	cat <<EOF >>"scripts/$dir.shader"
-textures/$s
-{
-	qer_editorimage $1
-	surfaceparm noimpact
-	surfaceparm nolightmap
-	surfaceparm sky
-	surfaceparm nomarks
-	q3map_sunExt .5 .5 .7 $coords 2 16 // red green blue intensity degrees elevation deviance samples
-	q3map_surfacelight 150 // intensity
-	skyparms env/$s - -
-}
-EOF
-}
-
-texnormalize()
-{
-	echo "$1" | sed 's/\.[Jj][Pp][Gg]$\|\.[Tt][Gg][Aa]$\|\.[Pp][Nn][Gg]$//;'
-}
-
-allshadernames() # prints all shader names or texture names
-{
-	cat scripts/*.shader 2>/dev/null | tr '\r' '\n' | {
-		mode=root
-		while IFS= read -r LINE; do
-			LINE=`echo "$LINE" | sed 's,//.*,,; s/\s\+/ /g; s/^ //; s/ $//; s/"//g;'`
-			[ -n "$LINE" ] || continue
-			set -- $LINE
-			case "$mode:$1" in
-				root:'{')
-					mode=shader
-					;;
-				root:*)
-					texnormalize "$1"
-					;;
-
-				shader:'{')
-					mode=stage
-					;;
-				shader:'}')
-					mode=root
-					;;
-				shader:skyparms)
-					echo "`texnormalize "$1"`_up"
-					;;
-
-				stage:'}')
-					mode=shader
-					;;
-				stage:map)
-					texnormalize "$2"
-					;;
-				stage:clampmap)
-					texnormalize "$2"
-					;;
-				stage:animmap)
-					shift
-					shift
-					for X in "$@"; do
-						texnormalize "$X"
-					done
-					;;
-			esac
-		done
-	}
-}
-
-allshaders=`allshadernames`
-lf="
-"
-
-has_shader()
-{
-	sh=`texnormalize "$1"`
-	case "$lf$allshaders$lf" in
-		*"$lf$sh$lf"*)
-			return 0
-			;;
-	esac
-	return 1
-}
-
-has_alpha()
-{
-	convert "$1" -depth 8 RGBA:- | xxd -c 4 -g 1 | grep -v " ff  " >/dev/null
-}
-
-autoshaders()
-{
-	{
-		[ -d "textures" ] && find textures -type f \( -iname \*.tga -o -iname \*.png \) -print | while IFS= read -r TEX; do
-			case `texnormalize "$TEX"` in
-				*_norm|*_shirt|*_pants|*_glow|*_gloss|*_bump)
-					# ignore these (they are used implicitly)
-					continue
-					;;
-			esac
-			if has_shader "$TEX"; then
-				echo>&2 "    $TEX has an associated shader, ignoring."
-			else
-				if has_alpha "$TEX"; then
-					echo>&2 "*** $TEX has alpha but no shader, creating default alpha shader."
-					makeshader "$TEX"
-				else
-					echo>&2 "    $TEX has no shader and no alpha, fine."
-				fi
-			fi
-		done
-		[ -d "env" ] && find env -type f \( -iname \*_up.tga -o -iname \*_up.png -o -iname \*_up.jpg \) -print | while IFS= read -r TEX; do
-			if has_shader "$TEX"; then
-				echo>&2 "    $TEX has an associated shader, ignoring."
-			else
-				echo>&2 "*** $TEX is sky but has no shader, creating default sky shader."
-				makeskyshader "$TEX"
-			fi
-		done
-	} | sort -u
-}
-
-aashaders=`autoshaders`
-
-if [ -n "$aashaders" ]; then
-	cat <<EOF
-The following shader files have been automatically created or appended to:
-
-$aashaders
-
-Please edit them to your needs, and possibly rename them.
-EOF
-fi

Deleted: trunk/misc/brightspot.c
===================================================================
--- trunk/misc/brightspot.c	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/brightspot.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,195 +0,0 @@
-#include <stdio.h>
-#include <math.h>
-
-// USAGE: see brightspot.sh (and in the future brightspot.bat)
-// It should output the right parameters for the sun direction in q3map2's format.
-// But probably is broken.
-
-#define false 0
-#define true 1
-
-int flip[6*3] =
-{
-	false, false,  true, // "rt"
-	 true,  true,  true, // "lf"
-	false,  true, false, // "bk"
-	 true, false, false, // "ft"
-	false, false,  true, // "up"
-	false, false,  true  // "dn"
-};
-
-static const double skyboxtexcoord2f[6*4*2] =
-{
-    // skyside[0]
-    0, 1,
-    1, 1,
-    1, 0,
-    0, 0,
-    // skyside[1]
-    1, 0,
-    0, 0,
-    0, 1,
-    1, 1,
-    // skyside[2]
-    1, 1,
-    1, 0,
-    0, 0,
-    0, 1,
-    // skyside[3]
-    0, 0,
-    0, 1,
-    1, 1,
-    1, 0,
-    // skyside[4]
-    0, 1,
-    1, 1,
-    1, 0,
-    0, 0,
-    // skyside[5]
-    0, 1,
-    1, 1,
-    1, 0,
-    0, 0
-};
-
-
-static const double skyboxvertex3f[6*4*3] =
-{
-        // skyside[0]
-         16, -16,  16,
-         16, -16, -16,
-         16,  16, -16,
-         16,  16,  16,
-        // skyside[1]
-        -16,  16,  16,
-        -16,  16, -16,
-        -16, -16, -16,
-        -16, -16,  16,
-        // skyside[2]
-         16,  16,  16,
-         16,  16, -16,
-        -16,  16, -16,
-        -16,  16,  16,
-        // skyside[3]
-        -16, -16,  16,
-        -16, -16, -16,
-         16, -16, -16,
-         16, -16,  16,
-        // skyside[4]
-        -16, -16,  16,
-         16, -16,  16,
-         16,  16,  16,
-        -16,  16,  16,
-        // skyside[5]
-         16, -16, -16,
-        -16, -16, -16,
-        -16,  16, -16,
-         16,  16, -16
-};
-
-void Unmap2f(double x, double y, const double *corners, double *u, double *v)
-{
-	// x - corners[0] == *u * (corners[2] - corners[0]) + *v * (corners[4] - corners[2]);
-	// y - corners[1] == *u * (corners[3] - corners[1]) + *v * (corners[5] - corners[3]);
-	
-	double xc0 = x - corners[0];
-	double yc1 = y - corners[1];
-	double c20 = corners[2] - corners[0];
-	double c31 = corners[3] - corners[1];
-	double c42 = corners[4] - corners[2];
-	double c53 = corners[5] - corners[3];
-
-	// xc0 == *u * c20 + *v * c42;
-	// yc1 == *u * c31 + *v * c53;
-
-	double det = c20 * c53 - c31 * c42;
-	double du = xc0 * c53 - yc1 * c42;
-	double dv = c20 * yc1 - c31 * xc0;
-
-	*u = du / det;
-	*v = dv / det;
-}
-
-void Map3f(double u, double v, const double *corners, double *x, double *y, double *z)
-{
-	*x = corners[0] + u * (corners[3] - corners[0]) + v * (corners[6] - corners[3]);
-	*y = corners[1] + u * (corners[4] - corners[1]) + v * (corners[7] - corners[4]);
-	*z = corners[2] + u * (corners[5] - corners[2]) + v * (corners[8] - corners[5]);
-}
-
-void MapCoord(int pic, int y, int x, double vec[3])
-{
-	int h;
-	int flipx = flip[3*pic+0];
-	int flipy = flip[3*pic+1];
-	int flipdiag = flip[3*pic+2];
-	double u, v;
-
-	if(flipx)
-		x = 511 - x;
-
-	if(flipy)
-		y = 511 - y;
-
-	if(flipdiag)
-	{
-		h = x; x = y; y = h;
-	}
-
-	Unmap2f((x + 0.5) / 512.0, (y + 0.5) / 512.0, skyboxtexcoord2f + 4*2*pic, &u, &v);
-	Map3f(u, v, skyboxvertex3f + 6*2*pic, &vec[0], &vec[1], &vec[2]);
-}
-
-int main(int argc, char **argv)
-{
-	FILE *f;
-	int i, j, k;
-	unsigned char picture[6][512][512];
-	unsigned char max;
-	double brightvec[3];
-	double pitch, yaw, l;
-
-	if(argc != 2)
-	{
-		fprintf(stderr, "Usage: %s imagefile.gray\n", *argv);
-		return 1;
-	}
-
-	f = fopen(argv[1], "rb");
-	if(!f)
-	{
-		perror("fopen");
-		return 1;
-	}
-	fread(&picture, sizeof(picture), 1, f);
-	fclose(f);
-
-	brightvec[0] = brightvec[1] = brightvec[2] = 0;
-	max = 0;
-	for(i = 0; i < 6; ++i)
-		for(j = 0; j < 512; ++j)
-			for(k = 0; k < 512; ++k)
-				if(picture[i][j][k] > max)
-					max = picture[i][j][k];
-	for(i = 0; i < 6; ++i)
-		for(j = 0; j < 512; ++j)
-			for(k = 0; k < 512; ++k)
-			{
-				double vec[3], f;
-				MapCoord(i, j, k, vec);
-				f = pow(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2], -1.5); // I know what I am doing.
-				f *= exp(10 * (picture[i][j][k] - max));
-				brightvec[0] += f * vec[0];
-				brightvec[1] += f * vec[1];
-				brightvec[2] += f * vec[2];
-			}
-
-	l = sqrt(brightvec[0]*brightvec[0] + brightvec[1]*brightvec[1] + brightvec[2]*brightvec[2]);
-	fprintf(stderr, "vec = %f %f %f\n", brightvec[0] / l, brightvec[1] / l, brightvec[2] / l);
-	
-	pitch = atan2(brightvec[2], sqrt(brightvec[0]*brightvec[0] + brightvec[1]*brightvec[1]));
-	yaw = atan2(brightvec[1], brightvec[0]);
-
-	printf("%f %f\n", yaw * 180 / M_PI, pitch * 180 / M_PI);
-	return 0;
-}

Deleted: trunk/misc/brightspot.sh
===================================================================
--- trunk/misc/brightspot.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/brightspot.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,36 +0,0 @@
-#!/bin/sh
-
-if [ -z "$1" ]; then
-	echo>&2 "Usage: $0 foo_rt.jpg"
-	exit 1
-fi
-
-brightspot=
-if which brightspot-bin >/dev/null; then
-	brightspot=brightspot-bin
-else
-	case "$0" in
-		*/*)
-			mydir=${0%/*}
-			;;
-		*)
-			mydir=.
-			;;
-	esac
-	brightspot="$mydir/brightspot-bin"
-	[ "$brightspot" -nt "$mydir/brightspot.c" ] || gcc -lm -O3 -Wall -Wextra "$mydir/brightspot.c" -o "$brightspot" || exit 1
-fi
-
-i=$1
-ext=${i##*.}
-name=${i%.*}
-name=${name%_[rlbfud][tfktpn]}
-
-{
-	convert "$name"_rt."$ext" -depth 8 -geometry 512x512 GRAY:-
-	convert "$name"_lf."$ext" -depth 8 -geometry 512x512 GRAY:-
-	convert "$name"_bk."$ext" -depth 8 -geometry 512x512 GRAY:-
-	convert "$name"_ft."$ext" -depth 8 -geometry 512x512 GRAY:-
-	convert "$name"_up."$ext" -depth 8 -geometry 512x512 GRAY:-
-	convert "$name"_dn."$ext" -depth 8 -geometry 512x512 GRAY:-
-} | "$brightspot" /dev/stdin

Deleted: trunk/misc/bsp2ent
===================================================================
--- trunk/misc/bsp2ent	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/bsp2ent	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,39 +0,0 @@
-#!/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;

Deleted: trunk/misc/bsptool.pl
===================================================================
--- trunk/misc/bsptool.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/bsptool.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,515 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use Image::Magick;
-use POSIX qw/floor ceil/;
-
-my @lumpname = qw/entities textures planes nodes leafs leaffaces leafbrushes models brushes brushsides vertices triangles effects faces lightmaps lightgrid pvs advertisements/;
-my %lumpid = map { $lumpname[$_] => $_ } 0.. at lumpname-1;
-my $msg = "";
-my @bsp;
-
-# READ THE BSP
-
-if(!@ARGV || $ARGV[0] eq '-h' || $ARGV[0] eq '--help')
-{
-	print <<EOF;
-Usage:
-  $0 filename.bsp [operations...]
-
-Operations are:
-  Information requests:
-    -i                print info about the BSP file
-    -xlumpname        extract a lump (see -i)
-
-  Changes:
-    -dlumpname        delete a lump (see -i)
-    -rlumpname        replace a lump (see -i) by the data from standard input
-    -gfilename.tga    save the lightgrid as filename.tga (debugging)
-    -Gratio           scale down the lightgrid to reduce BSP file size
-    -ljpgNNN          externalize the lightmaps as JPEG, quality NNN (number from 1 to 100)
-    -lpng             externalize the lightmaps as PNG
-    -ltga             externalize the lightmaps as TGA
-    -mMESSAGE         set the BSP file comment message
-
-  Save commands:
-    -o                actually apply the changes to the BSP
-    -ofilename2.bsp   save the changes to a new BSP file
-EOF
-	exit;
-}
-
-my $fn = shift @ARGV;
-$fn =~ /(.*)\.bsp$/
-	or die "invalid input file name (must be a .bsp): $fn";
-my $basename = $1;
-open my $fh, "<", $fn
-	or die "$fn: $!";
-
-read $fh, my $header, 8;
-
-die "Invalid BSP format"
-	if $header ne "IBSP\x2e\x00\x00\x00";
-
-for(0..16)
-{
-	read $fh, my $lump, 8;
-	my ($offset, $length) = unpack "VV", $lump;
-
-	push @bsp, [$offset, $length, undef];
-}
-
-for(@bsp)
-{
-	my ($offset, $length, $data) = @$_;
-	seek $fh, $offset, 0;
-	read $fh, $data, $length;
-	length $data == $length
-		or die "Incomplete BSP lump at $offset\n";
-	$_->[2] = $data;
-}
-
-close $fh;
-
-# STRUCT DECODING
-
-sub DecodeLump($@)
-{
-	my ($lump, @fields) = @_;
-	my @decoded;
-
-	my $spec = "";
-	my @decoders;
-
-	my $item;
-	my @data;
-	my $idx;
-
-	for(@fields)
-	{
-		if(/^(\w*)=(.*?)(\d*)$/)
-		{
-			$spec .= "$2$3 ";
-			my $f = $1;
-			my $n = $3;
-			if($n eq '')
-			{
-				push @decoders, sub { $item->{$f} = $data[$idx++]; };
-			}
-			else
-			{
-				push @decoders, sub { $item->{$f} = [ map { $data[$idx++] } 1..$n ]; };
-			}
-		}
-	}
-
-	my $itemlen = length pack $spec, ();
-	my $len = length $lump;
-
-	die "Invalid lump size: $len not divisible by $itemlen"
-		if $len % $itemlen;
-
-	my $items = $len / $itemlen;
-	for(0..$items - 1)
-	{
-		@data = unpack $spec, substr $lump, $_ * $itemlen, $itemlen;
-		$item = {};
-		$idx = 0;
-		$_->() for @decoders;
-		push @decoded, $item;
-	}
-	@decoded;
-}
-
-sub EncodeLump($@)
-{
-	my ($items, @fields) = @_;
-	my @decoded;
-
-	my @encoders;
-
-	my $item;
-	my @data;
-	my $idx;
-	my $data = "";
-
-	for(@fields)
-	{
-		if(/^(\w*)=(.*?)(\d*)$/)
-		{
-			my $spec = "$2$3";
-			my $f = $1;
-			my $n = $3;
-			if($n eq '')
-			{
-				push @encoders, sub { $data .= pack $spec, $item->{$f}; };
-			}
-			else
-			{
-				push @encoders, sub { $data .= pack $spec, @{$item->{$f}}; };
-			}
-		}
-	}
-
-	for my $i(@$items)
-	{
-		$item = $i;
-		$_->() for @encoders;
-	}
-
-	$data;
-}
-
-sub EncodeDirection(@)
-{
-	my ($x, $y, $z) = @_;
-
-	return [
-		map { ($_ / 0.02454369260617025967) & 0xFF }
-		(
-			atan2(sqrt($x * $x + $y * $y), $z),
-			atan2($y, $x)
-		)
-	];
-}
-
-sub DecodeDirection($)
-{
-	my ($dir) = @_;
-
-	my ($pitch, $yaw) = map { $_ * 0.02454369260617025967 } @$dir; # maps 256 to 2pi
-
-	return (
-		cos($yaw) * sin($pitch),
-		sin($yaw) * sin($pitch),
-		cos($pitch)
-	);
-}
-
-sub IntervalIntersection($$$$)
-{
-	my ($a, $al, $b, $bl) = @_;
-	my $a0 = $a - 0.5 * $al;
-	my $a1 = $a + 0.5 * $al;
-	my $b0 = $b - 0.5 * $bl;
-	my $b1 = $b + 0.5 * $bl;
-	my $left = ($a0 > $b0) ? $a0 : $b0;
-	my $right = ($a1 > $b1) ? $b1 : $a1;
-	die "Non-intersecting intervals $a $al $b $bl"
-		if $right < $left;
-	return $right - $left;
-}
-
-sub BoxIntersection(@)
-{
-	my ($x, $y, $z, $w, $h, $d, $x2, $y2, $z2, $w2, $h2, $d2) = @_;
-	return
-		IntervalIntersection($x, $w, $x2, $w2)
-		*
-		IntervalIntersection($y, $h, $y2, $h2)
-		*
-		IntervalIntersection($z, $d, $z2, $d2);
-}
-
-# OPTIONS
-
-for(@ARGV)
-{
-	if(/^-i$/) # info
-	{
-		my $total = 17 * 8 + 8 + length($msg);
-		my $max = 0;
-		for(0.. at bsp-1)
-		{
-			my $nl = length $bsp[$_]->[2];
-			$total += $nl;
-			print "BSP lump $_ ($lumpname[$_]): offset $bsp[$_]->[0] length $bsp[$_]->[1] newlength $nl\n";
-			my $endpos = $bsp[$_]->[0] + $bsp[$_]->[1];
-			$max = $endpos if $max < $endpos;
-		}
-		print "BSP file size will change from $max to $total bytes\n";
-	}
-	elsif(/^-d(.+)$/) # delete a lump
-	{
-		my $id = $lumpid{$1};
-		die "invalid lump $1 to remove"
-			unless defined $id;
-		$bsp[$id]->[2] = "";
-	}
-	elsif(/^-r(.+)$/) # replace a lump
-	{
-		my $id = $lumpid{$1};
-		die "invalid lump $1 to replace"
-			unless defined $id;
-		$bsp[$id]->[2] = do { undef local $/; scalar <STDIN>; };
-	}
-	elsif(/^-m(.*)$/) # change the message
-	{
-		$msg = $1;
-	}
-	elsif(/^-l(jpg|png|tga)(\d+)?$/) # externalize lightmaps (deleting the internal ones)
-	{
-		my $ext = $1;
-		my $quality = $2;
-		my %lightmaps = ();
-		my $faces = $bsp[$lumpid{faces}]->[2];
-		my $lightmaps = $bsp[$lumpid{lightmaps}]->[2];
-		my @values = DecodeLump $faces,
-			qw/texture=V effect=V type=V vertex=V n_vertexes=V meshvert=V n_meshverts=V lm_index=V lm_start=f2 lm_size=f2 lm_origin=f3 lm_vec_0=f3 lm_vec_1=f3 normal=f3 size=V2/;
-		my $oddfound = 0;
-		for(@values)
-		{
-			my $l = $_->{lm_index};
-			next if $l >= 2**31; # signed
-			$oddfound = 1
-				if $l % 2;
-			++$lightmaps{$l};
-		}
-		if(!$oddfound)
-		{
-			$lightmaps{$_+1} = $lightmaps{$_} for keys %lightmaps;
-		}
-		for(sort { $a <=> $b } keys %lightmaps)
-		{
-			print STDERR "Lightmap $_ was used $lightmaps{$_} times\n";
-
-			# export that lightmap
-			my $lmsize = 128 * 128 * 3;
-			next if length $lightmaps < ($_ + 1) * $lmsize;
-			my $lmdata = substr $lightmaps, $_ * $lmsize, $lmsize;
-			my $img = Image::Magick->new(size => '128x128', depth => 8, magick => 'RGB');
-			$img->BlobToImage($lmdata);
-			my $outfn = sprintf "%s/lm_%04d.$ext", $basename, $_;
-			mkdir $basename;
-			$img->Set(quality => $quality)
-				if defined $quality;
-			my $err = $img->Write($outfn);
-			die $err
-				if $err;
-			print STDERR "Wrote $outfn\n";
-		}
-
-		# nullify the lightmap lump
-		$bsp[$lumpid{lightmaps}]->[2] = "";
-	}
-	elsif(/^-g(.+)$/) # export light grid as an image (for debugging)
-	{
-		my $filename = $1;
-		my @models = DecodeLump $bsp[$lumpid{models}]->[2],
-			qw/mins=f3 maxs=f3 face=V n_faces=V brush=V n_brushes=V/;
-		my $entities = $bsp[$lumpid{entities}]->[2];
-		my @entitylines = split /\r?\n/, $entities;
-		my $gridsize = "64 64 128";
-		for(@entitylines)
-		{
-			last if $_ eq '}';
-			/^\s*"gridsize"\s+"(.*)"$/
-				and $gridsize = $1;
-		}
-		my @scale = map { 1 / $_ } split / /, $gridsize;
-		my @imins = map { ceil($models[0]{mins}[$_] * $scale[$_]) } 0..2;
-		my @imaxs = map { floor($models[0]{maxs}[$_] * $scale[$_]) } 0..2;
-		my @isize = map { $imaxs[$_] - $imins[$_] + 1 } 0..2;
-		my $isize = $isize[0] * $isize[1] * $isize[2];
-		my @gridcells = DecodeLump $bsp[$lumpid{lightgrid}]->[2],
-			qw/ambient=C3 directional=C3 dir=C2/;
-		die "Cannot decode light grid"
-			unless $isize == @gridcells;
-
-		# sum up the "ambient" light over all pixels
-		my @pixels;
-		my $max = 1;
-		for my $y(0..$isize[1]-1)
-		{
-			for my $x(0..$isize[0]-1)
-			{
-				my ($r, $g, $b) = (0, 0, 0);
-				for my $z(0..$isize[2]-1)
-				{
-					my $cell = $gridcells[$x + $y * $isize[0] + $z * $isize[0] * $isize[1]];
-					$r += $cell->{ambient}->[0];
-					$g += $cell->{ambient}->[1];
-					$b += $cell->{ambient}->[2];
-				}
-				push @pixels, [$r, $g, $b];
-				$max = $r if $max < $r;
-				$max = $g if $max < $g;
-				$max = $b if $max < $b;
-			}
-		}
-		my $pixeldata = "";
-		for my $p(@pixels)
-		{
-			$pixeldata .= pack "CCC", map { 255 * $p->[$_] / $max } 0..2;
-		}
-
-		my $img = Image::Magick->new(size => sprintf("%dx%d", $isize[0], $isize[1]), depth => 8, magick => 'RGB');
-		$img->BlobToImage($pixeldata);
-		$img->Write($filename);
-		print STDERR "Wrote $filename\n";
-	}
-	elsif(/^-G(.+)$/) # decimate light grid
-	{
-		my $decimate = $1;
-		my $filter = 1; # 0 = nearest, 1 = box filter
-
-		my @models = DecodeLump $bsp[$lumpid{models}]->[2],
-			qw/mins=f3 maxs=f3 face=V n_faces=V brush=V n_brushes=V/;
-		my $entities = $bsp[$lumpid{entities}]->[2];
-		my @entitylines = split /\r?\n/, $entities;
-		my $gridsize = "64 64 128";
-		my $gridsizeindex = undef;
-		for(0.. at entitylines-1)
-		{
-			my $l = $entitylines[$_];
-			last if $l eq '}';
-			if($l =~ /^\s*"gridsize"\s+"(.*)"$/)
-			{
-				$gridsize = $1;
-				$gridsizeindex = $_;
-			}
-		}
-		my @scale = map { 1 / $_ } split / /, $gridsize;
-		my @imins = map { ceil($models[0]{mins}[$_] * $scale[$_]) } 0..2;
-		my @imaxs = map { floor($models[0]{maxs}[$_] * $scale[$_]) } 0..2;
-		my @isize = map { $imaxs[$_] - $imins[$_] + 1 } 0..2;
-		my $isize = $isize[0] * $isize[1] * $isize[2];
-		my @gridcells = DecodeLump $bsp[$lumpid{lightgrid}]->[2],
-			qw/ambient=C3 directional=C3 dir=C2/;
-		die "Cannot decode light grid"
-			unless $isize == @gridcells;
-
-		# get the new grid size values
-		my @newscale = map { $_ / $decimate } @scale;
-		my $newgridsize = join " ", map { 1 / $_ } @newscale;
-		my @newimins = map { ceil($models[0]{mins}[$_] * $newscale[$_]) } 0..2;
-		my @newimaxs = map { floor($models[0]{maxs}[$_] * $newscale[$_]) } 0..2;
-		my @newisize = map { $newimaxs[$_] - $newimins[$_] + 1 } 0..2;
-
-		# do the decimation
-		my @newgridcells = ();
-		for my $z($newimins[2]..$newimaxs[2])
-		{
-			# the coords are MIDPOINTS of the grid cells!
-			my @oldz = grep { $_ >= $imins[2] && $_ <= $imaxs[2] } floor(($z - 0.5) * $decimate + 0.5) .. ceil(($z + 0.5) * $decimate - 0.5);
-			my $innerz_raw = $z * $decimate;
-			my $innerz = floor($innerz_raw + 0.5);
-			$innerz = $imins[2] if $innerz < $imins[2];
-			$innerz = $imaxs[2] if $innerz > $imaxs[2];
-			for my $y($newimins[1]..$newimaxs[1])
-			{
-				my @oldy = grep { $_ >= $imins[1] && $_ <= $imaxs[1] } floor(($y - 0.5) * $decimate + 0.5) .. ceil(($y + 0.5) * $decimate - 0.5);
-				my $innery_raw = $y * $decimate;
-				my $innery = floor($innery_raw + 0.5);
-				$innery = $imins[1] if $innery < $imins[1];
-				$innery = $imaxs[1] if $innery > $imaxs[1];
-				for my $x($newimins[0]..$newimaxs[0])
-				{
-					my @oldx = grep { $_ >= $imins[0] && $_ <= $imaxs[0] } floor(($x - 0.5) * $decimate + 0.5) .. ceil(($x + 0.5) * $decimate - 0.5);
-					my $innerx_raw = $x * $decimate;
-					my $innerx = floor($innerx_raw + 0.5);
-					$innerx = $imins[0] if $innerx < $imins[0];
-					$innerx = $imaxs[0] if $innerx > $imaxs[0];
-
-					my @vec = (0, 0, 0);
-					my @dir = (0, 0, 0);
-					my @amb = (0, 0, 0);
-					my $weight = 0;
-					my $innercell = $gridcells[($innerx - $imins[0]) + $isize[0] * ($innery - $imins[1]) + $isize[0] * $isize[1] * ($innerz - $imins[2])];
-					for my $Z(@oldz)
-					{
-						for my $Y(@oldy)
-						{
-							for my $X(@oldx)
-							{
-								my $cell = $gridcells[($X - $imins[0]) + $isize[0] * ($Y - $imins[1]) + $isize[0] * $isize[1] * ($Z - $imins[2])];
-
-								my $cellweight = BoxIntersection(
-									$X, $Y, $Z, 1, 1, 1,
-									map { $_ * $decimate } $x, $y, $z, 1, 1, 1
-								);
-
-								$dir[$_] += $cellweight * $cell->{directional}->[$_] for 0..2;
-								$amb[$_] += $cellweight * $cell->{ambient}->[$_] for 0..2;
-								my @norm = DecodeDirection $cell->{dir};
-								$vec[$_] += $cellweight * $norm[$_] for 0..2;
-								$weight += $cellweight;
-							}
-						}
-					}
-					if($weight)
-					{
-						$dir[$_] /= $weight for 0..2;
-						$dir[$_] *= $filter for 0..2;
-						$dir[$_] += (1 - $filter) * $innercell->{directional}->[$_] for 0..2;
-
-						$amb[$_] /= $weight for 0..2;
-						$amb[$_] *= $filter for 0..2;
-						$amb[$_] += (1 - $filter) * $innercell->{ambient}->[$_] for 0..2;
-
-						my @norm = DecodeDirection $innercell->{dir};
-						$vec[$_] /= $weight for 0..2;
-						$vec[$_] *= $filter for 0..2;
-						$vec[$_] += (1 - $filter) * $norm[$_] for 0..2;
-
-						$innercell = {
-							ambient => \@amb,
-							directional => \@dir,
-							dir => EncodeDirection @norm
-						};
-					}
-
-					push @newgridcells, $innercell;
-				}
-			}
-		}
-
-		$bsp[$lumpid{lightgrid}]->[2] = EncodeLump \@newgridcells,
-			qw/ambient=C3 directional=C3 dir=C2/;
-		splice @entitylines, $gridsizeindex, 1, ()
-			if defined $gridsizeindex;
-		splice @entitylines, 1, 0, qq{"gridsize" "$newgridsize"};
-		$bsp[$lumpid{entities}]->[2] = join "\n", @entitylines;
-	}
-	elsif(/^-x(.+)$/) # extract lump to stdout
-	{
-		my $id = $lumpid{$1};
-		die "invalid lump $1 to extract"
-			unless defined $id;
-		print $bsp[$id]->[2];
-	}
-	elsif(/^-o(.+)?$/) # write the final BSP file
-	{
-		my $outfile = $1;
-		$outfile = $fn
-			if not defined $outfile;
-		open my $fh, ">", $outfile
-			or die "$outfile: $!";
-		print $fh $header;
-		my $pos = 17 * 8 + tell($fh) + length $msg;
-		for(@bsp)
-		{
-			$_->[0] = $pos;
-			$_->[1] = length $_->[2];
-			$pos += $_->[1];
-			print $fh pack "VV", $_->[0], $_->[1];
-		}
-		print $fh $msg;
-		for(@bsp)
-		{
-			print $fh $_->[2];
-		}
-		close $fh;
-		print STDERR "Wrote $outfile\n";
-	}
-	else
-	{
-		die "Invalid option: $_";
-	}
-}
-
-# TODO:
-#   features like:
-#     decimate light grid
-#     edit lightmaps/grid

Deleted: trunk/misc/crc16.c
===================================================================
--- trunk/misc/crc16.c	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/crc16.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,97 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-
-// this CRC matches DP
-// output is:
-//   filesize.crc16
-// usage:
-//   mv csprogs.dat csprogs.dat.`crc16 < csprogs.dat`
-// see script csqcarchive.sh
-
-/*
-============================================================================
-
-					CRC FUNCTIONS
-
-============================================================================
-*/
-
-// this is a 16 bit, non-reflected CRC using the polynomial 0x1021
-// and the initial and final xor values shown below...  in other words, the
-// CCITT standard CRC used by XMODEM
-
-#define CRC_INIT_VALUE	0xffff
-#define CRC_XOR_VALUE	0x0000
-
-static unsigned short crctable[256] =
-{
-	0x0000,	0x1021,	0x2042,	0x3063,	0x4084,	0x50a5,	0x60c6,	0x70e7,
-	0x8108,	0x9129,	0xa14a,	0xb16b,	0xc18c,	0xd1ad,	0xe1ce,	0xf1ef,
-	0x1231,	0x0210,	0x3273,	0x2252,	0x52b5,	0x4294,	0x72f7,	0x62d6,
-	0x9339,	0x8318,	0xb37b,	0xa35a,	0xd3bd,	0xc39c,	0xf3ff,	0xe3de,
-	0x2462,	0x3443,	0x0420,	0x1401,	0x64e6,	0x74c7,	0x44a4,	0x5485,
-	0xa56a,	0xb54b,	0x8528,	0x9509,	0xe5ee,	0xf5cf,	0xc5ac,	0xd58d,
-	0x3653,	0x2672,	0x1611,	0x0630,	0x76d7,	0x66f6,	0x5695,	0x46b4,
-	0xb75b,	0xa77a,	0x9719,	0x8738,	0xf7df,	0xe7fe,	0xd79d,	0xc7bc,
-	0x48c4,	0x58e5,	0x6886,	0x78a7,	0x0840,	0x1861,	0x2802,	0x3823,
-	0xc9cc,	0xd9ed,	0xe98e,	0xf9af,	0x8948,	0x9969,	0xa90a,	0xb92b,
-	0x5af5,	0x4ad4,	0x7ab7,	0x6a96,	0x1a71,	0x0a50,	0x3a33,	0x2a12,
-	0xdbfd,	0xcbdc,	0xfbbf,	0xeb9e,	0x9b79,	0x8b58,	0xbb3b,	0xab1a,
-	0x6ca6,	0x7c87,	0x4ce4,	0x5cc5,	0x2c22,	0x3c03,	0x0c60,	0x1c41,
-	0xedae,	0xfd8f,	0xcdec,	0xddcd,	0xad2a,	0xbd0b,	0x8d68,	0x9d49,
-	0x7e97,	0x6eb6,	0x5ed5,	0x4ef4,	0x3e13,	0x2e32,	0x1e51,	0x0e70,
-	0xff9f,	0xefbe,	0xdfdd,	0xcffc,	0xbf1b,	0xaf3a,	0x9f59,	0x8f78,
-	0x9188,	0x81a9,	0xb1ca,	0xa1eb,	0xd10c,	0xc12d,	0xf14e,	0xe16f,
-	0x1080,	0x00a1,	0x30c2,	0x20e3,	0x5004,	0x4025,	0x7046,	0x6067,
-	0x83b9,	0x9398,	0xa3fb,	0xb3da,	0xc33d,	0xd31c,	0xe37f,	0xf35e,
-	0x02b1,	0x1290,	0x22f3,	0x32d2,	0x4235,	0x5214,	0x6277,	0x7256,
-	0xb5ea,	0xa5cb,	0x95a8,	0x8589,	0xf56e,	0xe54f,	0xd52c,	0xc50d,
-	0x34e2,	0x24c3,	0x14a0,	0x0481,	0x7466,	0x6447,	0x5424,	0x4405,
-	0xa7db,	0xb7fa,	0x8799,	0x97b8,	0xe75f,	0xf77e,	0xc71d,	0xd73c,
-	0x26d3,	0x36f2,	0x0691,	0x16b0,	0x6657,	0x7676,	0x4615,	0x5634,
-	0xd94c,	0xc96d,	0xf90e,	0xe92f,	0x99c8,	0x89e9,	0xb98a,	0xa9ab,
-	0x5844,	0x4865,	0x7806,	0x6827,	0x18c0,	0x08e1,	0x3882,	0x28a3,
-	0xcb7d,	0xdb5c,	0xeb3f,	0xfb1e,	0x8bf9,	0x9bd8,	0xabbb,	0xbb9a,
-	0x4a75,	0x5a54,	0x6a37,	0x7a16,	0x0af1,	0x1ad0,	0x2ab3,	0x3a92,
-	0xfd2e,	0xed0f,	0xdd6c,	0xcd4d,	0xbdaa,	0xad8b,	0x9de8,	0x8dc9,
-	0x7c26,	0x6c07,	0x5c64,	0x4c45,	0x3ca2,	0x2c83,	0x1ce0,	0x0cc1,
-	0xef1f,	0xff3e,	0xcf5d,	0xdf7c,	0xaf9b,	0xbfba,	0x8fd9,	0x9ff8,
-	0x6e17,	0x7e36,	0x4e55,	0x5e74,	0x2e93,	0x3eb2,	0x0ed1,	0x1ef0
-};
-
-unsigned short CRC_Block(const unsigned char *data, size_t size)
-{
-	unsigned short crc = CRC_INIT_VALUE;
-	while (size--)
-		crc = (crc << 8) ^ crctable[(crc >> 8) ^ (*data++)];
-	return crc ^ CRC_XOR_VALUE;
-}
-
-int main()
-{
-	unsigned char *buf;
-	size_t bufsize = 0;
-	size_t newbufsize;
-	size_t nread;
-
-	for(;;)
-	{
-		newbufsize = 2 * bufsize + 1;
-		buf = realloc(buf, newbufsize);
-		nread = fread(buf + bufsize, 1, newbufsize - bufsize, stdin);
-		if(nread != newbufsize - bufsize)
-		{
-			// output checksum
-			unsigned short crc = CRC_Block(buf, bufsize + nread);
-			printf("%ju.%u\n", (uintmax_t) (bufsize + nread), crc);
-
-			// exit
-			break;
-		}
-		bufsize = newbufsize;
-	}
-
-	return 0;
-}

Deleted: trunk/misc/csqcarchive.sh
===================================================================
--- trunk/misc/csqcarchive.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/csqcarchive.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-set -e
-
-make crc16
-crc16=`pwd`/crc16
-out=`pwd`/csqcarchive.zip
-
-t=`mktemp -dt csqcarchive.XXXXXX`
-cd "$t"
-
-revs()
-{
-	{
-		svn log svn://svn.icculus.org/nexuiz/$1/data/qcsrc/common
-		echo
-		svn log svn://svn.icculus.org/nexuiz/$1/data/qcsrc/client
-	} | {
-		while IFS= read -r LINE; do
-			if [ "$LINE" = "------------------------------------------------------------------------" ]; then
-				read -r REV REST
-				case "$REV" in
-					r*)
-						echo ${REV#r}
-						;;
-				esac
-			fi
-		done
-	} | sort -n
-}
-
-rm -f "$out"
-for repo in branches/nexuiz-2.0 trunk; do
-	for rev in `revs $repo`; do
-		if [ "$rev" -lt 3789 ]; then
-			continue
-		fi
-		svn checkout -r"$rev" svn://svn.icculus.org/nexuiz/$repo/data/qcsrc
-		rm -f Makefile csprogs.dat
-		wget -OMakefile "http://svn.icculus.org/*checkout*/nexuiz/$repo/data/Makefile?revision=$rev" || continue
-		make csprogs.dat || continue
-		nm="csprogs.dat.`$crc16 < csprogs.dat`"
-		mv csprogs.dat "$nm"
-		zip -9r "$out" "$nm"
-	done
-done

Deleted: trunk/misc/democonv-15-20.pl
===================================================================
--- trunk/misc/democonv-15-20.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/democonv-15-20.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,100 +0,0 @@
-#!/usr/bin/perl
-
-# usage:
-#   ./democonv-15-20.pl infile outfile
-
-use strict;
-use warnings;
-
-# constants
-my $svc_print = "\010";
-my $svc_serverinfo = "\013";
-
-my %maps = (
-	nexdm01 => 'basement',
-	nexdm02 => 'bleach',
-	nexdm03 => 'slimepit',
-	nexdm04 => 'skyway',
-	nexdm05 => 'downer',
-	nexdm06 => 'starship',
-	nexdm07 => 'dsi',
-	nexdm08 => 'glowarena',
-	nexdm09 => 'aneurysm',
-	nexdm10 => 'stormkeep',
-	nexdm11 => 'ruinsofslaughter',
-	nexdm12 => 'evilspace',
-	nexdm13 => 'dismal',
-	nexdm14 => 'soylent',
-	nexdm15 => 'oilrig',
-	nexdm16 => 'silvercity',
-	nexdm17 => 'dieselpower',
-	nexdm18 => 'runningman',
-	nexdm18_1on1remix => 'runningman_1on1remix',
-	nexdmextra1 => 'darkzone',
-	nexdmextra2 => 'aggressor',
-	nexctf01 => 'basementctf',
-	nexctf02 => 'runningmanctf',
-);
-
-# opening the files
-
-push @ARGV, "$ARGV[0]-converted.dem"
-	if @ARGV == 1;
-
-die "Usage: $0 infile outfile"
-	if @ARGV != 2;
-my ($in, $out) = @ARGV;
-
-$in ne $out
-	or die "Input and output file may not be the same!";
-
-open my $infh, "<", $in
-	or die "open $in: $!";
-binmode $infh;
-
-open my $outfh, ">", $out
-	or die "open $out: $!";
-binmode $outfh;
-
-sub TranslateMapname($)
-{
-	my ($map) = @_;
-	return $maps{$map}
-		if exists $maps{$map};
-	return $map;
-}
-
-# 1. CD track
-
-$/ = "\012";
-my $cdtrack = <$infh>;
-print $outfh $cdtrack;
-
-# 2. packets
-
-for(;;)
-{
-	last
-		unless 4 == read $infh, my $length, 4;
-	$length = unpack("V", $length);
-	die "Invalid demo packet"
-		unless 12 == read $infh, my $angles, 12;
-	die "Invalid demo packet"
-		unless $length == read $infh, my($data), $length;
-
-	$data =~ s{
-		^
-		($svc_print
-			[^\0]*\0
-		$svc_serverinfo....
-			[^\0]*\0
-			maps/)([^\0]*)(\.bsp\0)
-	}{$1 . TranslateMapname($2) . $3}sex;
-
-	print $outfh pack("V", length $data);
-	print $outfh $angles;
-	print $outfh $data;
-}
-
-close $outfh;
-close $infh;

Deleted: trunk/misc/demosplit.pl
===================================================================
--- trunk/misc/demosplit.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/demosplit.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,72 +0,0 @@
-#!/usr/bin/perl
-
-# usage:
-#   ./demosplit.pl demo.dem
-# splits the demo into separate demos for each map played and writes them
-# to demo-0000.dem, demo-0001.dem ...
-
-use strict;
-use warnings;
-
-# constants
-my $svc_signon = "\001";
-
-# opening the files
-
-die "Usage: $0 infile"
-	if @ARGV != 1;
-my ($in) = @ARGV;
-
-my $demoname = [$in =~ /^(.*)\.dem$/]->[0];
-$demoname = "out"
-	if not defined $demoname;
-
-open my $infh, "<", $in
-	or die "open $in: $!";
-binmode $infh;
-
-# 1. CD track
-
-$/ = "\012";
-my $cdtrack = <$infh>;
-
-# 2. packets
-
-my $outfh;
-my $outnum = 0;
-
-for(;;)
-{
-	last
-		unless 4 == read $infh, my $length, 4;
-	$length = unpack("V", $length);
-	die "Invalid demo packet"
-		unless 12 == read $infh, my $angles, 12;
-	die "Invalid demo packet"
-		unless $length == read $infh, my($data), $length;
-
-	if($data =~ m{
-		^
-		$svc_signon
-		$
-	}sx)
-	{
-		close $outfh
-			if $outfh;
-		my $outname = sprintf("%s-%04d.dem", $demoname, $outnum++);
-		open $outfh, ">", $outname
-			or die "open $outname: $!";
-		binmode $outfh;
-		print $outfh $cdtrack;
-		print "Writing to $outname...\n";
-	}
-
-	die "No signon received"
-		unless $outfh;
-	print $outfh pack("V", length $data);
-	print $outfh $angles;
-	print $outfh $data;
-}
-
-close $outfh;
-close $infh;

Deleted: trunk/misc/demotc-race-record-extractor.sh
===================================================================
--- trunk/misc/demotc-race-record-extractor.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/demotc-race-record-extractor.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-d=$1
-i=0
-perl demotc.pl grep "$d" 'all-time fastest lap record with (.*)\n' | while IFS=" " read -r timecode result; do
-	timecode=${timecode%:}
-	result=${result#\"}
-	result=${result%\"}
-
-	echo "Possible record found at $timecode: $result, extracting..."
-
-	minutes=${result%%:*}
-	result=${result#*:}
-	seconds=${result%%.*}
-	result=${result#*.}
-	tenths=$result
-
-	timecode_start=`echo "$timecode - $minutes*60 - $seconds - $tenths*0.1 - 2" | bc -l`
-	timecode_end=`echo "$timecode + 2" | bc -l`
-	i=$(($i + 1))
-	perl demotc.pl cut "$d" "playback-$i.dem" "$timecode_start" "$timecode_end"
-	perl demotc.pl cut "$d" "capture-$i.dem" "$timecode_start" "$timecode_end" --capture
-done

Deleted: trunk/misc/demotc.pl
===================================================================
--- trunk/misc/demotc.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/demotc.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,172 +0,0 @@
-#!/usr/bin/perl
-
-# Fake demo "cutting" tool
-# works by looking for time codes in the demo
-# and injecting playback speed commands
-
-use strict;
-use warnings;
-
-sub sanitize($)
-{
-	my ($str) = @_;
-	$str =~ y/\000-\037//d;
-	return $str;
-}
-
-# opening the files
-
-my ($in, $out, $tc0, $tc1, $pattern, $capture);
-
-my $mode = shift @ARGV;
-$mode = 'help' if not defined $mode;
-
-if($mode eq 'grep' && @ARGV == 2)
-{
-	$in = $ARGV[0];
-	$pattern = $ARGV[1];
-}
-elsif($mode eq 'uncut' && @ARGV == 2)
-{
-	$in = $ARGV[0];
-	$out = $ARGV[1];
-}
-elsif($mode eq 'cut' && (@ARGV == 4 || @ARGV == 5))
-{
-	$in = $ARGV[0];
-	$out = $ARGV[1];
-	$tc0 = $ARGV[2];
-	$tc1 = $ARGV[3];
-	$capture = (@ARGV == 5);
-}
-else
-{
-	die "Usage: $0 cut infile outfile tc_start tc_end [--capture], or $0 uncut infile outfile, or $0 grep infile pattern\n"
-}
-
-if($mode ne 'grep')
-{
-	$in ne $out
-		or die "Input and output file may not be the same!";
-}
-
-open my $infh, "<", $in
-	or die "open $in: $!";
-binmode $infh;
-
-my $outfh;
-if($mode ne 'grep') # cutting
-{
-	open $outfh, ">", $out
-		or die "open $out: $!";
-	binmode $outfh;
-}
-
-# 1. CD track
-
-$/ = "\012";
-my $cdtrack = <$infh>;
-print $outfh $cdtrack if $mode ne 'grep';
-
-# 2. packets
-
-my $tc = undef;
-
-my $first = 1;
-my $demo_started = 0;
-my $demo_stopped = 0;
-my $inject_buffer = "";
-
-for(;;)
-{
-	last
-		unless 4 == read $infh, my $length, 4;
-	$length = unpack("V", $length);
-	die "Invalid demo packet"
-		unless 12 == read $infh, my $angles, 12;
-	die "Invalid demo packet"
-		unless $length == read $infh, my($data), $length;
-	
-	# remove existing cut marks
-	$data =~ s{^\011\n//CUTMARK\n[^\0]*\0}{};
-	
-	if(substr($data, 0, 1) eq "\007") # svc_time
-	{
-		$tc = unpack "f", substr $data, 1, 4;
-	}
-
-	if($mode eq 'cut' && defined $tc)
-	{
-		if($first)
-		{
-			$inject_buffer = "\011\n//CUTMARK\nslowmo 100\n\000";
-			$first = 0;
-		}
-		if($demo_started < 1 && $tc > $tc0 - 50)
-		{
-			$inject_buffer = "\011\n//CUTMARK\nslowmo 10\n\000";
-			$demo_started = 1;
-		}
-		if($demo_started < 2 && $tc > $tc0 - 5)
-		{
-			$inject_buffer = "\011\n//CUTMARK\nslowmo 1\n\000";
-			$demo_started = 2;
-		}
-		if($demo_started < 3 && $tc > $tc0)
-		{
-			if($capture)
-			{
-				$inject_buffer = "\011\n//CUTMARK\ncl_capturevideo 1\n\000";
-			}
-			else
-			{
-				$inject_buffer = "\011\n//CUTMARK\nslowmo 0; defer 1 \"slowmo 1\"\n\000";
-			}
-			$demo_started = 3;
-		}
-		if(!$demo_stopped && $tc > $tc1)
-		{
-			if($capture)
-			{
-				$inject_buffer = "\011\n//CUTMARK\ncl_capturevideo 0; defer 0.5 \"disconnect\"\n\000";
-			}
-			else
-			{
-				$inject_buffer = "\011\n//CUTMARK\ndefer 0.5 \"disconnect\"\n\000";
-			}
-			$demo_stopped = 1;
-		}
-	}
-	elsif($mode eq 'grep')
-	{
-		if(my @l = ($data =~ /$pattern/))
-		{
-			if(defined $tc)
-			{
-				print "$tc:";
-			}
-			else
-			{
-				print "start:";
-			}
-			for(@l)
-			{
-				print " \"", sanitize($_), "\"";
-			}
-			print "\n";
-		}
-	}
-	
-	next if $mode eq 'grep';
-	if(length($inject_buffer . $data) < 65536)
-	{
-		$data = $inject_buffer . $data;
-		$inject_buffer = "";
-	}
-	print $outfh pack("V", length $data);
-	print $outfh $angles;
-	print $outfh $data;
-}
-
-close $outfh if $mode ne 'grep';
-close $infh;

Deleted: trunk/misc/dependencies.pl
===================================================================
--- trunk/misc/dependencies.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/dependencies.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,303 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-my %files = ();
-my %shaders = ();
-
-sub ReadShaders()
-{
-	for my $sf(<scripts/*.shader>)
-	{
-		my $curshader = undef;
-		my @tex = ();
-		my $level = 0;
-		open my $fh, "<", $sf
-			or die "<$sf: $!";
-		while(<$fh>)
-		{
-			s/\r//gs;
-			chomp;
-
-			s/\/\/.*//s;
-			s/^\s+//;
-			s/\s+$//;
-			next if /^$/;
-
-			my @line = map { s/"//g; $_; } split /\s+/, $_;
-
-			if($line[0] eq '{')
-			{
-				++$level;
-			}
-			elsif($line[0] eq '}')
-			{
-				--$level;
-				if($level <= 0)
-				{
-					$level = 0;
-					if(defined $curshader)
-					{
-						$shaders{lc $curshader} = { shaderfile => $sf, textures => [ @tex ] };
-					}
-					$curshader = undef;
-				}
-			}
-			elsif($level == 0)
-			{
-				$curshader = $line[0];
-				@tex = ();
-			}
-			elsif($level == 1 and lc $line[0] eq 'qer_editorimage')
-			{
-				push @tex, $line[1];
-			}
-			elsif($level == 1 and lc $line[0] eq 'qer_lightimage')
-			{
-				push @tex, $line[1];
-			}
-			elsif($level == 1 and lc $line[0] eq 'skyparms')
-			{
-				for(qw/rt lf ft bk up dn/)
-				{
-					push @tex, "$line[1]_$_";
-					push @tex, "$line[3]_$_";
-				}
-			}
-			elsif($level == 2 and lc $line[0] eq 'map')
-			{
-				push @tex, $line[1];
-			}
-			elsif($level == 2 and lc $line[0] eq 'animmap')
-			{
-				for(2..(@line - 1))
-				{
-					push @tex, $line[$_];
-				}
-			}
-		}
-	}
-}
-
-sub AddFile($)
-{
-	my ($file) = @_;
-	return 0
-		unless -e $file;
-	++$files{$file};
-	return 1;
-}
-
-sub AddSound($)
-{
-	my ($tex) = @_;
-	$tex =~ s/\.ogg$|\.wav$//i;
-	AddFile "$tex.ogg" or
-	AddFile "$tex.wav" or
-	AddFile "sound/$tex.ogg" or
-	AddFile "sound/$tex.wav";
-}
-
-sub AddTexture($)
-{
-	my ($tex) = @_;
-	$tex =~ s/\.jpg$|\.tga$|\.png$//i;
-	AddFile "$tex.jpg" or
-	AddFile "$tex.tga" or
-	AddFile "$tex.png"
-		or return 0;
-	for('_shirt', '_pants', '_glow', '_norm', '_bump', '_gloss')
-	{
-		AddFile "$tex$_.jpg" or
-		AddFile "$tex$_.tga" or
-		AddFile "$tex$_.png";
-	}
-	return 1;
-}
-
-sub AddShader($)
-{
-	my ($shader) = @_;
-	$shader =~ s/\.jpg$|\.tga$|\.png$//i;
-	my $si = $shaders{lc $shader};
-	if(not defined $si)
-	{
-		AddTexture $shader
-			or warn "Unknown shader used: $shader";
-	}
-	else
-	{
-		AddFile $si->{shaderfile};
-		AddTexture $_
-			for @{$si->{textures}};
-	}
-}
-
-sub AddMapDependencies($)
-{
-	my ($data) = @_;
-	for(/^"noise.*" "(.*)"/gm)
-	{
-		AddSound $1;
-	}
-	for(/^"sound.*" "(.*)"/gm)
-	{
-		AddSound $1;
-	}
-	for(/^"music" "(.*)"/gm)
-	{
-		AddSound $1;
-	}
-	for(/^"model" "(.*)"/gm)
-	{
-		# TODO make this AddModel
-		# TODO and find the shaders the model uses
-		AddFile $1;
-	}
-	for(/^"lodmodel.*" "(.*)"/gm)
-	{
-		AddFile $1;
-	}
-}
-
-sub AddMapinfoDependencies($)
-{
-	my ($data) = @_;
-	for($data =~ /^cdtrack (.*)$/gm)
-	{
-		AddSound "sound/cdtracks/$1";
-	}
-}
-
-sub AddCfgDependencies($)
-{
-	my ($data) = @_;
-	for($data =~ /^cd loop "?(.*?)"?$/gm)
-	{
-		AddSound "sound/cdtracks/$1";
-	}
-}
-
-sub AddShaderDependencies($)
-{
-	my ($data) = @_;
-
-	my $n = length($data) / 72;
-	for(0..($n-1))
-	{
-		my $s = substr $data, $_ * 72, 64;
-		$s =~ s/\0.*$//s;
-		AddShader $s;
-	}
-}
-
-sub AddFaceDependencies($$)
-{
-	my ($base, $data) = @_;
-
-	my $n = length($data) / 104;
-	for(0..($n-1))
-	{
-		my $l = unpack "V", substr $data, $_ * 104 + 28, 4;
-		AddTexture sprintf "maps/%s/lm_%04d", $base, $l;
-		AddTexture sprintf "maps/%s/lm_%04d", $base, $l | 1; # deluxe
-	}
-}
-
-
-ReadShaders();
-
-for(<maps/*.ent>)
-{
-	AddFile $_;
-
-	my $data = do {
-		undef local $/;
-		open my $fh, "<", $_
-			or die "<$_: $!";
-		<$fh>;
-	};
-	AddMapDependencies $data;
-}
-
-for(<maps/*.bsp>)
-{
-	AddFile $_;
-
-	m!^maps/(.*)\.bsp! or die "perl is stupid";
-	my $b = $1;
-	AddFile "maps/$b.mapinfo";
-	AddFile "maps/$b.jpg";
-	AddFile "maps/$b.cfg";
-	AddFile "maps/$b.waypoints";
-	AddFile "maps/$b.rtlights";
-	AddTexture "gfx/$b\_radar.tga";
-	AddTexture "gfx/$b\_mini.tga";
-
-	my $data = do {
-		undef local $/;
-		open my $fh, "<", "maps/$b.mapinfo"
-			or warn "<maps/$b.mapinfo: $!";
-		<$fh>;
-	};
-	AddMapinfoDependencies $data;
-
-	$data = do {
-		undef local $/;
-		open my $fh, "<", "maps/$b.cfg"
-			or warn "<maps/$b.cfg: $!";
-		<$fh>;
-	};
-	AddCfgDependencies $data;
-
-	$data = do {
-		undef local $/;
-		open my $fh, "-|", 'bsptool.pl', $_, '-xentities'
-			or die "<$_: $!";
-		<$fh>;
-	};
-	AddMapDependencies $data;
-
-	$data = do {
-		undef local $/;
-		open my $fh, "-|", 'bsptool.pl', $_, '-xfaces'
-			or die "<$_: $!";
-		<$fh>;
-	};
-	AddFaceDependencies $b, $data;
-
-	$data = do {
-		undef local $/;
-		open my $fh, "-|", 'bsptool.pl', $_, '-xtextures'
-			or die "<$_: $!";
-		<$fh>;
-	};
-	AddShaderDependencies $data;
-}
-
-sub RecurseDir($);
-sub RecurseDir($)
-{
-	my ($dir) = @_;
-	if(-d $dir)
-	{
-		for(<$dir/*>)
-		{
-			RecurseDir $_;
-		}
-	}
-	else
-	{
-		warn "Unused file: $dir"
-			unless $files{$dir};
-	}
-}
-
-for(<*>)
-{
-	RecurseDir $_;
-}
-
-print "$_\0"
-	for sort keys %files;

Deleted: trunk/misc/entmerge.pl
===================================================================
--- trunk/misc/entmerge.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/entmerge.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,595 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use Carp;
-$SIG{__DIE__} = sub { 
-	Carp::cluck "Exception: $@";
-};
-
-# ent file managing tool
-# usage:
-#
-#   map -> ent:
-#     perl entmerge.pl $scalefactor             < mapname.map > mapname.ent
-#
-#   ent -> map:
-#     perl entmerge.pl $scalefactor mapname.ent < mapname.map > mapname-merged.map
-#
-#   bsp -> ent:
-#     perl bsptool.pl mapname.bsp -xentities                  > mapname.ent
-#                                                          
-#   ent -> bsp:                                            
-#     perl bsptool.pl mapname.bsp -rentities                  < mapname.ent
-
-sub DotProduct($$)
-{
-	my ($a, $b) = @_;
-	return	$a->[0]*$b->[0]
-		+	$a->[1]*$b->[1]
-		+	$a->[2]*$b->[2];
-}
-
-sub CrossProduct($$)
-{
-	my ($a, $b) = @_;
-	return	[
-		$a->[1]*$b->[2] - $a->[2]*$b->[1],
-		$a->[2]*$b->[0] - $a->[0]*$b->[2],
-		$a->[0]*$b->[1] - $a->[1]*$b->[0]
-	];
-}
-
-sub VectorMAM(@)
-{
-	my (@data) = @_;
-	my $out = [0, 0, 0];
-	for my $coord(0..2)
-	{
-		my $c = 0;
-		$c += $data[2*$_ + 0] * $data[2*$_ + 1]->[$coord]
-			for 0..(@data/2 - 1);
-		$out->[$coord] = $c;
-	}
-	return $out;
-}
-
-sub VectorLength2($)
-{
-	my ($v) = @_;
-	return DotProduct $v, $v;
-}
-
-sub VectorLength($)
-{
-	my ($v) = @_;
-	return sqrt VectorLength2 $v;
-}
-
-sub VectorNormalize($)
-{
-	my ($v) = @_;
-	return VectorMAM 1/VectorLength($v), $v;
-}
-
-sub Polygon_QuadForPlane($$)
-{
-	my ($plane, $quadsize) = @_;
-
-	my $quadup;
-	if(abs($plane->[2]) > abs($plane->[0]) && abs($plane->[2]) > abs($plane->[1]))
-	{
-		$quadup = [1, 0, 0];
-	}
-	else
-	{
-		$quadup = [0, 0, 1];
-	}
-
-	$quadup = VectorMAM 1, $quadup, -DotProduct($quadup, $plane), $plane;
-	$quadup = VectorMAM $plane->[3], VectorNormalize $quadup;
-
-	my $quadright = CrossProduct $quadup, $plane;
-
-	return [
-		VectorMAM($plane->[3], $plane, -$quadsize*2, $quadright, +$quadsize*2, $quadup),
-		VectorMAM($plane->[3], $plane, +$quadsize*2, $quadright, +$quadsize*2, $quadup),
-		VectorMAM($plane->[3], $plane, +$quadsize*2, $quadright, -$quadsize*2, $quadup),
-		VectorMAM($plane->[3], $plane, -$quadsize*2, $quadright, -$quadsize*2, $quadup)
-	];
-}
-
-sub Polygon_Clip($$$)
-{
-	my ($points, $plane, $epsilon) = @_;
-
-	if(@$points < 1)
-	{
-		return [];
-	}
-
-	my $n = 0;
-	my $ndist = DotProduct($points->[$n], $plane) - $plane->[3];
-
-	my @outfrontpoints = ();
-
-	for my $i(0..@$points - 1)
-	{
-		my $p = $n;
-		my $pdist = $ndist;
-		$n = ($i+1) % @$points;
-		$ndist = DotProduct($points->[$n], $plane) - $plane->[3];
-		if($pdist >= -$epsilon)
-		{
-			push @outfrontpoints, $points->[$p];
-		}
-		if(($pdist > $epsilon && $ndist < -$epsilon) || ($pdist < -$epsilon && $ndist > $epsilon))
-		{
-			my $frac = $pdist / ($pdist - $ndist);
-			push @outfrontpoints, VectorMAM 1-$frac, $points->[$p], $frac, $points->[$n];
-		}
-	}
-
-	return \@outfrontpoints;
-}
-
-sub MakePlane($$$)
-{
-	my ($p, $q, $r) = @_;
-
-	my $a = VectorMAM 1, $q, -1, $p;
-	my $b = VectorMAM 1, $r, -1, $p;
-	my $n = VectorNormalize CrossProduct $a, $b;
-
-	return [ @$n, DotProduct $n, $p ];
-}
-
-sub GetBrushWindings($)
-{
-	my ($planes) = @_;
-
-	my @windings = ();
-
-	for my $i(0..(@$planes - 1))
-	{
-		my $winding = Polygon_QuadForPlane $planes->[$i], 65536;
-
-		for my $j(0..(@$planes - 1))
-		{
-			next
-				if $i == $j;
-			$winding = Polygon_Clip $winding, $planes->[$j], 1/64.0;
-		}
-
-		push @windings, $winding
-			unless @$winding == 0;
-	}
-
-	return \@windings;
-}
-
-sub GetBrushMinMax($)
-{
-	my ($brush) = @_;
-
-	if($brush->[0] =~ /^\(/)
-	{
-		# plain brush
-		my @planes = ();
-		for(@$brush)
-		{
-			/^\(\s+(\S+)\s+(\S+)\s+(\S+)\s+\)\s+\(\s+(\S+)\s+(\S+)\s+(\S+)\s+\)\s+\(\s+(\S+)\s+(\S+)\s+(\S+)\s+\)\s+/
-				or die "Invalid line in plain brush: $_";
-			push @planes, MakePlane [ $1, $2, $3 ], [ $4, $5, $6 ], [ $7, $8, $9 ];
-			# for any three planes, find their intersection
-			# check if the intersection is inside all other planes
-		}
-		
-		my $windings = GetBrushWindings \@planes;
-
-		my (@mins, @maxs);
-
-		for(@$windings)
-		{
-			for my $v(@$_)
-			{
-				if(@mins)
-				{
-					for(0..2)
-					{
-						$mins[$_] = $v->[$_] if $mins[$_] > $v->[$_];
-						$maxs[$_] = $v->[$_] if $maxs[$_] < $v->[$_];
-					}
-				}
-				else
-				{
-					@mins = @$v;
-					@maxs = @$v;
-				}
-			}
-		}
-
-		return undef
-			unless @mins;
-		return \@mins, \@maxs;
-	}
-
-	die "Cannot decode this brush yet! brush is @$brush";
-}
-
-sub BrushOrigin($)
-{
-	my ($brushes) = @_;
-
-	my @org = ();
-
-	for my $brush(@$brushes)
-	{
-		my $isorigin = 0;
-		for(@$brush)
-		{
-			$isorigin = 1
-				if /\bcommon\/origin\b/;
-		}
-		if($isorigin)
-		{
-			my ($mins, $maxs) = GetBrushMinMax $brush;
-			@org = map { 0.5 * ($mins->[$_] + $maxs->[$_]) } 0..2
-				if defined $mins;
-		}
-	}
-
-	return \@org
-		if @org;
-	return undef;
-}
-
-sub ParseEntity($)
-{
-	my ($fh) = @_;
-
-	my %ent = ( );
-	my @brushes = ( );
-
-	while(<$fh>)
-	{
-		chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
-
-		if(/^\{$/)
-		{
-			# entity starts
-			while(<$fh>)
-			{
-				chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
-
-				if(/^"(.*?)" "(.*)"$/)
-				{
-					# key-value pair
-					$ent{$1} = $2;
-				}
-				elsif(/^\{$/)
-				{
-					my $brush = [];
-					push @brushes, $brush;
-
-					while(<$fh>)
-					{
-						chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
-
-						if(/^\{$/)
-						{
-							# patch?
-							push @$brush, $_;
-
-							while(<$fh>)
-							{
-								chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
-
-								if(/^\}$/)
-								{
-									push @$brush, $_;
-
-									last;
-								}
-								else
-								{
-									push @$brush, $_;
-								}
-							}
-						}
-						elsif(/^\}$/)
-						{
-							# end of brush
-							last;
-						}
-						else
-						{
-							push @$brush, $_;
-						}
-					}
-				}
-				elsif(/^\}$/)
-				{
-					return \%ent, \@brushes;
-				}
-			}
-		}
-		else
-		{
-			die "Unexpected line in top level: >>$_<<";
-		}
-	}
-
-	return undef;
-}
-
-sub UnparseEntity($$)
-{
-	my ($ent, $brushes) = @_;
-	my %ent = %$ent;
-
-	my $s = "{\n";
-
-	for(sort keys %ent)
-	{
-		$s .= "\"$_\" \"$ent{$_}\"\n";
-	}
-
-	if(defined $brushes)
-	{
-		for(@$brushes)
-		{
-			$s .= "{\n";
-			$s .= "$_\n" for @$_;
-			$s .= "}\n";
-		}
-	}
-
-	$s .= "}\n";
-	return $s;
-}
-
-my ($scale, $in_ent) = @ARGV;
-
-$scale = 1
-	if not defined $scale;
-
-my @submodels = ();
-my @entities = ();
-my @entities_skipped = ();
-
-# THIS part is always a .map file
-my $first = 1;
-my $keeplights;
-for(;;)
-{
-	my ($ent, $brushes) = ParseEntity \*STDIN;
-
-	defined $ent
-		or last;
-	
-	if($first && $ent->{classname} eq 'worldspawn')
-	{
-		$keeplights = $ent->{_keeplights};
-		delete $ent->{_keeplights};
-		@submodels = ($brushes);
-	}
-	else
-	{
-		if($first)
-		{
-			push @entities, { classname => "worldspawn" };
-			@submodels = ([]);
-		}
-
-		if($ent->{classname} eq 'worldspawn')
-		{
-			$ent->{classname} = "worldspawn_renamed";
-		}
-
-		if(grep { $_ eq $ent->{classname} } qw/group_info func_group misc_model _decal _skybox/)
-		{
-			push @entities_skipped, [$ent, $brushes];
-			next;
-		}
-
-		if(!$keeplights && $ent->{classname} =~ /^light/)
-		{
-			push @entities_skipped, [$ent, $brushes];
-			next;
-		}
-
-		if(@$brushes)
-		{
-			my $i = @submodels;
-			push @submodels, $brushes;
-			$ent->{model} = sprintf "*%d", $i;
-		}
-	}
-
-	push @entities, $ent;
-
-	$first = 0;
-}
-
-if($first)
-{
-	push @entities, { classname => "worldspawn" };
-	@submodels = ([]);
-}
-
-if(defined $in_ent)
-{
-	# translate map using ent to map
-	open my $fh, "<", $in_ent
-		or die "$in_ent: $!";
-
-	# THIS part is always an .ent file now
-	my @entities_entfile = ();
-	$first = 1;
-	
-	my $clear_all_worldlights;
-
-	for(;;)
-	{
-		my ($ent, $brushes) = ParseEntity $fh;
-
-		defined $ent
-			or last;
-		
-		if($first && $ent->{classname} eq 'worldspawn')
-		{
-		}
-		else
-		{
-			if($first)
-			{
-				push @entities_entfile, { classname => "worldspawn" };
-			}
-
-			if($ent->{classname} eq 'worldspawn')
-			{
-				$ent->{classname} = "worldspawn_renamed";
-			}
-
-			if(!$keeplights && $ent->{classname} =~ /^light/)
-			{
-				# light entity detected!
-				# so let's replace all light entities
-				$clear_all_worldlights = 1;
-			}
-		}
-
-		if(defined $ent->{model} and $ent->{model} =~ /^\*(\d+)$/)
-		{
-			my $entfileorigin = [ split /\s+/, ($ent->{origin} || "0 0 0") ];
-			my $baseorigin = BrushOrigin $submodels[$1];
-
-			if(defined $baseorigin)
-			{
-				my $org = VectorMAM 1, $entfileorigin, -1, $baseorigin;
-				$ent->{origin} = sprintf "%.6f %.6f %.6f", @$org;
-			}
-		}
-
-		push @entities_entfile, $ent;
-		$first = 0;
-	}
-	close $fh;
-
-	if($keeplights && !$entities_entfile[0]->{keeplights})
-	{
-		# PROBLEM:
-		# the .ent file was made without keeplights
-		# merging it with the .map would delete all lights
-		# so insert all light entities here!
-		@entities_skipped = (@entities_skipped,
-			map
-			{
-				my $submodel = undef;
-				if(defined $_->{model} and $_->{model} =~ /^\*(\d+)$/)
-				{
-					$submodel = $submodels[$1];
-				}
-				[ $_, $submodel ]
-			}
-			grep
-			{
-				$_->{classname} =~ /^light/
-			}
-			@entities
-		);
-	}
-
-	if($clear_all_worldlights)
-	{
-		# PROBLEM:
-		# the .ent file was made with keeplights
-		# the .map did not indicate so!
-		# so we must delete all lights from the skipped entity list
-		@entities_skipped = grep { $_->[0]->{classname} !~ /^light/ } @entities_skipped;
-	}
-
-	if($first)
-	{
-		push @entities_entfile, { classname => "worldspawn" };
-	}
-
-	$first = 1;
-	for(@entities_entfile)
-	{
-		my %e = %$_;
-		my $submodel = undef;
-
-		$e{gridsize} = "64 64 128" if not exists $e{gridsize} and $first;
-		$e{lip} /= $scale if exists $e{lip};
-		$e{origin} = sprintf '%.6f %.6f %.6f', map { $_ / $scale } split /\s+/, $e{origin} if exists $e{origin};
-		$e{gridsize} = sprintf '%.6f %.6f %.6f', map { $_ / $scale } split /\s+/, $e{gridsize} if exists $e{gridsize} and $first;
-
-		if($first)
-		{
-			$submodel = $submodels[0];
-			if($keeplights)
-			{
-				$e{_keeplights} = 1;
-			}
-			else
-			{
-				delete $e{_keeplights};
-			}
-		}
-		elsif(defined $e{model} and $e{model} =~ /^\*(\d+)$/)
-		{
-			$submodel = $submodels[$1];
-			delete $e{model};
-		}
-		print UnparseEntity \%e, $submodel;
-		$first = 0;
-	}
-	for(@entities_skipped)
-	{
-		print UnparseEntity $_->[0], $_->[1];
-		$first = 0;
-	}
-}
-else
-{
-	# translate map to ent
-	$first = 1;
-	for(@entities)
-	{
-		my %e = %$_;
-
-		if($first)
-		{
-			if($keeplights)
-			{
-				$e{_keeplights} = 1;
-			}
-			else
-			{
-				delete $e{_keeplights};
-			}
-		}
-
-		if(defined $e{model} and $e{model} =~ /^\*(\d+)$/)
-		{
-			my $oldorigin = [ split /\s+/, ($e{origin} || "0 0 0") ];
-			my $org = BrushOrigin $submodels[$1];
-
-			if(defined $org)
-			{
-				$org = VectorMAM 1, $org, 1, $oldorigin;
-				$e{origin} = sprintf "%.6f %.6f %.6f", @$org;
-			}
-		}
-
-		$e{gridsize} = "64 64 128" if not exists $e{gridsize} and $first;
-		$e{lip} *= $scale if exists $e{lip};
-		$e{origin} = sprintf '%.6f %.6f %.6f', map { $_ * $scale } split /\s+/, $e{origin} if exists $e{origin};
-		$e{gridsize} = sprintf '%.6f %.6f %.6f', map { $_ * $scale } split /\s+/, $e{gridsize} if exists $e{gridsize} and $first;
-
-		print UnparseEntity \%e, undef;
-		$first = 0;
-	}
-}

Deleted: trunk/misc/fiximage.pl
===================================================================
--- trunk/misc/fiximage.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/fiximage.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,105 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-# Usage:
-#   convert image.tga -depth 8 RGBA:- | perl fiximage.pl 72 | convert -depth 8 -size 72x56 RGBA:- output.tga
-
-my ($width) = @ARGV;
-
-my @pixels = ();
-
-for(;;)
-{
-	read STDIN, my $data, 4
-		or last;
-	my ($r, $g, $b, $a) = unpack "CCCC", $data;
-	push @pixels, [$r, $g, $b, $a];
-}
-
-my $height = @pixels / $width;
-my @fixlater;
-for my $y(0..($height-1))
-{
-	for my $x(0..($width-1))
-	{
-		next
-			if $pixels[$x + $y * $width][3] != 0;
-		# alpha is zero? Replace by weighted average.
-		my ($r, $g, $b, $a) = (0, 0, 0);
-		for my $dy(-1..1)
-		{
-			next if $y + $dy < 0;
-			next if $y + $dy >= $height;
-			for my $dx(-1..1)
-			{
-				next if $x + $dx < 0;
-				next if $x + $dx >= $width;
-				my $pix = $pixels[($x + $dx) + ($y + $dy) * $width];
-				$r += $pix->[0] * $pix->[3];
-				$g += $pix->[1] * $pix->[3];
-				$b += $pix->[2] * $pix->[3];
-				$a += $pix->[3];
-			}
-		}
-		if($a == 0)
-		{
-			push @fixlater, [$x, $y];
-			$pixels[$x + $y * $width] = [0, 0, 0, 0, undef];
-			next;
-		}
-		$r = int ($r / $a);
-		$g = int ($g / $a);
-		$b = int ($b / $a);
-		print STDERR "Fixing ($x, $y -> $r, $g, $b, $a)\n";
-		$pixels[$x + $y * $width] = [$r, $g, $b, 0];
-	}
-}
-
-while(@fixlater)
-{
-	print STDERR "Pixels left: ", scalar(@fixlater), "\n";
-
-	# These pixels have no neighbors with a non-zero alpha.
-	my @fixels = @fixlater;
-	@fixlater = ();
-	my @pixelsorig = @pixels;
-	for(@fixels)
-	{
-		my ($x, $y) = @$_;
-		my ($r, $g, $b, $a) = (0, 0, 0, 0);
-		for my $dy(-1..1)
-		{
-			next if $y + $dy < 0;
-			next if $y + $dy >= $height;
-			for my $dx(-1..1)
-			{
-				next if $x + $dx < 0;
-				next if $x + $dx >= $width;
-				my $pix = $pixelsorig[($x + $dx) + ($y + $dy) * $width];
-				next
-					if @$pix == 5;
-				$r += $pix->[0];
-				$g += $pix->[1];
-				$b += $pix->[2];
-				$a += 1;
-			}
-		}
-		if($a == 0)
-		{
-			push @fixlater, [$x, $y];
-			next;
-		}
-		$r = int ($r / $a);
-		$g = int ($g / $a);
-		$b = int ($b / $a);
-		#print STDERR "Fixing later ($x, $y -> $r, $g, $b, $a)\n";
-		$pixels[$x + $y * $width] = [$r, $g, $b, 0];
-	}
-}
-
-for(@pixels)
-{
-	print pack "CCCC", @$_;
-}

Deleted: trunk/misc/hslimage.c
===================================================================
--- trunk/misc/hslimage.c	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/hslimage.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,104 +0,0 @@
-#include <math.h>
-#include <stdio.h>
-
-#define MARGIN_X 0
-#define MARGIN_Y 0
-
-void hsl_to_rgb(float hsl_x, float hsl_y, float hsl_z, float *rgb_x, float *rgb_y, float *rgb_z)
-{
-	float mi, ma, maminusmi, h;
-
-	if(hsl_z <= 0.5)
-		maminusmi = hsl_y * 2 * hsl_z;
-	else
-		maminusmi = hsl_y * (2 - 2 * hsl_z);
-	
-	// hsl_z     = 0.5 * mi + 0.5 * ma
-	// maminusmi =     - mi +       ma
-	mi = hsl_z - 0.5 * maminusmi;
-	ma = hsl_z + 0.5 * maminusmi;
-
-	h = hsl_x - 6 * floor(hsl_x / 6);
-
-	//else if(ma == rgb_x)
-	//	h = 60 * (rgb_y - rgb_z) / (ma - mi);
-	if(h <= 1)
-	{
-		*rgb_x = ma;
-		*rgb_y = h * (ma - mi) + mi;
-		*rgb_z = mi;
-	}
-	//else if(ma == rgb_y)
-	//	h = 60 * (rgb_z - rgb_x) / (ma - mi) + 120;
-	else if(h <= 2)
-	{
-		*rgb_x = (2 - h) * (ma - mi) + mi;
-		*rgb_y = ma;
-		*rgb_z = mi;
-	}
-	else if(h <= 3)
-	{
-		*rgb_x = mi;
-		*rgb_y = ma;
-		*rgb_z = (h - 2) * (ma - mi) + mi;
-	}
-	//else // if(ma == rgb_z)
-	//	h = 60 * (rgb_x - rgb_y) / (ma - mi) + 240;
-	else if(h <= 4)
-	{
-		*rgb_x = mi;
-		*rgb_y = (4 - h) * (ma - mi) + mi;
-		*rgb_z = ma;
-	}
-	else if(h <= 5)
-	{
-		*rgb_x = (h - 4) * (ma - mi) + mi;
-		*rgb_y = mi;
-		*rgb_z = ma;
-	}
-	//else if(ma == rgb_x)
-	//	h = 60 * (rgb_y - rgb_z) / (ma - mi);
-	else // if(h <= 6)
-	{
-		*rgb_x = ma;
-		*rgb_y = mi;
-		*rgb_z = (6 - h) * (ma - mi) + mi;
-	}
-}
-
-void hslimage_color(float v_x, float v_y, float margin_x, float margin_y, float *rgb_x, float *rgb_y, float *rgb_z)
-{
-	v_x = (v_x - margin_x) / (1 - 2 * margin_x);
-	v_y = (v_y - margin_y) / (1 - 2 * margin_y);
-	if(v_x < 0) v_x = 0;
-	if(v_y < 0) v_y = 0;
-	if(v_x > 1) v_x = 1;
-	if(v_y > 1) v_y = 1;
-	if(v_y > 0.875) // grey bar
-		hsl_to_rgb(0, 0, v_x, rgb_x, rgb_y, rgb_z);
-	else
-		hsl_to_rgb(v_x * 6, 1, (v_y / 0.875), rgb_x, rgb_y, rgb_z);
-}
-
-int main()
-{
-	int x, y;
-	float r, g, b;
-
-	for(y = 0; y < 512; ++y)
-	{
-		for(x = 0; x < 512; ++x)
-		{
-			hslimage_color(x / 512.0, y / 512.0, MARGIN_X, MARGIN_Y, &r, &g, &b);
-			/*
-			putc(floor(r * 15 + 0.5) * 17, stdout);
-			putc(floor(g * 15 + 0.5) * 17, stdout);
-			putc(floor(b * 15 + 0.5) * 17, stdout);
-			*/
-			putc(floor(r * 255 + 0.5), stdout);
-			putc(floor(g * 255 + 0.5), stdout);
-			putc(floor(b * 255 + 0.5), stdout);
-		}
-	}
-	return 0;
-}

Deleted: trunk/misc/jpeg-if-not-alpha.sh
===================================================================
--- trunk/misc/jpeg-if-not-alpha.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/jpeg-if-not-alpha.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-set -e
-
-: ${qual:=95}
-
-for X in "$@"; do
-	case "$X" in
-		*.jpg)
-			if [ -n "$scaledown" ]; then
-				mogrify -geometry "$scaledown>" -quality 100 "$X"
-			fi
-			jpegoptim --strip-all -m$qual "$X"
-			;;
-		*.png|*.tga)
-			if [ -n "$scaledown" ]; then
-				mogrify -geometry "$scaledown>" -quality 100 "$X"
-			fi
-			if convert "$X" -depth 16 RGBA:- | perl -e 'while(read STDIN, $_, 8) { substr($_, 6, 2) eq "\xFF\xFF" or exit 1; ++$pix; } exit not $pix;'; then
-				echo "$X has no alpha, converting"
-				convert "$X" -quality 100 "${X%.*}.jpg"
-				jpegoptim --strip-all -m$qual "${X%.*}.jpg"
-				rm -f "$X"
-			else
-				echo "$X has alpha, not converting"
-			fi
-			;;
-	esac
-done

Deleted: trunk/misc/makebuild.sh
===================================================================
--- trunk/misc/makebuild.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/makebuild.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,377 +0,0 @@
-#!/bin/bash
-
-set -e
-
-# Options:
-#   pw=foo          extract password
-#   version=2.5     make a FINAL build
-#   tag=FOO         insert FOO before the date in build names
-
-base=`pwd`
-
-# customizable specific stuff
-basepk3=$base/data20080229.pk3 # 2.4
-hotbasepk3= # hotfix
-nexdir=$base/nexuiz
-havocdir=$base/nexuiz/havoc
-dpdir=$base/darkplaces
-tmpdir=/tmp/NEX
-zipdir=$base/builds
-buildfiles=$base/nexuiz/misc/buildfiles
-mingwdlls=$buildfiles/w32
-osxapps=$buildfiles/osx
-copystrip=$buildfiles/copystrip
-zipdiff=$base/nexuiz/misc/zipdiff
-fteqccdir="$base/fteqcc"
-fteqccflags=""
-menuqc=menu
-newest=NEWEST
-aft="perl -I/chroot/debian-etch/usr/share/aft /chroot/debian-etch/usr/bin/aft"
-# end system specific stuff
-
-case "$pw" in
-	'')
-		zipflags=
-		;;
-	*)
-		zipflags="-P $pw"
-		;;
-esac
-
-: ${date:=`date +%Y%m%d`}
-: ${versiontag:=}
-echo "date stamp: $date"
-
-case "$version" in
-	'')
-		version=2-svntest-$date
-		versiontag=test
-		defaultcfg=
-		ext=
-		;;
-	*)
-		version=$version
-		versiontag=$versiontag
-		defaultcfg=
-		ext=_$version
-		;;
-esac
-
-mk7z()
-{
-	7za a -tzip -mx=9 "$@"
-	chmod 644 "$1"
-}
-
-#if [ -n "$EXPERIMENTAL" ]; then
-#	basepk3=$base/data20071231.pk3 # newer build to make smaller patches
-#	nexdir=$base/nexuiz
-#fi
-
-# TODO normalize the builds
-platforms='x86 amd64 osx'
-buildon()
-{
-	host=$1
-	prefix=$2
-	fteqccname=$3
-	path=$4
-	makeflags=$5
-	strip=$6
-
-	fteqcc_cflags=
-	case "$fteqccname" in
-		*.exe)
-			fteqcc_cflags=win
-			;;
-	esac
-
-	rm -f "$fteqccdir"/*.o
-	rm -f "$fteqccdir"/*.bin
-	rsync --exclude "*.o" --exclude "*.d" --exclude "nexuiz-*" --delete-excluded --delete -zvaSHP . "$copystrip" "$fteqccdir" "$host:$path"
-	ssh "$host" ". ~/.profile && cd $path && COPYSTRIP_STRIP=$strip PATH=$path/copystrip:\$PATH make $makeflags clean nexuiz && cd ${fteqccdir##*/} && make $makeflags $fteqcc_cflags"
-	rsync --exclude "*.o" --exclude "*.d" --delete-excluded --delete -zvaSHP "$host:$path/." .
-	for P in -dedicated -sdl -glx -wgl -agl -dedicated.exe -sdl.exe .exe; do
-		[ -f nexuiz$P ] && mv nexuiz$P "$tmpdir/$prefix$P"
-		[ -f nexuiz$P-withdebug ] && mv nexuiz$P-withdebug "$tmpdir/debuginfo/$prefix$P"
-	done
-	case "$fteqccname" in
-		*.exe)
-			mv "${fteqccdir##*/}"/fteqcc.exe "$tmpdir/fteqcc/$fteqccname"
-			;;
-		*)
-			mv "${fteqccdir##*/}"/fteqcc.bin "$tmpdir/fteqcc/$fteqccname"
-			;;
-	esac
-	make clean
-}
-
-build()
-{
-	buildon nexmacbuild                           nexuiz-osx          fteqcc-osx          /tmp/Darkplaces.build 'CC="gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"' strip
-	buildon eos.thruhere.net                      nexuiz-linux-686    fteqcc-linux-686    /tmp/Darkplaces.build 'CC="gcc -g" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-i386/lib' strip
-	buildon alientrap.org                         nexuiz-linux-x86_64 fteqcc-linux-x86_64 /tmp/Darkplaces.build 'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-x86_64/lib' strip
-	buildon alientrap.org                         nexuiz              fteqcc.exe          /tmp/Darkplaces.build 'DP_MAKE_TARGET=mingw CC="/chroot/debian-etch/usr/bin/i586-mingw32msvc-gcc -g -DSUPPORTDIRECTX -I/home/divverent/dxheaders" WINDRES=/chroot/debian-etch/usr/bin/i586-mingw32msvc-windres SDL_CONFIG=/home/divverent/sdl-win32/SDL-1.2.13/bin/sdl-config' /chroot/debian-etch/usr/bin/i586-mingw32msvc-strip
-		mv "$tmpdir/nexuiz-osx-agl"     "$tmpdir/Nexuiz.app/Contents/MacOS/nexuiz-osx-agl-bin"
-		mv "$tmpdir/nexuiz-osx-sdl"     "$tmpdir/Nexuiz-SDL.app/Contents/MacOS/nexuiz-osx-sdl-bin"
-}
-
-# avoid dupes
-i=
-while [ -f "$zipdir/nexuiz$date$i$ext.zip" ]; do
-	if [ -z "$i" ]; then
-		i=a
-	else
-		i=`echo "$i" | tr a-y b-z`
-	fi
-done
-ext=$i$ext
-
-echo "Using build name nexuiz$date$ext"
-sleep 3
-
-# check for remains
-conflicts=`find "$dpdir" "$nexdir" -name '*.orig' -o -name '*.rej' -o -name '*.mine' -o -name '.#*' -o -name '.*~'`
-if [ -n "$conflicts" ]; then
-	echo "CONFLICTS OR UNNEEDED FILES HAVE BEEN FOUND!"
-	echo "NOT PROCEEDING"
-	echo
-	echo "$conflicts"
-	exit 1
-fi
-
-set -x
-
-# prepare temp dir
-rm -rf "$tmpdir"
-mkdir -p "$tmpdir"
-
-# clean up and patch DP
-cd "$dpdir"
-quilt pop -a || true
-svn revert -R .
-if [ -s patches/series ]; then
-	quilt push -a # apply all patches
-fi
-
-# prepare directory structure
-cp -r "$osxapps"/*.app "$tmpdir"
-mkdir "$tmpdir/debuginfo"
-mkdir "$tmpdir/fteqcc"
-
-# prepare fteqcc build
-svn export "$fteqccdir" "$tmpdir/fteqcc/source"
-svn info "$fteqccdir" > "$tmpdir/fteqcc/source/fteqcc-base-revision.txt"
-fteqccrev=$((`grep "Last Changed Rev:" "$tmpdir/fteqcc/source/fteqcc-base-revision.txt" | cut -d : -f 2`))
-echo "fteqcc rev $fteqccrev"
-
-# build all executables
-rm -f *.exe nexuiz-* *-withdebug* *.o
-make clean
-build
-rm -f *.exe nexuiz-* *-withdebug '.#'* *.o
-rm -rf fteqcc copystrip
-make clean
-
-# move shell scripts and license
-cd "$tmpdir"
-cp "$nexdir/"nexuiz-*.sh "$tmpdir/"
-cp "$nexdir/gpl.txt" "$tmpdir/"
-
-# prepare data
-cd "$nexdir/data"
-svn export . "$tmpdir/data"
-svn info . > "$tmpdir/data/nexuiz-data-base-revision.txt"
-svn log > "$tmpdir/data/ChangeLog"
-
-# prepare havoc
-cd "$havocdir"
-svn export . "$tmpdir/havoc"
-
-# prepare Docs
-cd "$nexdir/Docs"
-svn export . "$tmpdir/Docs"
-
-# prepare server
-cd "$nexdir/server"
-svn export . "$tmpdir/server"
-
-# make gamesource
-cd "$tmpdir/data"
-mkdir -p "$tmpdir/sources"
-mk7z ../sources/gamesource$date.zip qcsrc nexuiz-data-base-revision.txt ChangeLog
-
-# make enginesource
-cd "$dpdir"
-svn export . "$tmpdir/darkplaces"
-svn info > "$tmpdir/darkplaces/nexuiz-base-revision.txt"
-svn diff > "$tmpdir/darkplaces/nexuiz-engine-changes.diff"
-svn log > "$tmpdir/darkplaces/ChangeLog"
-cd "$tmpdir"
-mk7z "$tmpdir/sources/enginesource$date.zip" "darkplaces"
-rm -rf darkplaces
-
-# make fteqcc archive
-cd "$tmpdir"
-zip -9r "$tmpdir/sources/fteqcc-binaries-and-source-rev$fteqccrev.zip" "fteqcc"
-rm -rf fteqcc
-
-# clean fteqcc dir
-cd "$fteqccdir"
-rm -f *.o *.bin
-make
-
-# make local compiler
-cd "$tmpdir/data"
-make FTEQCC="$fteqccdir/fteqcc.bin"
-
-# prepare root
-rm -rf "$tmpdir/data/qcsrc"
-cd "$tmpdir/Docs"
-perl -pi -e '/^#---SET nexversion=([0-9.]*)$/ and $_ = "#---SET nexversion='$version'\n"' FAQ.aft
-perl -pi -e '/^\s*Version ([0-9.]*)<\/div>$/ and $_ = "Version '$version'</div>\n"' Readme.htm
-cp "$dpdir/darkplaces.txt" .
-$aft FAQ.aft
-$aft FAQ.aft
-rm FAQ.aft-TOC
-cd "$tmpdir/data"
-mv common-spog.pk3 ..
-perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version'\n"' default.cfg
-if [ -n "$versiontag" ]; then
-	perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
-	cp "$buildfiles/brand/$versiontag.tga" gfx/brand.tga
-fi
-echo >> default.cfg
-echo "$defaultcfg" >> default.cfg
-mk7z ../data.pk3 .
-cd "$tmpdir/havoc"
-perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version-havoc'\n"' default.cfg
-if [ -n "$versiontag" ]; then
-	perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
-fi
-echo >> default.cfg
-echo "$defaultcfg" >> default.cfg
-mk7z ../havoc.pk3 .
-
-# make data pk3
-cd "$tmpdir"
-rm -rf data
-mkdir data
-mv data.pk3 data/data$tag$date.pk3
-mv common-spog.pk3 data/
-rm -rf havoc
-mkdir havoc
-mv havoc.pk3 havoc/data$tag${date}havoc.pk3
-
-cp -r "$mingwdlls"/* .
-# fix up permissions
-chmod 644 *.dll *.exe
-
-# make main structure
-mkdir Nexuiz
-mv * Nexuiz/ || true
-
-find . -name .svn -exec rm -rf {} \; -prune
-
-rm -f "$zipdir/nexuiz$date$ext.zip"
-zip $zipflags -9yr "$zipdir/nexuiz$date$ext.zip"           Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/data$tag$date.pk3 Nexuiz/data/common-spog.pk3 Nexuiz/havoc/*
-ln -snf nexuiz$date$ext.zip "$zipdir/nexuiz-$newest.zip"
-
-rm -f "$zipdir/nexuizengineonly$date$ext.zip"
-zip $zipflags -9yr "$zipdir/nexuizengineonly$date$ext.zip" Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll
-ln -snf nexuizengineonly$date$ext.zip "$zipdir/nexuizengineonly-$newest.zip"
-
-rm -f "$zipdir/nexuizsource$date$ext.zip"
-zip $zipflags -9yr "$zipdir/nexuizsource$date$ext.zip"     Nexuiz/gpl.txt                                            Nexuiz/sources
-ln -snf nexuizsource$date$ext.zip "$zipdir/nexuizsource-$newest.zip"
-
-# TODO remove these excludes after the version after 2.4.2
-$zipdiff -o "Nexuiz/data/datapatch$tag$date.pk3" -f "$basepk3" -t Nexuiz/data/data$tag$date.pk3 \
-	-x 'sound/cdtracks/track*.ogg' \
-	-x 'sound/cdtracks/brainsukker.ogg' \
-	-x 'sound/cdtracks/breakdown-easy.ogg' \
-	-x 'sound/cdtracks/calling-bogus.ogg' \
-	-x 'sound/cdtracks/chaos-fog.ogg' \
-	-x 'sound/cdtracks/digital-pursuit.ogg' \
-	-x 'sound/cdtracks/infight.ogg' \
-	-x 'sound/cdtracks/neuronal-diving.ogg' \
-	-x 'sound/cdtracks/subcities.ogg' \
-	-x 'sound/cdtracks/thru-the-mirror.ogg'
-mkdir -p sound/cdtracks
-ln -snf track001.ogg sound/cdtracks/digital-pursuit.ogg
-ln -snf track002.ogg sound/cdtracks/breakdown-easy.ogg
-ln -snf track003.ogg sound/cdtracks/brainsukker.ogg
-ln -snf track004.ogg sound/cdtracks/chaos-fog.ogg
-ln -snf track005.ogg sound/cdtracks/infight.ogg
-ln -snf track006.ogg sound/cdtracks/neuronal-diving.ogg
-ln -snf track007.ogg sound/cdtracks/subcities.ogg
-ln -snf track008.ogg sound/cdtracks/thru-the-mirror.ogg
-ln -snf track009.ogg sound/cdtracks/calling-bogus.ogg
-zip -9yr "Nexuiz/data/datapatch$tag$date.pk3" sound/cdtracks/*
-rm -rf sound
-[ -n "$hotbasepk3" ] && $zipdiff -o "Nexuiz/data/datapatch$tag$date""hotfix.pk3" -f "$hotbasepk3" -t Nexuiz/data/data$tag$date.pk3
-mkdir -p gfx
-if unzip "Nexuiz/data/data$tag$date.pk3" gfx/brand.tga; then
-	zip -9r "Nexuiz/data/datapatch$tag$date.pk3" gfx/brand.tga
-	[ -n "$hotbasepk3" ] && zip -9r "Nexuiz/data/datapatch$tag$date""hotfix.pk3" gfx/brand.tga
-	rm -rf gfx
-fi
-
-rm -f "$zipdir/nexuizpatch$date$ext.zip"
-zip $zipflags -9yr "$zipdir/nexuizpatch$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/datapatch$tag$date.pk3 Nexuiz/havoc/*
-ln -snf nexuizpatch$date$ext.zip "$zipdir/nexuizpatch-$newest.zip"
-
-[ -n "$hotbasepk3" ] && rm -f "$zipdir/nexuizhotfix$date$ext.zip"
-[ -n "$hotbasepk3" ] && zip $zipflags -9yr "$zipdir/nexuizhotfix$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/datapatch$tag$date""hotfix.pk3 Nexuiz/havoc/*
-[ -n "$hotbasepk3" ] && ln -snf nexuizhotfix$date$ext.zip "$zipdir/nexuizhotfix-$newest.zip"
-
-rm -f "$zipdir/nexuizdocs$date$ext.zip"
-zip $zipflags -9yr "$zipdir/nexuizdocs$date$ext.zip"       Nexuiz/gpl.txt Nexuiz/Docs
-ln -snf nexuizdocs$date$ext.zip "$zipdir/nexuizdocs-$newest.zip"
-
-rm -f "$zipdir/nexuizdebug$date$ext.zip"
-zip $zipflags -9yr "$zipdir/nexuizdebug$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/debuginfo/* Nexuiz/sources
-ln -snf nexuizdebug$date$ext.zip "$zipdir/nexuizdebug-$newest.zip"
-
-case "$versiontag" in
-	test)
-		;;
-	*)
-		cat <<'EOF'
-
-NOTE: This is a RELEASE BUILD.
-
-To upload and finish the build, these things have to be done:
-
-- Test the build:
-  - On Linux/ATI
-  - On Vista/nvidia
-  - On Vista/ATI
-  - On Vista/Intel
-  - On OSX/ATI
-  - Turn on "developer 1"; watch out for suspicious messages.
-  - While testing, make sure all campaign levels are tested. In CTF/KH levels,
-    try to do a capture. After that, finish the game by prvm_edictset server 1
-    frags 1000.
-  - Play on a server running the new code. Ideally, that server should be public
-    and "somewhat compatible" to old clients, and some other players should be
-    on it.
-- Post the build on the forum as a test release. E.g. run this script again
-  with the "version" variable NOT SET, so the build gets marked "testing only",
-  and upload it and post it on the forum for testing. Mention the test server
-  that is already running the new code. Wait for at least one week for critical
-  bug reports.
-- If needed, fix the reported bugs and re-run this script for a release build.
-  Possibly repeat the testing process.
-- Upload the "final" build you have just made to Sourceforge (upload.sf.net,
-  incoming). Use the naming scheme nexuiz-25.zip, nexuizpatch-24-to-25.zip
-- Make the download available on sourceforge.
-- Announce the build on the forum; update the downloads website. Note that the
-  download may be still unavailable because of the SF mirror system.
-- Wait for the mirrors to catch up.
-- Edit the website: make a new news item for the new release, change the logo
-  image in the top left for the new version (ask [-z-]).
-
-EOF
-		;;
-esac

Copied: trunk/misc/mediasource/graphics/sb-flag-carrying.svg (from rev 5536, trunk/misc/sb-flag-carrying.svg)
===================================================================
--- trunk/misc/mediasource/graphics/sb-flag-carrying.svg	                        (rev 0)
+++ trunk/misc/mediasource/graphics/sb-flag-carrying.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.44"
+   width="503"
+   height="470"
+   version="1.0"
+   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
+   sodipodi:docname="flag-carrying.svg"
+   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-carrying-blue.png"
+   inkscape:export-xdpi="19.617588"
+   inkscape:export-ydpi="19.617588">
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs5">
+    <linearGradient
+       id="linearGradient3763">
+      <stop
+         style="stop-color:red;stop-opacity:1;"
+         offset="0"
+         id="stop3765" />
+      <stop
+         id="stop3775"
+         offset="0.33000001"
+         style="stop-color:yellow;stop-opacity:1;" />
+      <stop
+         style="stop-color:red;stop-opacity:1;"
+         offset="0.66000003"
+         id="stop3777" />
+      <stop
+         style="stop-color:yellow;stop-opacity:1;"
+         offset="1"
+         id="stop3767" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient2801">
+      <stop
+         style="stop-color:white;stop-opacity:1;"
+         offset="0"
+         id="stop2803" />
+      <stop
+         id="stop2809"
+         offset="0.94999999"
+         style="stop-color:white;stop-opacity:1;" />
+      <stop
+         style="stop-color:white;stop-opacity:0;"
+         offset="1"
+         id="stop2805" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient2844"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.539066,0,0,1.902367,2.172742,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient3780"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.376665,0,0,1.902367,2.162274,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient3788"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient3793"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <mask
+       maskUnits="userSpaceOnUse"
+       id="mask3790">
+      <rect
+         transform="matrix(0,1,-1,0,0,0)"
+         style="opacity:1;fill:url(#linearGradient3793);fill-opacity:1;stroke:none;stroke-width:7.87110186;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+         id="rect1878"
+         width="225.11722"
+         height="511.84491"
+         x="2.137996"
+         y="-511.84491" />
+    </mask>
+  </defs>
+  <sodipodi:namedview
+     inkscape:window-height="645"
+     inkscape:window-width="1019"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     showgrid="true"
+     gridspacingx="2.5mm"
+     gridspacingy="2.5mm"
+     grid_units="mm"
+     inkscape:grid-points="false"
+     showguides="true"
+     inkscape:guide-bbox="true"
+     inkscape:grid-bbox="true"
+     inkscape:zoom="0.83829788"
+     inkscape:cx="287.59931"
+     inkscape:cy="273.85808"
+     inkscape:window-x="232"
+     inkscape:window-y="222"
+     inkscape:current-layer="svg2" />
+  <g
+     id="g1880"
+     clip-path="none"
+     mask="url(#mask3790)">
+    <g
+       inkscape:export-ydpi="9.7539482"
+       inkscape:export-xdpi="9.7539482"
+       transform="matrix(0.934555,0,0,0.934555,55.17645,61.98067)"
+       style="opacity:0.3"
+       id="g3727"
+       clip-path="none">
+      <path
+         sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc"
+         id="path3723"
+         d="M 77.936648,416.64918 C 66.929291,403.69748 47.183112,391.08021 47.468568,373.29631 C 61.580167,359.55032 81.18305,352.59514 97.68777,341.87372 C 110.74595,338.06729 118.44307,325.60734 131.14032,321.25949 C 135.23774,323.22955 138.01636,322.87548 140.0172,321.10616 C 145.99641,315.81884 145.02996,297.89311 151.55592,291.58386 C 160.41708,277.70343 159.66836,263.16374 151.9131,249.96044 C 155.45664,243.72563 166.71663,233.58495 153.20463,230.91525 C 150.00252,215.17855 175.41335,202.075 175.86122,197.3583 C 176.33392,192.38001 161.41329,172.43211 164.3281,159.50104 C 176.9793,149.65115 169.78762,127.26772 185.31798,119.25569 C 192.29054,113.20477 210.4602,112.16805 212.11472,108.77965 C 201.12352,97.080172 196.85491,76.451388 208.74212,64.292723 C 224.70534,54.897624 253.66981,63.271708 249.38462,85.387324 C 246.46527,97.938613 255.64422,119.85276 235.95305,120.95585 C 230.47567,135.53763 249.4295,147.25179 253.87515,160.6006 C 265.05211,172.03304 281.81019,176.78954 296.25889,178.5893 C 310.67702,185.99278 288.95145,207.16258 276.86491,208.87501 C 266.07803,212.64746 260.99023,200.43911 248.56706,199.24357 C 238.83475,180.87439 228.23756,204.15442 225.12821,214.88295 C 213.65178,221.44238 218.19122,227.13612 229.18395,228.95525 C 245.80155,238.06299 267.29134,240.22536 282.438,253.76183 C 299.52394,258.59567 310.08927,275.78366 295.39762,289.93827 C 298.94588,304.03742 292.54903,321.6244 289.93715,337.16017 C 278.51909,356.2747 292.73993,376.18783 309.33405,385.30202 C 313.65263,407.67285 287.14409,394.36219 275.71731,391.48441 C 260.84112,389.40428 250.51246,374.97195 260.19241,361.87832 C 261.27126,344.49092 263.85189,326.74433 259.40604,309.69521 C 257.08074,299.89268 265.30058,279.83135 249.8705,289.28304 C 236.68476,288.01966 223.42917,279.26247 210.09004,284.32363 C 197.57182,299.06507 191.69147,317.89165 180.59757,333.39344 C 175.89821,346.24998 171.80041,359.44265 155.36011,356.73483 C 136.17465,361.97053 118.11284,370.88329 98.07399,372.33299 C 72.235605,375.57602 96.62115,400.99427 88.93957,414.97797 C 86.16289,418.03926 81.55,417.41052 77.936648,416.64918 z "
+         style="fill:red;fill-opacity:1;stroke:black;stroke-width:5.35013991;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <path
+         sodipodi:nodetypes="ccsccscc"
+         id="path3725"
+         d="M 279.0423,191.87383 L 330.33071,-14.440493 C 304.24885,-21.480848 277.5851,-19.962497 250.79521,-25.067388 C 225.00536,-31.478574 192.76761,-48.637795 192.76761,-48.637795 L 175.66896,20.143756 C 175.66896,20.143756 207.91424,37.272644 233.7041,43.683836 C 259.49396,50.095029 296.03668,50.066395 296.03668,50.066395 L 261.84691,187.59917"
+         style="fill:blue;fill-opacity:1;stroke:black;stroke-width:5.35013991;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;opacity:1" />
+    </g>
+    <use
+       style="opacity:0.7"
+       transform="translate(-18.6911,0)"
+       height="470"
+       width="503"
+       id="use3731"
+       xlink:href="#g3727"
+       y="0"
+       x="0" />
+    <use
+       style="opacity:0.7"
+       height="470"
+       width="503"
+       transform="translate(-18.6911,0)"
+       id="use3733"
+       xlink:href="#use3731"
+       y="0"
+       x="0" />
+    <use
+       style="opacity:0.7"
+       height="470"
+       width="503"
+       transform="translate(-18.6911,0)"
+       id="use3735"
+       xlink:href="#use3733"
+       y="0"
+       x="0" />
+    <use
+       style="opacity:0.7"
+       height="470"
+       width="503"
+       transform="translate(-18.6911,0)"
+       id="use3737"
+       xlink:href="#use3735"
+       y="0"
+       x="0" />
+    <path
+       sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc"
+       id="path1873"
+       d="M 146.70363,451.36224 C 136.41665,439.25817 117.96276,427.46664 118.22954,410.8466 C 131.4176,398.00022 149.73758,391.50022 165.16214,381.48046 C 177.36573,377.92315 184.55911,366.27864 196.42539,362.21533 C 200.25466,364.05646 202.85143,363.72556 204.72132,362.07204 C 210.30922,357.13075 209.40602,340.37817 215.50489,334.48182 C 223.78613,321.5098 223.08641,307.92166 215.8387,295.58245 C 219.15033,289.75568 229.67341,280.27865 217.0457,277.78367 C 214.05316,263.07686 237.80097,250.83087 238.21953,246.42286 C 238.6613,241.77037 224.71715,223.12796 227.4412,211.04316 C 239.26444,201.8379 232.54342,180.91935 247.05739,173.43167 C 253.57364,167.77675 270.55418,166.80788 272.10042,163.64124 C 261.82854,152.70743 257.83929,133.4287 268.94854,122.06576 C 283.86705,113.28552 310.93594,121.11156 306.93119,141.77982 C 304.2029,153.50969 312.78113,173.98967 294.37865,175.02056 C 289.25974,188.64804 306.97314,199.59557 311.12784,212.07076 C 321.57332,222.75501 337.23467,227.20022 350.73778,228.88219 C 364.21231,235.80115 343.90857,255.58549 332.61304,257.18585 C 322.5321,260.71142 317.77727,249.30204 306.16714,248.18474 C 297.07176,231.01774 287.1681,252.7742 284.26224,262.80061 C 273.53689,268.93075 277.77925,274.25187 288.05256,275.95194 C 303.58262,284.46363 323.66601,286.48448 337.8214,299.13506 C 353.78915,303.65255 363.66303,319.71567 349.93287,332.94393 C 353.24892,346.12036 347.27071,362.55636 344.82976,377.07539 C 334.15896,394.93897 347.44912,413.54889 362.95723,422.0666 C 366.99318,442.97337 342.2195,430.53383 331.54054,427.84438 C 317.63792,425.90039 307.98522,412.41258 317.03167,400.17586 C 318.03991,383.92638 320.45165,367.34122 316.29676,351.40788 C 314.12364,342.24687 321.80553,323.49846 307.38528,332.33158 C 295.06248,331.15088 282.6744,322.96681 270.20825,327.69674 C 258.50928,341.47343 253.01377,359.0679 242.64591,373.55518 C 238.2541,385.57032 234.42448,397.8996 219.06012,395.36899 C 201.13025,400.26204 184.2505,408.5915 165.52309,409.94633 C 141.3757,412.97712 164.16533,436.73187 156.98647,449.80041 C 154.39151,452.66135 150.08051,452.07376 146.70363,451.36224 z "
+       style="fill:red;fill-opacity:1;stroke:black;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;opacity:1"
+       clip-path="none" />
+    <path
+       sodipodi:nodetypes="ccsccscc"
+       id="path3671"
+       d="M 334.64793,241.29732 L 382.57977,48.485235 C 358.20483,41.905636 333.28609,43.324619 308.24947,38.553817 C 284.14743,32.562211 254.01948,16.525975 254.01948,16.525975 L 238.03985,80.806118 C 238.03985,80.806118 268.17484,96.814006 292.27689,102.80562 C 316.37893,108.79723 350.53011,108.77047 350.53011,108.77047 L 318.57789,237.30241"
+       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       clip-path="none" />
+  </g>
+</svg>

Copied: trunk/misc/mediasource/graphics/sb-flag-dropped.svg (from rev 5536, trunk/misc/sb-flag-dropped.svg)
===================================================================
--- trunk/misc/mediasource/graphics/sb-flag-dropped.svg	                        (rev 0)
+++ trunk/misc/mediasource/graphics/sb-flag-dropped.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="744.09448819"
+   height="1052.3622047"
+   id="svg5531"
+   sodipodi:version="0.32"
+   inkscape:version="0.44"
+   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
+   sodipodi:docname="flag-dropped.svg"
+   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-dropped-blue.png"
+   inkscape:export-xdpi="13.401096"
+   inkscape:export-ydpi="13.401096">
+  <defs
+     id="defs5533" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10000"
+     guidetolerance="10"
+     objecttolerance="10"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="0.7"
+     inkscape:cx="375"
+     inkscape:cy="574.45286"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     inkscape:window-width="854"
+     inkscape:window-height="582"
+     inkscape:window-x="153"
+     inkscape:window-y="185" />
+  <metadata
+     id="metadata5536">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1">
+    <path
+       style="opacity:0.4;fill:#6f6f6f;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+       d="M 128.57143,612.36219 L 240,442.36218 L 545.71428,463.79076 L 372.85714,636.6479 L 128.57143,612.36219 z "
+       id="path5540"
+       sodipodi:nodetypes="ccccc" />
+    <path
+       sodipodi:nodetypes="cccsccscc"
+       id="path3671"
+       d="M 260.11602,526.80611 L 269.0491,540.74905 L 436.33978,433.56795 C 423.14748,412.0414 404.06506,395.95356 389.14932,375.28684 C 375.75138,354.37505 364.8752,322.02443 364.8752,322.02443 L 309.10345,357.75672 C 309.10345,357.75672 320.00421,390.09157 333.40215,411.00337 C 346.80009,431.91517 371.63495,455.35729 371.63495,455.35729 L 260.11602,526.80611 z "
+       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:7.47643995;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+  </g>
+</svg>

Copied: trunk/misc/mediasource/graphics/sb-flag-shielded.svg (from rev 5536, trunk/misc/sb-flag-shielded.svg)
===================================================================
--- trunk/misc/mediasource/graphics/sb-flag-shielded.svg	                        (rev 0)
+++ trunk/misc/mediasource/graphics/sb-flag-shielded.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.46"
+   width="503"
+   height="470"
+   version="1.0"
+   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
+   sodipodi:docname="sb-flag-shielded.svg"
+   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-carrying-blue.png"
+   inkscape:export-xdpi="13.401096"
+   inkscape:export-ydpi="13.401096"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs5">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 235 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="503 : 235 : 1"
+       inkscape:persp3d-origin="251.5 : 156.66667 : 1"
+       id="perspective31" />
+    <linearGradient
+       id="linearGradient3763">
+      <stop
+         style="stop-color:red;stop-opacity:1;"
+         offset="0"
+         id="stop3765" />
+      <stop
+         id="stop3775"
+         offset="0.33000001"
+         style="stop-color:yellow;stop-opacity:1;" />
+      <stop
+         style="stop-color:red;stop-opacity:1;"
+         offset="0.66000003"
+         id="stop3777" />
+      <stop
+         style="stop-color:yellow;stop-opacity:1;"
+         offset="1"
+         id="stop3767" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient2801">
+      <stop
+         style="stop-color:white;stop-opacity:1;"
+         offset="0"
+         id="stop2803" />
+      <stop
+         id="stop2809"
+         offset="0.94999999"
+         style="stop-color:white;stop-opacity:1;" />
+      <stop
+         style="stop-color:white;stop-opacity:0;"
+         offset="1"
+         id="stop2805" />
+    </linearGradient>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient2844"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.539066,0,0,1.902367,2.172742,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient3780"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.376665,0,0,1.902367,2.162274,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient3788"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient2801"
+       id="linearGradient3793"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
+       x1="-0.064449146"
+       y1="134.97579"
+       x2="499.41825"
+       y2="134.97579" />
+    <mask
+       maskUnits="userSpaceOnUse"
+       id="mask3790">
+      <rect
+         transform="matrix(0,1,-1,0,0,0)"
+         style="opacity:1;fill:url(#linearGradient3793);fill-opacity:1;stroke:none;stroke-width:7.87110186;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+         id="rect1878"
+         width="225.11722"
+         height="511.84491"
+         x="2.137996"
+         y="-511.84491" />
+    </mask>
+  </defs>
+  <sodipodi:namedview
+     inkscape:window-height="765"
+     inkscape:window-width="1019"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     showgrid="true"
+     grid_units="mm"
+     inkscape:grid-points="false"
+     showguides="true"
+     inkscape:guide-bbox="true"
+     inkscape:grid-bbox="true"
+     inkscape:zoom="0.83829788"
+     inkscape:cx="322.19322"
+     inkscape:cy="177.03021"
+     inkscape:window-x="26"
+     inkscape:window-y="68"
+     inkscape:current-layer="svg2">
+    <inkscape:grid
+       id="GridFromPre046Settings"
+       type="xygrid"
+       originx="0px"
+       originy="0px"
+       spacingx="1.25mm"
+       spacingy="1.25mm"
+       color="#0000ff"
+       empcolor="#0000ff"
+       opacity="0.2"
+       empopacity="0.4"
+       empspacing="5"
+       units="mm"
+       visible="true"
+       enabled="true" />
+  </sodipodi:namedview>
+  <path
+     id="path3671"
+     d="M 255.85515,350.70413 L 303.78699,157.89205 C 279.41205,151.31245 254.49331,152.73143 229.45669,147.96063 C 205.35465,141.96902 175.2267,125.93279 175.2267,125.93279 L 159.24707,190.21293 C 159.24707,190.21293 189.38206,206.22082 213.48411,212.21243 C 237.58615,218.20404 271.73733,218.17728 271.73733,218.17728 L 239.78511,346.70922"
+     style="fill:#0000ff;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+     mask="none" />
+  <path
+     style="opacity:1;fill:#aa0000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+     d="M 233.59375,27.09375 C 117.46186,27.09375 23.21875,121.33686 23.21875,237.46875 C 23.218748,353.60065 117.46186,447.84375 233.59375,447.84375 C 349.72564,447.84374 444,353.60064 444,237.46875 C 444,121.33687 349.72564,27.09375 233.59375,27.09375 z M 233.59375,71.375 C 325.27682,71.375 399.6875,145.78568 399.6875,237.46875 C 399.6875,279.3234 384.20404,317.59332 358.625,346.8125 L 124.28125,112.5 C 153.50236,86.913055 191.73187,71.375 233.59375,71.375 z M 108.59375,128.125 L 342.96875,362.46875 C 313.74534,388.06512 275.46426,403.5625 233.59375,403.5625 C 141.91068,403.56249 67.5,329.15182 67.5,237.46875 C 67.499999,195.61411 83.014714,157.34418 108.59375,128.125 z"
+     id="path3211" />
+</svg>

Copied: trunk/misc/mediasource/graphics/sb-flag-taken.svg (from rev 5536, trunk/misc/sb-flag-taken.svg)
===================================================================
--- trunk/misc/mediasource/graphics/sb-flag-taken.svg	                        (rev 0)
+++ trunk/misc/mediasource/graphics/sb-flag-taken.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:xlink="http://www.w3.org/1999/xlink"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.44"
+   width="503"
+   height="470"
+   version="1.0"
+   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
+   sodipodi:docname="flag-taken.svg"
+   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-taken-blue.png"
+   inkscape:export-xdpi="9.7539482"
+   inkscape:export-ydpi="9.7539482">
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs5" />
+  <sodipodi:namedview
+     inkscape:window-height="625"
+     inkscape:window-width="854"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     guidetolerance="10.0"
+     gridtolerance="10.0"
+     objecttolerance="10.0"
+     borderopacity="1.0"
+     bordercolor="#666666"
+     pagecolor="#ffffff"
+     id="base"
+     showgrid="true"
+     gridspacingx="2.5mm"
+     gridspacingy="2.5mm"
+     grid_units="mm"
+     inkscape:grid-points="false"
+     showguides="true"
+     inkscape:guide-bbox="true"
+     inkscape:grid-bbox="true"
+     inkscape:zoom="0.41914894"
+     inkscape:cx="287.59931"
+     inkscape:cy="103.2055"
+     inkscape:window-x="122"
+     inkscape:window-y="154"
+     inkscape:current-layer="svg2" />
+  <g
+     id="g3727"
+     style="opacity:0.3"
+     transform="matrix(0.934555,0,0,0.934555,55.17645,61.98067)"
+     inkscape:export-xdpi="9.7539482"
+     inkscape:export-ydpi="9.7539482">
+    <path
+       style="fill:red;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 77.936648,416.64918 C 66.929291,403.69748 47.183112,391.08021 47.468568,373.29631 C 61.580167,359.55032 81.18305,352.59514 97.68777,341.87372 C 110.74595,338.06729 118.44307,325.60734 131.14032,321.25949 C 135.23774,323.22955 138.01636,322.87548 140.0172,321.10616 C 145.99641,315.81884 145.02996,297.89311 151.55592,291.58386 C 160.41708,277.70343 159.66836,263.16374 151.9131,249.96044 C 155.45664,243.72563 166.71663,233.58495 153.20463,230.91525 C 150.00252,215.17855 175.41335,202.075 175.86122,197.3583 C 176.33392,192.38001 161.41329,172.43211 164.3281,159.50104 C 176.9793,149.65115 169.78762,127.26772 185.31798,119.25569 C 192.29054,113.20477 210.4602,112.16805 212.11472,108.77965 C 201.12352,97.080172 196.85491,76.451388 208.74212,64.292723 C 224.70534,54.897624 253.66981,63.271708 249.38462,85.387324 C 246.46527,97.938613 255.64422,119.85276 235.95305,120.95585 C 230.47567,135.53763 249.4295,147.25179 253.87515,160.6006 C 265.05211,172.03304 281.81019,176.78954 296.25889,178.5893 C 310.67702,185.99278 288.95145,207.16258 276.86491,208.87501 C 266.07803,212.64746 260.99023,200.43911 248.56706,199.24357 C 238.83475,180.87439 228.23756,204.15442 225.12821,214.88295 C 213.65178,221.44238 218.19122,227.13612 229.18395,228.95525 C 245.80155,238.06299 267.29134,240.22536 282.438,253.76183 C 299.52394,258.59567 310.08927,275.78366 295.39762,289.93827 C 298.94588,304.03742 292.54903,321.6244 289.93715,337.16017 C 278.51909,356.2747 292.73993,376.18783 309.33405,385.30202 C 313.65263,407.67285 287.14409,394.36219 275.71731,391.48441 C 260.84112,389.40428 250.51246,374.97195 260.19241,361.87832 C 261.27126,344.49092 263.85189,326.74433 259.40604,309.69521 C 257.08074,299.89268 265.30058,279.83135 249.8705,289.28304 C 236.68476,288.01966 223.42917,279.26247 210.09004,284.32363 C 197.57182,299.06507 191.69147,317.89165 180.59757,333.39344 C 175.89821,346.24998 171.80041,359.44265 155.36011,356.73483 C 136.17465,361.97053 118.11284,370.88329 98.07399,372.33299 C 72.235605,375.57602 96.62115,400.99427 88.93957,414.97797 C 86.16289,418.03926 81.55,417.41052 77.936648,416.64918 z "
+       id="path3723"
+       sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc" />
+    <path
+       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;opacity:1"
+       d="M 279.0423,191.87383 L 330.33071,-14.440493 C 304.24885,-21.480848 277.5851,-19.962497 250.79521,-25.067388 C 225.00536,-31.478574 192.76761,-48.637795 192.76761,-48.637795 L 175.66896,20.143756 C 175.66896,20.143756 207.91424,37.272644 233.7041,43.683836 C 259.49396,50.095029 296.03668,50.066395 296.03668,50.066395 L 261.84691,187.59917"
+       id="path3725"
+       sodipodi:nodetypes="ccsccscc" />
+  </g>
+  <use
+     x="0"
+     y="0"
+     xlink:href="#g3727"
+     id="use3731"
+     width="503"
+     height="470"
+     transform="translate(-18.6911,0)"
+     style="opacity:0.7" />
+  <use
+     x="0"
+     y="0"
+     xlink:href="#use3731"
+     id="use3733"
+     transform="translate(-18.6911,0)"
+     width="503"
+     height="470"
+     style="opacity:0.7" />
+  <use
+     x="0"
+     y="0"
+     xlink:href="#use3733"
+     id="use3735"
+     transform="translate(-18.6911,0)"
+     width="503"
+     height="470"
+     style="opacity:0.7" />
+  <use
+     x="0"
+     y="0"
+     xlink:href="#use3735"
+     id="use3737"
+     transform="translate(-18.6911,0)"
+     width="503"
+     height="470"
+     style="opacity:0.7" />
+  <g
+     id="g3739"
+     transform="matrix(0.934555,0,0,0.934555,55.17645,61.98067)">
+    <path
+       sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc"
+       id="path1873"
+       d="M 97.936648,416.64918 C 86.929291,403.69748 67.183112,391.08021 67.468568,373.29631 C 81.580167,359.55032 101.18305,352.59514 117.68777,341.87372 C 130.74595,338.06729 138.44307,325.60734 151.14032,321.25949 C 155.23774,323.22955 158.01636,322.87548 160.0172,321.10616 C 165.99641,315.81884 165.02996,297.89311 171.55592,291.58386 C 180.41708,277.70343 179.66836,263.16374 171.9131,249.96044 C 175.45664,243.72563 186.71663,233.58495 173.20463,230.91525 C 170.00252,215.17855 195.41335,202.075 195.86122,197.3583 C 196.33392,192.38001 181.41329,172.43211 184.3281,159.50104 C 196.9793,149.65115 189.78762,127.26772 205.31798,119.25569 C 212.29054,113.20477 230.4602,112.16805 232.11472,108.77965 C 221.12352,97.080172 216.85491,76.451388 228.74212,64.292723 C 244.70534,54.897624 273.66981,63.271708 269.38462,85.387324 C 266.46527,97.938613 275.64422,119.85276 255.95305,120.95585 C 250.47567,135.53763 269.4295,147.25179 273.87515,160.6006 C 285.05211,172.03304 301.81019,176.78954 316.25889,178.5893 C 330.67702,185.99278 308.95145,207.16258 296.86491,208.87501 C 286.07803,212.64746 280.99023,200.43911 268.56706,199.24357 C 258.83475,180.87439 248.23756,204.15442 245.12821,214.88295 C 233.65178,221.44238 238.19122,227.13612 249.18395,228.95525 C 265.80155,238.06299 287.29134,240.22536 302.438,253.76183 C 319.52394,258.59567 330.08927,275.78366 315.39762,289.93827 C 318.94588,304.03742 312.54903,321.6244 309.93715,337.16017 C 298.51909,356.2747 312.73993,376.18783 329.33405,385.30202 C 333.65263,407.67285 307.14409,394.36219 295.71731,391.48441 C 280.84112,389.40428 270.51246,374.97195 280.19241,361.87832 C 281.27126,344.49092 283.85189,326.74433 279.40604,309.69521 C 277.08074,299.89268 285.30058,279.83135 269.8705,289.28304 C 256.68476,288.01966 243.42917,279.26247 230.09004,284.32363 C 217.57182,299.06507 211.69147,317.89165 200.59757,333.39344 C 195.89821,346.24998 191.80041,359.44265 175.36011,356.73483 C 156.17465,361.97053 138.11284,370.88329 118.07399,372.33299 C 92.235605,375.57602 116.62115,400.99427 108.93957,414.97797 C 106.16289,418.03926 101.55,417.41052 97.936648,416.64918 z "
+       style="fill:red;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <path
+       sodipodi:nodetypes="ccsccscc"
+       id="path3671"
+       d="M 299.0423,191.87383 L 350.33071,-14.440493 C 324.24885,-21.480848 297.5851,-19.962497 270.79521,-25.067388 C 245.00536,-31.478574 212.76761,-48.637795 212.76761,-48.637795 L 195.66896,20.143756 C 195.66896,20.143756 227.91424,37.272644 253.7041,43.683836 C 279.49396,50.095029 316.03668,50.066395 316.03668,50.066395 L 281.84691,187.59917"
+       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+  </g>
+</svg>

Copied: trunk/misc/mediasource/menuskins (from rev 5536, trunk/graphicssource/Menu Skins)

Copied: trunk/misc/mediasource/models (from rev 5536, trunk/modelsource)

Deleted: trunk/misc/nexuiz-map-compiler
===================================================================
--- trunk/misc/nexuiz-map-compiler	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/nexuiz-map-compiler	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,233 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use POSIX;
-
-# change these to match your system, or define them in ~/.nexuiz-map-compiler
-# (just copy paste this part to the file ~/.nexuiz-map-compiler)
-
-	# Path to Nexuiz (where the data directory is in)
-	our $NEXUIZDIR   = '/home/polzer/Nexvn/nexuiz';
-
-	# Path to your q3map2 program. You find it in your GtkRadiant/install
-	# directory.
-	our $Q3MAP2      = '/home/users4/ommz/polzer/bin/q3map2.x86';
-
-	# General flags for q3map2 (for example -threads 4)
-	our $Q3MAP2FLAGS = '';
-
-	# Default flags for the -bsp stage
-	our $BSPFLAGS    = '-samplesize 8 -minsamplesize 4 -mv 1000000 -mi 6000000';
-
-	# Default flags for the -vis stage
-	our $VISFLAGS    = '';
-
-	# Default flags for the -light stage
-	our $LIGHTFLAGS  = '-deluxe -patchshadows -samples 3 -lightmapsize 512 -bounce 8 -fastbounce -bouncegrid';
-
-# end of user changable part
-
-do "$ENV{HOME}/.nexuiz-map-compiler";
-
-sub Usage()
-{
-	print <<EOF;
-Usage:
-$0 mapname [-bsp bspflags...] [-vis visflags...] [-light lightflags...]
-EOF
-	exit 1;
-}
-
-my $options =
-{
-	bsp => [split /\s+/, $BSPFLAGS],
-	vis => [split /\s+/, $VISFLAGS],
-	light => [split /\s+/, $LIGHTFLAGS],
-	maps => [],
-	scale => 1
-};
-
-my $curmode = 'maps';
-
-while(@ARGV)
-{
-	$_ = shift @ARGV;
-	my $enterflags = undef;
-	if($_ eq '-bsp' or $_ eq '-meta')
-	{
-		$enterflags = 'bsp';
-	}
-	elsif($_ eq '-vis')
-	{
-		$enterflags = 'vis';
-	}
-	elsif($_ eq '-light')
-	{
-		$enterflags = 'light';
-	}
-	elsif($_ eq '-map')
-	{
-		$curmode = 'maps';
-	}
-	elsif($_ eq '-scale')
-	{
-		$options->{scale} = (shift @ARGV) || 1;
-	}
-	elsif($_ eq '-novis')
-	{
-		$options->{vis} = undef;
-	}
-	elsif($_ eq '-nolight')
-	{
-		$options->{light} = undef;
-	}
-	elsif($_ =~ /^-/ and $curmode eq 'maps')
-	{
-		$curmode = 'bsp';
-		push @{$options->{$curmode}}, $_;
-	}
-	else
-	{
-		push @{$options->{$curmode}}, $_;
-	}
-	if(defined $enterflags)
-	{
-		$curmode = $enterflags;
-		if($ARGV[0] eq '+')
-		{
-			shift @ARGV;
-		}
-		else
-		{
-			$options->{$curmode} = [];
-		}
-	}
-}
-
-my $game = 'compile.' . int rand 99999999; # mktemp on win32?
-
-sub q3map2(@)
-{
-	my @args = ($Q3MAP2, split(/\s+/, $Q3MAP2FLAGS), '-game', 'nexuiz', '-fs_basepath', $NEXUIZDIR, '-fs_game', $game, '-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.";
-};
-
-my ($prescale, $postscale) = ($options->{scale} =~ /^([0-9.]+)(?::([0-9.]+))?$/);
-$postscale = 1 if not defined $postscale;
-
-for my $m(@{$options->{maps}})
-{
-	if($prescale != 1 or $postscale != 1)
-	{
-		open my $checkfh, "<", "$m.map"
-			or die "open $m.map: $!";
-		my $keeplights = 0;
-		while(<$checkfh>)
-		{
-			/^\s*"_keeplights"\s+"1"\s*$/
-				or next;
-			$keeplights = 1;
-		}
-		close $checkfh;
-		die "$m does not define _keeplights to 1"
-			unless $keeplights;
-	}
-
-	my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
-	open my $shaderlist, "+<", "$NEXUIZDIR/data/scripts/shaderlist.txt"
-		or die "open $NEXUIZDIR/data/scripts/shaderlist.txt: $!";
-	my $previous_shaderlist = "";
-	while(<$shaderlist>)
-	{
-		$previous_shaderlist .= $_;
-		y/\r\n//d;
-		delete $shaders{$_};
-	}
-	my $restore_shaderlist = sub
-	{
-		open $shaderlist, ">", "$NEXUIZDIR/data/scripts/shaderlist.txt";
-		print $shaderlist $previous_shaderlist;
-		close $shaderlist;
-	};
-	local $SIG{INT} = sub
-	{
-		print "SIGINT caught, cleaning up...\n";
-		$restore_shaderlist->();
-		exit 0;
-	};
-	eval
-	{
-		for(keys %shaders)
-		{
-			print $shaderlist "$_\n";
-		}
-		close $shaderlist;
-
-		unlink <$m/lm_*>; # delete old external lightmaps
-		q3map2 '-bsp', '-meta', @{$options->{bsp}},   "$m.map"
-			or die "-bsp: $?";
-		if($prescale != 1)
-		{
-			q3map2 '-scale', $prescale, "$m.bsp"
-				or die "-scale: $?";
-			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($postscale != 1)
-		{
-			q3map2 '-scale', $postscale, "$m.bsp"
-				or die "-scale: $?";
-			rename "${m}_s.bsp", "$m.bsp"
-				or die "rename ${m}_s.bsp $m.bsp: $!";
-		}
-
-		unlink "$m.srf";
-
-		$restore_shaderlist->();
-		1;
-	}
-	or do
-	{
-		$restore_shaderlist->();
-		die $@;
-	};
-}

Deleted: trunk/misc/polycount.pl
===================================================================
--- trunk/misc/polycount.pl	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/polycount.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-
-for(@ARGV)
-{
-	my $data = do {
-		open my $fh, "<", $_;
-		undef local $/;
-		<$fh>;
-	};
-
-	my $vertex = undef;
-	my $poly = undef;
-	my $type = undef;
-
-	if("IDP3" eq substr $data, 0, 4)
-	{
-		# MD3 model
-		my $num_meshes = unpack "V", substr $data, 4+4+64+4+4+4, 4;
-		my $ofs_meshes = unpack "V", substr $data, 4+4+64+4+4+4+4+4+4+4, 4;
-		$vertex = $poly = 0;
-		for(1..$num_meshes)
-		{
-			$vertex     += unpack "V", substr $data, $ofs_meshes+4+64+4+4+4, 4;
-			$poly       += unpack "V", substr $data, $ofs_meshes+4+64+4+4+4+4, 4;
-			$ofs_meshes += unpack "V", substr $data, $ofs_meshes+4+64+4+4+4+4+4+4+4+4+4, 4;
-		}
-		$type = "md3";
-	}
-	elsif("ZYMOTICMODEL" eq substr $data, 0, 12)
-	{
-		# ZYM model
-		$vertex = unpack "N", substr $data, 12+4+4+4*3+4*3+4, 4;
-		$poly   = unpack "N", substr $data, 12+4+4+4*3+4*3+4+4, 4;
-		$type = "zym";
-	}
-
-	if(defined $type)
-	{
-		printf "%8d %8d %-3s %s\n", $vertex, $poly, $type, $_;
-	}
-	else
-	{
-		printf "%8s %8s %-3s %s\n", "-", "-", "-", $_;
-	}
-}

Deleted: trunk/misc/sb-flag-carrying.svg
===================================================================
--- trunk/misc/sb-flag-carrying.svg	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/sb-flag-carrying.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,220 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://web.resource.org/cc/"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:xlink="http://www.w3.org/1999/xlink"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   id="svg2"
-   sodipodi:version="0.32"
-   inkscape:version="0.44"
-   width="503"
-   height="470"
-   version="1.0"
-   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
-   sodipodi:docname="flag-carrying.svg"
-   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-carrying-blue.png"
-   inkscape:export-xdpi="19.617588"
-   inkscape:export-ydpi="19.617588">
-  <metadata
-     id="metadata7">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <defs
-     id="defs5">
-    <linearGradient
-       id="linearGradient3763">
-      <stop
-         style="stop-color:red;stop-opacity:1;"
-         offset="0"
-         id="stop3765" />
-      <stop
-         id="stop3775"
-         offset="0.33000001"
-         style="stop-color:yellow;stop-opacity:1;" />
-      <stop
-         style="stop-color:red;stop-opacity:1;"
-         offset="0.66000003"
-         id="stop3777" />
-      <stop
-         style="stop-color:yellow;stop-opacity:1;"
-         offset="1"
-         id="stop3767" />
-    </linearGradient>
-    <linearGradient
-       id="linearGradient2801">
-      <stop
-         style="stop-color:white;stop-opacity:1;"
-         offset="0"
-         id="stop2803" />
-      <stop
-         id="stop2809"
-         offset="0.94999999"
-         style="stop-color:white;stop-opacity:1;" />
-      <stop
-         style="stop-color:white;stop-opacity:0;"
-         offset="1"
-         id="stop2805" />
-    </linearGradient>
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient2844"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.539066,0,0,1.902367,2.172742,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient3780"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.376665,0,0,1.902367,2.162274,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient3788"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient3793"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <mask
-       maskUnits="userSpaceOnUse"
-       id="mask3790">
-      <rect
-         transform="matrix(0,1,-1,0,0,0)"
-         style="opacity:1;fill:url(#linearGradient3793);fill-opacity:1;stroke:none;stroke-width:7.87110186;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
-         id="rect1878"
-         width="225.11722"
-         height="511.84491"
-         x="2.137996"
-         y="-511.84491" />
-    </mask>
-  </defs>
-  <sodipodi:namedview
-     inkscape:window-height="645"
-     inkscape:window-width="1019"
-     inkscape:pageshadow="2"
-     inkscape:pageopacity="0.0"
-     guidetolerance="10.0"
-     gridtolerance="10.0"
-     objecttolerance="10.0"
-     borderopacity="1.0"
-     bordercolor="#666666"
-     pagecolor="#ffffff"
-     id="base"
-     showgrid="true"
-     gridspacingx="2.5mm"
-     gridspacingy="2.5mm"
-     grid_units="mm"
-     inkscape:grid-points="false"
-     showguides="true"
-     inkscape:guide-bbox="true"
-     inkscape:grid-bbox="true"
-     inkscape:zoom="0.83829788"
-     inkscape:cx="287.59931"
-     inkscape:cy="273.85808"
-     inkscape:window-x="232"
-     inkscape:window-y="222"
-     inkscape:current-layer="svg2" />
-  <g
-     id="g1880"
-     clip-path="none"
-     mask="url(#mask3790)">
-    <g
-       inkscape:export-ydpi="9.7539482"
-       inkscape:export-xdpi="9.7539482"
-       transform="matrix(0.934555,0,0,0.934555,55.17645,61.98067)"
-       style="opacity:0.3"
-       id="g3727"
-       clip-path="none">
-      <path
-         sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc"
-         id="path3723"
-         d="M 77.936648,416.64918 C 66.929291,403.69748 47.183112,391.08021 47.468568,373.29631 C 61.580167,359.55032 81.18305,352.59514 97.68777,341.87372 C 110.74595,338.06729 118.44307,325.60734 131.14032,321.25949 C 135.23774,323.22955 138.01636,322.87548 140.0172,321.10616 C 145.99641,315.81884 145.02996,297.89311 151.55592,291.58386 C 160.41708,277.70343 159.66836,263.16374 151.9131,249.96044 C 155.45664,243.72563 166.71663,233.58495 153.20463,230.91525 C 150.00252,215.17855 175.41335,202.075 175.86122,197.3583 C 176.33392,192.38001 161.41329,172.43211 164.3281,159.50104 C 176.9793,149.65115 169.78762,127.26772 185.31798,119.25569 C 192.29054,113.20477 210.4602,112.16805 212.11472,108.77965 C 201.12352,97.080172 196.85491,76.451388 208.74212,64.292723 C 224.70534,54.897624 253.66981,63.271708 249.38462,85.387324 C 246.46527,97.938613 255.64422,119.85276 235.95305,120.95585 C 230.47567,135.53763 249.4295,147.25179 253.87515,160.6006 C 265.05211,172.03304 281.81019,176.78954 296.25889,178.5893 C 310.67702,185.99278 288.95145,207.16258 276.86491,208.87501 C 266.07803,212.64746 260.99023,200.43911 248.56706,199.24357 C 238.83475,180.87439 228.23756,204.15442 225.12821,214.88295 C 213.65178,221.44238 218.19122,227.13612 229.18395,228.95525 C 245.80155,238.06299 267.29134,240.22536 282.438,253.76183 C 299.52394,258.59567 310.08927,275.78366 295.39762,289.93827 C 298.94588,304.03742 292.54903,321.6244 289.93715,337.16017 C 278.51909,356.2747 292.73993,376.18783 309.33405,385.30202 C 313.65263,407.67285 287.14409,394.36219 275.71731,391.48441 C 260.84112,389.40428 250.51246,374.97195 260.19241,361.87832 C 261.27126,344.49092 263.85189,326.74433 259.40604,309.69521 C 257.08074,299.89268 265.30058,279.83135 249.8705,289.28304 C 236.68476,288.01966 223.42917,279.26247 210.09004,284.32363 C 197.57182,299.06507 191.69147,317.89165 180.59757,333.39344 C 175.89821,346.24998 171.80041,359.44265 155.36011,356.73483 C 136.17465,361.97053 118.11284,370.88329 98.07399,372.33299 C 72.235605,375.57602 96.62115,400.99427 88.93957,414.97797 C 86.16289,418.03926 81.55,417.41052 77.936648,416.64918 z "
-         style="fill:red;fill-opacity:1;stroke:black;stroke-width:5.35013991;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-      <path
-         sodipodi:nodetypes="ccsccscc"
-         id="path3725"
-         d="M 279.0423,191.87383 L 330.33071,-14.440493 C 304.24885,-21.480848 277.5851,-19.962497 250.79521,-25.067388 C 225.00536,-31.478574 192.76761,-48.637795 192.76761,-48.637795 L 175.66896,20.143756 C 175.66896,20.143756 207.91424,37.272644 233.7041,43.683836 C 259.49396,50.095029 296.03668,50.066395 296.03668,50.066395 L 261.84691,187.59917"
-         style="fill:blue;fill-opacity:1;stroke:black;stroke-width:5.35013991;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;opacity:1" />
-    </g>
-    <use
-       style="opacity:0.7"
-       transform="translate(-18.6911,0)"
-       height="470"
-       width="503"
-       id="use3731"
-       xlink:href="#g3727"
-       y="0"
-       x="0" />
-    <use
-       style="opacity:0.7"
-       height="470"
-       width="503"
-       transform="translate(-18.6911,0)"
-       id="use3733"
-       xlink:href="#use3731"
-       y="0"
-       x="0" />
-    <use
-       style="opacity:0.7"
-       height="470"
-       width="503"
-       transform="translate(-18.6911,0)"
-       id="use3735"
-       xlink:href="#use3733"
-       y="0"
-       x="0" />
-    <use
-       style="opacity:0.7"
-       height="470"
-       width="503"
-       transform="translate(-18.6911,0)"
-       id="use3737"
-       xlink:href="#use3735"
-       y="0"
-       x="0" />
-    <path
-       sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc"
-       id="path1873"
-       d="M 146.70363,451.36224 C 136.41665,439.25817 117.96276,427.46664 118.22954,410.8466 C 131.4176,398.00022 149.73758,391.50022 165.16214,381.48046 C 177.36573,377.92315 184.55911,366.27864 196.42539,362.21533 C 200.25466,364.05646 202.85143,363.72556 204.72132,362.07204 C 210.30922,357.13075 209.40602,340.37817 215.50489,334.48182 C 223.78613,321.5098 223.08641,307.92166 215.8387,295.58245 C 219.15033,289.75568 229.67341,280.27865 217.0457,277.78367 C 214.05316,263.07686 237.80097,250.83087 238.21953,246.42286 C 238.6613,241.77037 224.71715,223.12796 227.4412,211.04316 C 239.26444,201.8379 232.54342,180.91935 247.05739,173.43167 C 253.57364,167.77675 270.55418,166.80788 272.10042,163.64124 C 261.82854,152.70743 257.83929,133.4287 268.94854,122.06576 C 283.86705,113.28552 310.93594,121.11156 306.93119,141.77982 C 304.2029,153.50969 312.78113,173.98967 294.37865,175.02056 C 289.25974,188.64804 306.97314,199.59557 311.12784,212.07076 C 321.57332,222.75501 337.23467,227.20022 350.73778,228.88219 C 364.21231,235.80115 343.90857,255.58549 332.61304,257.18585 C 322.5321,260.71142 317.77727,249.30204 306.16714,248.18474 C 297.07176,231.01774 287.1681,252.7742 284.26224,262.80061 C 273.53689,268.93075 277.77925,274.25187 288.05256,275.95194 C 303.58262,284.46363 323.66601,286.48448 337.8214,299.13506 C 353.78915,303.65255 363.66303,319.71567 349.93287,332.94393 C 353.24892,346.12036 347.27071,362.55636 344.82976,377.07539 C 334.15896,394.93897 347.44912,413.54889 362.95723,422.0666 C 366.99318,442.97337 342.2195,430.53383 331.54054,427.84438 C 317.63792,425.90039 307.98522,412.41258 317.03167,400.17586 C 318.03991,383.92638 320.45165,367.34122 316.29676,351.40788 C 314.12364,342.24687 321.80553,323.49846 307.38528,332.33158 C 295.06248,331.15088 282.6744,322.96681 270.20825,327.69674 C 258.50928,341.47343 253.01377,359.0679 242.64591,373.55518 C 238.2541,385.57032 234.42448,397.8996 219.06012,395.36899 C 201.13025,400.26204 184.2505,408.5915 165.52309,409.94633 C 141.3757,412.97712 164.16533,436.73187 156.98647,449.80041 C 154.39151,452.66135 150.08051,452.07376 146.70363,451.36224 z "
-       style="fill:red;fill-opacity:1;stroke:black;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;opacity:1"
-       clip-path="none" />
-    <path
-       sodipodi:nodetypes="ccsccscc"
-       id="path3671"
-       d="M 334.64793,241.29732 L 382.57977,48.485235 C 358.20483,41.905636 333.28609,43.324619 308.24947,38.553817 C 284.14743,32.562211 254.01948,16.525975 254.01948,16.525975 L 238.03985,80.806118 C 238.03985,80.806118 268.17484,96.814006 292.27689,102.80562 C 316.37893,108.79723 350.53011,108.77047 350.53011,108.77047 L 318.57789,237.30241"
-       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
-       clip-path="none" />
-  </g>
-</svg>

Deleted: trunk/misc/sb-flag-dropped.svg
===================================================================
--- trunk/misc/sb-flag-dropped.svg	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/sb-flag-dropped.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://web.resource.org/cc/"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="744.09448819"
-   height="1052.3622047"
-   id="svg5531"
-   sodipodi:version="0.32"
-   inkscape:version="0.44"
-   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
-   sodipodi:docname="flag-dropped.svg"
-   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-dropped-blue.png"
-   inkscape:export-xdpi="13.401096"
-   inkscape:export-ydpi="13.401096">
-  <defs
-     id="defs5533" />
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     gridtolerance="10000"
-     guidetolerance="10"
-     objecttolerance="10"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="0.7"
-     inkscape:cx="375"
-     inkscape:cy="574.45286"
-     inkscape:document-units="px"
-     inkscape:current-layer="layer1"
-     inkscape:window-width="854"
-     inkscape:window-height="582"
-     inkscape:window-x="153"
-     inkscape:window-y="185" />
-  <metadata
-     id="metadata5536">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer"
-     id="layer1">
-    <path
-       style="opacity:0.4;fill:#6f6f6f;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
-       d="M 128.57143,612.36219 L 240,442.36218 L 545.71428,463.79076 L 372.85714,636.6479 L 128.57143,612.36219 z "
-       id="path5540"
-       sodipodi:nodetypes="ccccc" />
-    <path
-       sodipodi:nodetypes="cccsccscc"
-       id="path3671"
-       d="M 260.11602,526.80611 L 269.0491,540.74905 L 436.33978,433.56795 C 423.14748,412.0414 404.06506,395.95356 389.14932,375.28684 C 375.75138,354.37505 364.8752,322.02443 364.8752,322.02443 L 309.10345,357.75672 C 309.10345,357.75672 320.00421,390.09157 333.40215,411.00337 C 346.80009,431.91517 371.63495,455.35729 371.63495,455.35729 L 260.11602,526.80611 z "
-       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:7.47643995;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
-  </g>
-</svg>

Deleted: trunk/misc/sb-flag-shielded.svg
===================================================================
--- trunk/misc/sb-flag-shielded.svg	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/sb-flag-shielded.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,180 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:xlink="http://www.w3.org/1999/xlink"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   id="svg2"
-   sodipodi:version="0.32"
-   inkscape:version="0.46"
-   width="503"
-   height="470"
-   version="1.0"
-   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
-   sodipodi:docname="sb-flag-shielded.svg"
-   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-carrying-blue.png"
-   inkscape:export-xdpi="13.401096"
-   inkscape:export-ydpi="13.401096"
-   inkscape:output_extension="org.inkscape.output.svg.inkscape">
-  <metadata
-     id="metadata7">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <defs
-     id="defs5">
-    <inkscape:perspective
-       sodipodi:type="inkscape:persp3d"
-       inkscape:vp_x="0 : 235 : 1"
-       inkscape:vp_y="0 : 1000 : 0"
-       inkscape:vp_z="503 : 235 : 1"
-       inkscape:persp3d-origin="251.5 : 156.66667 : 1"
-       id="perspective31" />
-    <linearGradient
-       id="linearGradient3763">
-      <stop
-         style="stop-color:red;stop-opacity:1;"
-         offset="0"
-         id="stop3765" />
-      <stop
-         id="stop3775"
-         offset="0.33000001"
-         style="stop-color:yellow;stop-opacity:1;" />
-      <stop
-         style="stop-color:red;stop-opacity:1;"
-         offset="0.66000003"
-         id="stop3777" />
-      <stop
-         style="stop-color:yellow;stop-opacity:1;"
-         offset="1"
-         id="stop3767" />
-    </linearGradient>
-    <linearGradient
-       id="linearGradient2801">
-      <stop
-         style="stop-color:white;stop-opacity:1;"
-         offset="0"
-         id="stop2803" />
-      <stop
-         id="stop2809"
-         offset="0.94999999"
-         style="stop-color:white;stop-opacity:1;" />
-      <stop
-         style="stop-color:white;stop-opacity:0;"
-         offset="1"
-         id="stop2805" />
-    </linearGradient>
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient2844"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.539066,0,0,1.902367,2.172742,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient3780"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.376665,0,0,1.902367,2.162274,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient3788"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient2801"
-       id="linearGradient3793"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="matrix(0.450701,0,0,1.902367,2.167046,-512.696)"
-       x1="-0.064449146"
-       y1="134.97579"
-       x2="499.41825"
-       y2="134.97579" />
-    <mask
-       maskUnits="userSpaceOnUse"
-       id="mask3790">
-      <rect
-         transform="matrix(0,1,-1,0,0,0)"
-         style="opacity:1;fill:url(#linearGradient3793);fill-opacity:1;stroke:none;stroke-width:7.87110186;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
-         id="rect1878"
-         width="225.11722"
-         height="511.84491"
-         x="2.137996"
-         y="-511.84491" />
-    </mask>
-  </defs>
-  <sodipodi:namedview
-     inkscape:window-height="765"
-     inkscape:window-width="1019"
-     inkscape:pageshadow="2"
-     inkscape:pageopacity="0.0"
-     guidetolerance="10.0"
-     gridtolerance="10.0"
-     objecttolerance="10.0"
-     borderopacity="1.0"
-     bordercolor="#666666"
-     pagecolor="#ffffff"
-     id="base"
-     showgrid="true"
-     grid_units="mm"
-     inkscape:grid-points="false"
-     showguides="true"
-     inkscape:guide-bbox="true"
-     inkscape:grid-bbox="true"
-     inkscape:zoom="0.83829788"
-     inkscape:cx="322.19322"
-     inkscape:cy="177.03021"
-     inkscape:window-x="26"
-     inkscape:window-y="68"
-     inkscape:current-layer="svg2">
-    <inkscape:grid
-       id="GridFromPre046Settings"
-       type="xygrid"
-       originx="0px"
-       originy="0px"
-       spacingx="1.25mm"
-       spacingy="1.25mm"
-       color="#0000ff"
-       empcolor="#0000ff"
-       opacity="0.2"
-       empopacity="0.4"
-       empspacing="5"
-       units="mm"
-       visible="true"
-       enabled="true" />
-  </sodipodi:namedview>
-  <path
-     id="path3671"
-     d="M 255.85515,350.70413 L 303.78699,157.89205 C 279.41205,151.31245 254.49331,152.73143 229.45669,147.96063 C 205.35465,141.96902 175.2267,125.93279 175.2267,125.93279 L 159.24707,190.21293 C 159.24707,190.21293 189.38206,206.22082 213.48411,212.21243 C 237.58615,218.20404 271.73733,218.17728 271.73733,218.17728 L 239.78511,346.70922"
-     style="fill:#0000ff;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
-     mask="none" />
-  <path
-     style="opacity:1;fill:#aa0000;fill-opacity:1;stroke:#000000;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-     d="M 233.59375,27.09375 C 117.46186,27.09375 23.21875,121.33686 23.21875,237.46875 C 23.218748,353.60065 117.46186,447.84375 233.59375,447.84375 C 349.72564,447.84374 444,353.60064 444,237.46875 C 444,121.33687 349.72564,27.09375 233.59375,27.09375 z M 233.59375,71.375 C 325.27682,71.375 399.6875,145.78568 399.6875,237.46875 C 399.6875,279.3234 384.20404,317.59332 358.625,346.8125 L 124.28125,112.5 C 153.50236,86.913055 191.73187,71.375 233.59375,71.375 z M 108.59375,128.125 L 342.96875,362.46875 C 313.74534,388.06512 275.46426,403.5625 233.59375,403.5625 C 141.91068,403.56249 67.5,329.15182 67.5,237.46875 C 67.499999,195.61411 83.014714,157.34418 108.59375,128.125 z"
-     id="path3211" />
-</svg>

Deleted: trunk/misc/sb-flag-taken.svg
===================================================================
--- trunk/misc/sb-flag-taken.svg	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/sb-flag-taken.svg	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://web.resource.org/cc/"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:xlink="http://www.w3.org/1999/xlink"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   id="svg2"
-   sodipodi:version="0.32"
-   inkscape:version="0.44"
-   width="503"
-   height="470"
-   version="1.0"
-   sodipodi:docbase="/home/users4/ommz/polzer/WWW/temp/running-marine"
-   sodipodi:docname="flag-taken.svg"
-   inkscape:export-filename="/home/users4/ommz/polzer/WWW/temp/running-marine/flag-taken-blue.png"
-   inkscape:export-xdpi="9.7539482"
-   inkscape:export-ydpi="9.7539482">
-  <metadata
-     id="metadata7">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <defs
-     id="defs5" />
-  <sodipodi:namedview
-     inkscape:window-height="625"
-     inkscape:window-width="854"
-     inkscape:pageshadow="2"
-     inkscape:pageopacity="0.0"
-     guidetolerance="10.0"
-     gridtolerance="10.0"
-     objecttolerance="10.0"
-     borderopacity="1.0"
-     bordercolor="#666666"
-     pagecolor="#ffffff"
-     id="base"
-     showgrid="true"
-     gridspacingx="2.5mm"
-     gridspacingy="2.5mm"
-     grid_units="mm"
-     inkscape:grid-points="false"
-     showguides="true"
-     inkscape:guide-bbox="true"
-     inkscape:grid-bbox="true"
-     inkscape:zoom="0.41914894"
-     inkscape:cx="287.59931"
-     inkscape:cy="103.2055"
-     inkscape:window-x="122"
-     inkscape:window-y="154"
-     inkscape:current-layer="svg2" />
-  <g
-     id="g3727"
-     style="opacity:0.3"
-     transform="matrix(0.934555,0,0,0.934555,55.17645,61.98067)"
-     inkscape:export-xdpi="9.7539482"
-     inkscape:export-ydpi="9.7539482">
-    <path
-       style="fill:red;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-       d="M 77.936648,416.64918 C 66.929291,403.69748 47.183112,391.08021 47.468568,373.29631 C 61.580167,359.55032 81.18305,352.59514 97.68777,341.87372 C 110.74595,338.06729 118.44307,325.60734 131.14032,321.25949 C 135.23774,323.22955 138.01636,322.87548 140.0172,321.10616 C 145.99641,315.81884 145.02996,297.89311 151.55592,291.58386 C 160.41708,277.70343 159.66836,263.16374 151.9131,249.96044 C 155.45664,243.72563 166.71663,233.58495 153.20463,230.91525 C 150.00252,215.17855 175.41335,202.075 175.86122,197.3583 C 176.33392,192.38001 161.41329,172.43211 164.3281,159.50104 C 176.9793,149.65115 169.78762,127.26772 185.31798,119.25569 C 192.29054,113.20477 210.4602,112.16805 212.11472,108.77965 C 201.12352,97.080172 196.85491,76.451388 208.74212,64.292723 C 224.70534,54.897624 253.66981,63.271708 249.38462,85.387324 C 246.46527,97.938613 255.64422,119.85276 235.95305,120.95585 C 230.47567,135.53763 249.4295,147.25179 253.87515,160.6006 C 265.05211,172.03304 281.81019,176.78954 296.25889,178.5893 C 310.67702,185.99278 288.95145,207.16258 276.86491,208.87501 C 266.07803,212.64746 260.99023,200.43911 248.56706,199.24357 C 238.83475,180.87439 228.23756,204.15442 225.12821,214.88295 C 213.65178,221.44238 218.19122,227.13612 229.18395,228.95525 C 245.80155,238.06299 267.29134,240.22536 282.438,253.76183 C 299.52394,258.59567 310.08927,275.78366 295.39762,289.93827 C 298.94588,304.03742 292.54903,321.6244 289.93715,337.16017 C 278.51909,356.2747 292.73993,376.18783 309.33405,385.30202 C 313.65263,407.67285 287.14409,394.36219 275.71731,391.48441 C 260.84112,389.40428 250.51246,374.97195 260.19241,361.87832 C 261.27126,344.49092 263.85189,326.74433 259.40604,309.69521 C 257.08074,299.89268 265.30058,279.83135 249.8705,289.28304 C 236.68476,288.01966 223.42917,279.26247 210.09004,284.32363 C 197.57182,299.06507 191.69147,317.89165 180.59757,333.39344 C 175.89821,346.24998 171.80041,359.44265 155.36011,356.73483 C 136.17465,361.97053 118.11284,370.88329 98.07399,372.33299 C 72.235605,375.57602 96.62115,400.99427 88.93957,414.97797 C 86.16289,418.03926 81.55,417.41052 77.936648,416.64918 z "
-       id="path3723"
-       sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc" />
-    <path
-       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;opacity:1"
-       d="M 279.0423,191.87383 L 330.33071,-14.440493 C 304.24885,-21.480848 277.5851,-19.962497 250.79521,-25.067388 C 225.00536,-31.478574 192.76761,-48.637795 192.76761,-48.637795 L 175.66896,20.143756 C 175.66896,20.143756 207.91424,37.272644 233.7041,43.683836 C 259.49396,50.095029 296.03668,50.066395 296.03668,50.066395 L 261.84691,187.59917"
-       id="path3725"
-       sodipodi:nodetypes="ccsccscc" />
-  </g>
-  <use
-     x="0"
-     y="0"
-     xlink:href="#g3727"
-     id="use3731"
-     width="503"
-     height="470"
-     transform="translate(-18.6911,0)"
-     style="opacity:0.7" />
-  <use
-     x="0"
-     y="0"
-     xlink:href="#use3731"
-     id="use3733"
-     transform="translate(-18.6911,0)"
-     width="503"
-     height="470"
-     style="opacity:0.7" />
-  <use
-     x="0"
-     y="0"
-     xlink:href="#use3733"
-     id="use3735"
-     transform="translate(-18.6911,0)"
-     width="503"
-     height="470"
-     style="opacity:0.7" />
-  <use
-     x="0"
-     y="0"
-     xlink:href="#use3735"
-     id="use3737"
-     transform="translate(-18.6911,0)"
-     width="503"
-     height="470"
-     style="opacity:0.7" />
-  <g
-     id="g3739"
-     transform="matrix(0.934555,0,0,0.934555,55.17645,61.98067)">
-    <path
-       sodipodi:nodetypes="ccccscccscccccccccccccccccccccccccc"
-       id="path1873"
-       d="M 97.936648,416.64918 C 86.929291,403.69748 67.183112,391.08021 67.468568,373.29631 C 81.580167,359.55032 101.18305,352.59514 117.68777,341.87372 C 130.74595,338.06729 138.44307,325.60734 151.14032,321.25949 C 155.23774,323.22955 158.01636,322.87548 160.0172,321.10616 C 165.99641,315.81884 165.02996,297.89311 171.55592,291.58386 C 180.41708,277.70343 179.66836,263.16374 171.9131,249.96044 C 175.45664,243.72563 186.71663,233.58495 173.20463,230.91525 C 170.00252,215.17855 195.41335,202.075 195.86122,197.3583 C 196.33392,192.38001 181.41329,172.43211 184.3281,159.50104 C 196.9793,149.65115 189.78762,127.26772 205.31798,119.25569 C 212.29054,113.20477 230.4602,112.16805 232.11472,108.77965 C 221.12352,97.080172 216.85491,76.451388 228.74212,64.292723 C 244.70534,54.897624 273.66981,63.271708 269.38462,85.387324 C 266.46527,97.938613 275.64422,119.85276 255.95305,120.95585 C 250.47567,135.53763 269.4295,147.25179 273.87515,160.6006 C 285.05211,172.03304 301.81019,176.78954 316.25889,178.5893 C 330.67702,185.99278 308.95145,207.16258 296.86491,208.87501 C 286.07803,212.64746 280.99023,200.43911 268.56706,199.24357 C 258.83475,180.87439 248.23756,204.15442 245.12821,214.88295 C 233.65178,221.44238 238.19122,227.13612 249.18395,228.95525 C 265.80155,238.06299 287.29134,240.22536 302.438,253.76183 C 319.52394,258.59567 330.08927,275.78366 315.39762,289.93827 C 318.94588,304.03742 312.54903,321.6244 309.93715,337.16017 C 298.51909,356.2747 312.73993,376.18783 329.33405,385.30202 C 333.65263,407.67285 307.14409,394.36219 295.71731,391.48441 C 280.84112,389.40428 270.51246,374.97195 280.19241,361.87832 C 281.27126,344.49092 283.85189,326.74433 279.40604,309.69521 C 277.08074,299.89268 285.30058,279.83135 269.8705,289.28304 C 256.68476,288.01966 243.42917,279.26247 230.09004,284.32363 C 217.57182,299.06507 211.69147,317.89165 200.59757,333.39344 C 195.89821,346.24998 191.80041,359.44265 175.36011,356.73483 C 156.17465,361.97053 138.11284,370.88329 118.07399,372.33299 C 92.235605,375.57602 116.62115,400.99427 108.93957,414.97797 C 106.16289,418.03926 101.55,417.41052 97.936648,416.64918 z "
-       style="fill:red;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    <path
-       sodipodi:nodetypes="ccsccscc"
-       id="path3671"
-       d="M 299.0423,191.87383 L 350.33071,-14.440493 C 324.24885,-21.480848 297.5851,-19.962497 270.79521,-25.067388 C 245.00536,-31.478574 212.76761,-48.637795 212.76761,-48.637795 L 195.66896,20.143756 C 195.66896,20.143756 227.91424,37.272644 253.7041,43.683836 C 279.49396,50.095029 316.03668,50.066395 316.03668,50.066395 L 281.84691,187.59917"
-       style="fill:blue;fill-opacity:1;stroke:black;stroke-width:8;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
-  </g>
-</svg>

Deleted: trunk/misc/spherefunc2skybox.c
===================================================================
--- trunk/misc/spherefunc2skybox.c	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/spherefunc2skybox.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,269 +0,0 @@
-#include <stdio.h>
-#include <err.h>
-#include <stdint.h>
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-
-double rnd()
-{
-	return rand() / (RAND_MAX + 1.0);
-}
-
-typedef void (*mapfunc_t) (double x_in, double y_in, double *x_out, double *y_out, double *z_out);
-typedef void (*colorfunc_t) (double x, double y, double z, double *r, double *g, double *b);
-
-void color_test(double x, double y, double z, double *r, double *g, double *b)
-{
-	// put in a nice function here
-	*r = 0.5 + 0.5 * x;
-	*g = 0.5 + 0.5 * y;
-	*b = 0.5 + 0.5 * z;
-}
-
-double mandelbrot_iter(double zx, double zy, double cx, double cy, int maxiter)
-{
-	double tmp;
-	int i;
-
-	double f, fprev;
-
-	f = 0;
-
-	for(i = 1; i < maxiter; ++i)
-	{
-		tmp = zx;
-		zx = zx * zx - zy * zy + cx;
-		zy = 2 * tmp * zy + cy;
-		fprev = f;
-		f = zx * zx + zy * zy;
-		if(f > 4)
-			break;
-	}
-
-	if(i >= maxiter)
-		return i;
-	else
-	{
-		// f: the greater, the more in 0 direction
-		//    the smaller, the more in 1 direction
-		// fprev:
-		//    the greater, the more in 0 direction
-		return i + 1 / (f - 4 + 1); // f = 16: + 0, f = 4: + 1
-	}
-	// i.e. 0 for i=1, 1 for i=maxiter
-}
-
-double mandelbrot_range(double zx, double zy, double cx, double cy, int maxiter, double offset)
-{
-	double i = mandelbrot_iter(zx, zy, cx, cy, maxiter);
-	// map linearily 1/(offset + iter) so that:
-	//   0       -> 0
-	//   maxiter -> 1
-	// i.e. solve:
-	//   f(iter) = A/(offset + iter) + B
-	// that is:
-	//   f(0)       = A/offset + B = 0
-	//   f(maxiter) = A/(offset + maxiter) + B = 1
-	// -->
-	//   1/(1/(offset + maxiter) - 1/offset) = A
-	//   B =          1 + offset / maxiter
-	//   A = -offset (1 + offset / maxiter)
-	// -->
-	//   f(iter) = -offset (1 + offset / maxiter) / (offset + iter) + 1 + offset / maxiter
-	//           = -offset (1 + offset / maxiter) / (offset + iter) + 1 + offset / maxiter
-	//           = iter (offset + maxiter)   /   maxiter (offset + iter)
-	return (i * (offset + maxiter)) / ((i + offset) * maxiter);
-}
-
-double color_mandelbrot_parms[13];
-double mandelbrot_miniter = -1;
-#define MAXITER 8192
-
-double iter_mandelbrot_raw(double x, double y, double z)
-{
-	z -= color_mandelbrot_parms[6];
-	x /= fabs(z);
-	y /= fabs(z);
-
-	if(z > 0)
-		return mandelbrot_range(color_mandelbrot_parms[4], color_mandelbrot_parms[5], color_mandelbrot_parms[0] + x * color_mandelbrot_parms[2], color_mandelbrot_parms[1] + y * color_mandelbrot_parms[3], MAXITER, color_mandelbrot_parms[9]);
-	else
-		return 0;
-}
-
-void iter_mandelbrot_raw_initialize_min()
-{
-	if(mandelbrot_miniter >= 0)
-		return;
-	// randomly sample 256 points
-	// mandelbrot them
-	// set that as miniter
-	int i = 0;
-	double x, y, z;
-	mandelbrot_miniter = MAXITER;
-	for(i = 0; i < 8192; ++i)
-	{
-		x = rnd() * 2 - 1;
-		y = rnd() * 2 - 1;
-		z = rnd() * 2 - 1;
-		double f = sqrt(x*x + y*y + z*z);
-		x /= f;
-		y /= f;
-		z /= f;
-		double a = (z - color_mandelbrot_parms[6]) / (color_mandelbrot_parms[7] - color_mandelbrot_parms[6]);
-		a = (a - color_mandelbrot_parms[8]) / (1 - color_mandelbrot_parms[8]);
-		if(a < 1)
-			continue;
-		double iterations = iter_mandelbrot_raw(x, y, z);
-		if(iterations == 0)
-			continue;
-		if(iterations < mandelbrot_miniter)
-			mandelbrot_miniter = iterations;
-	}
-}
-
-void color_mandelbrot(double x, double y, double z, double *r, double *g, double *b)
-{
-	iter_mandelbrot_raw_initialize_min();
-
-	double iterations = iter_mandelbrot_raw(x, y, z);
-	//printf("iter = %f\n", iterations);
-	double a = (z - color_mandelbrot_parms[6]) / (color_mandelbrot_parms[7] - color_mandelbrot_parms[6]);
-	a = (a - color_mandelbrot_parms[8]) / (1 - color_mandelbrot_parms[8]);
-	if(a < 0)
-		a = 0;
-	if(a > 1)
-		a = 1;
-	iterations = iterations * a + mandelbrot_miniter * (1-a);
-	*r = pow(iterations, color_mandelbrot_parms[10]);
-	*g = pow(iterations, color_mandelbrot_parms[11]);
-	*b = pow(iterations, color_mandelbrot_parms[12]);
-}
-
-void map_back(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
-{
-	*x_out = 2 * x_in - 1;
-	*y_out = +1;
-	*z_out = 1 - 2 * y_in;
-}
-
-void map_right(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
-{
-	*x_out = +1;
-	*y_out = 1 - 2 * x_in;
-	*z_out = 1 - 2 * y_in;
-}
-
-void map_front(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
-{
-	*x_out = 1 - 2 * x_in;
-	*y_out = -1;
-	*z_out = 1 - 2 * y_in;
-}
-
-void map_left(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
-{
-	*x_out = -1;
-	*y_out = 2 * x_in - 1;
-	*z_out = 1 - 2 * y_in;
-}
-
-void map_up(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
-{
-	*x_out = 2 * y_in - 1;
-	*y_out = 1 - 2 * x_in;
-	*z_out = +1;
-}
-
-void map_down(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
-{
-	*x_out = 1 - 2 * y_in;
-	*y_out = 1 - 2 * x_in;
-	*z_out = -1;
-}
-
-void writepic(colorfunc_t f, mapfunc_t m, const char *fn, int width, int height)
-{
-	int x, y;
-	uint8_t tga[18];
-
-	FILE *file = fopen(fn, "wb");
-	if(!file)
-		err(1, "fopen %s", fn);
-
-	memset(tga, 0, sizeof(tga));
-	tga[2] = 2;          // uncompressed type
-	tga[12] = (width >> 0) & 0xFF;
-	tga[13] = (width >> 8) & 0xFF;
-	tga[14] = (height >> 0) & 0xFF;
-	tga[15] = (height >> 8) & 0xFF;
-	tga[16] = 24;        // pixel size
-
-	fwrite(&tga, sizeof(tga), 1, file);
-	for(y = height-1; y >= 0; --y)
-		for(x = 0; x < width; ++x)
-		{
-			uint8_t rgb[3];
-			double rr, gg, bb;
-			double xx, yy;
-			double xxx, yyy, zzz;
-			double r;
-			xx = (x + 0.5) / width;
-			yy = (y + 0.5) / height;
-			m(xx, yy, &xxx, &yyy, &zzz);
-			r = sqrt(xxx*xxx + yyy*yyy + zzz*zzz);
-			xxx /= r;
-			yyy /= r;
-			zzz /= r;
-			f(xxx, yyy, zzz, &rr, &gg, &bb);
-			rgb[2] = floor(rnd() + rr * 255);
-			rgb[1] = floor(rnd() + gg * 255);
-			rgb[0] = floor(rnd() + bb * 255);
-			fwrite(rgb, sizeof(rgb), 1, file);
-		}
-	
-	fclose(file);
-}
-
-void map_all(const char *fn, colorfunc_t f, int width, int height)
-{
-	char buf[1024];
-	snprintf(buf, sizeof(buf), "%s_bk.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_back, buf, width, height);
-	snprintf(buf, sizeof(buf), "%s_ft.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_front, buf, width, height);
-	snprintf(buf, sizeof(buf), "%s_rt.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_right, buf, width, height);
-	snprintf(buf, sizeof(buf), "%s_lf.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_left, buf, width, height);
-	snprintf(buf, sizeof(buf), "%s_up.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_up, buf, width, height);
-	snprintf(buf, sizeof(buf), "%s_dn.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_down, buf, width, height);
-}
-
-int main(int argc, char **argv)
-{
-	colorfunc_t f;
-	if(argc < 4)
-		errx(1, "usage: %s filename res func parms...", *argv);
-	int res = atoi(argv[2]);
-	if(!strcmp(argv[3], "mandel"))
-	{
-		f = color_mandelbrot;
-		color_mandelbrot_parms[0]  = argc<= 4 ?  -0.740 :  atof(argv[4]); // shift xy
-		color_mandelbrot_parms[1]  = argc<= 5 ?  -0.314 :  atof(argv[5]);
-		color_mandelbrot_parms[2]  = argc<= 6 ?  -0.003 :  atof(argv[6]); // mul xy
-		color_mandelbrot_parms[3]  = argc<= 7 ?  -0.003 :  atof(argv[7]);
-		color_mandelbrot_parms[4]  = argc<= 8 ?   0.420 :  atof(argv[8]); // shift z
-		color_mandelbrot_parms[5]  = argc<= 9 ?   0.000 :  atof(argv[9]);
-		color_mandelbrot_parms[6]  = argc<=10 ?  -0.8   : atof(argv[10]); // horizon
-		color_mandelbrot_parms[7]  = argc<=11 ?  -0.7   : atof(argv[11]);
-		color_mandelbrot_parms[8]  = argc<=12 ?   0.5   : atof(argv[12]);
-		color_mandelbrot_parms[9]  = argc<=13 ? 400     : atof(argv[13]); // coloring
-		color_mandelbrot_parms[10] = argc<=14 ?   0.6   : atof(argv[14]);
-		color_mandelbrot_parms[11] = argc<=15 ?   0.5   : atof(argv[15]);
-		color_mandelbrot_parms[12] = argc<=16 ?   0.2   : atof(argv[16]);
-	}
-	else
-	{
-		f = color_test;
-	}
-	map_all(argv[1], color_mandelbrot, res, res);
-	return 0;
-}

Deleted: trunk/misc/testbuild.sh
===================================================================
--- trunk/misc/testbuild.sh	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/testbuild.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-cd nexuiz
-../darkplaces/nexuiz-glx "$@"

Copied: trunk/misc/tools (from rev 5536, trunk/tools)

Copied: trunk/misc/tools/assault-circuit-board-creator.pl (from rev 5536, trunk/misc/assault-circuit-board-creator.pl)
===================================================================
--- trunk/misc/tools/assault-circuit-board-creator.pl	                        (rev 0)
+++ trunk/misc/tools/assault-circuit-board-creator.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,278 @@
+#!/usr/bin/perl
+
+# script that creates an "assault circuit"
+
+use strict;
+use warnings;
+
+my @objectives = @ARGV;
+
+if(!@objectives)
+{
+	print STDERR <<EOF;
+Assault Circuit Board Creator
+
+Usage: 
+  [brushprimit=1 \\]
+  [ofs_x=offset \\]
+  [ofs_y=offset \\]
+  [ofs_z=offset \\]
+  perl $0 breakables1[,buttons1] breakables2[,buttons2] breakables3[,buttons3] ... \\
+  > file.map
+
+Example:
+  ofs_z=1024 perl $0 1 1 3,2 1 > assault.map
+EOF
+	exit 1;
+}
+
+my $bp = $ENV{brushprimit};
+my @ofs = ($ENV{ofs_x} || 0, $ENV{ofs_y} || 0, $ENV{ofs_z} || 0);
+
+my $BRUSHDEF_START = $bp ? "{\nbrushDef\n{" : "{";
+my $BRUSHDEF_END   = $bp ? "}\n}" : "}";
+my $BRUSHDEF_PRE   = $bp ? "( ( 0.03125 0 -0 ) ( -0 0.03125 0 ) ) " : "";
+my $BRUSHDEF_POST  = $bp ? " 0 0 0" : " 0 0 0 0.500000 0.500000 0 0 0";
+
+sub BrushRectangle($@@)
+{
+    my ($shader, $x0, $y0, $z0, $x1, $y1, $z1) = @_;
+    return <<EOF;
+$BRUSHDEF_START
+( $x1 $y1 $z1 ) ( $x1 $y0 $z1 ) ( $x0 $y1 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
+( $x1 $y1 $z1 ) ( $x0 $y1 $z1 ) ( $x1 $y1 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
+( $x1 $y1 $z1 ) ( $x1 $y1 $z0 ) ( $x1 $y0 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
+( $x0 $y0 $z0 ) ( $x1 $y0 $z0 ) ( $x0 $y1 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
+( $x0 $y0 $z0 ) ( $x0 $y0 $z1 ) ( $x1 $y0 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
+( $x0 $y0 $z0 ) ( $x0 $y1 $z0 ) ( $x0 $y0 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
+$BRUSHDEF_END
+EOF
+}
+
+sub Entity(%)
+{
+	my (%h) = @_;
+	my @brushes = ();
+	if(ref $h{model} eq 'ARRAY')
+	{
+		@brushes = @{$h{model}};
+		delete $h{model};
+	}
+	return join "", ("{\n", (map { qq{"$_" "$h{$_}"\n} } keys %h), @brushes, "}\n");
+	# "
+}
+
+sub FindDamage($)
+{
+	my ($cnt) = @_;
+
+	my $dmg;
+
+	# 1. divisible by 10?
+	$dmg = (1 + int(10 / $cnt)) * 10;
+	return $dmg
+		if $dmg * ($cnt - 1) < 100;
+
+	# 2. divisible by 5?
+	$dmg = (1 + int(20 / $cnt)) * 5;
+	return $dmg
+		if $dmg * ($cnt - 1) < 100;
+
+	# 3. divisible by 2?
+	$dmg = (1 + int(50 / $cnt)) * 2;
+	return $dmg
+		if $dmg * ($cnt - 1) < 100;
+
+	# 4. divisible by 1?
+	$dmg = (1 + int(100 / $cnt));
+	return $dmg
+		if $dmg * ($cnt - 1) < 100;
+
+	# 5. give up
+	return (100 / $cnt + 100 / ($cnt + 1)) / 2;
+}
+
+sub ObjectiveSpawns($@)
+{
+	my ($target, $x, $y, $z) = @_;
+
+	my @l = ();
+
+	$z -= 64;
+
+	for(1..6)
+	{
+		my $xx = $x - 32;
+		my $yy = $y + ($_ - 3.5) * 64;
+		my $zz = $z - 8 - 32; # align feet to 64-grid
+		push @l, Entity
+			classname => "info_player_attacker",
+			target => $target,
+			origin => "$xx $yy $zz";
+
+		$xx = $x + 32;
+		push @l, Entity
+			classname => "info_player_defender",
+			target => $target,
+			origin => "$xx $yy $zz";
+	}
+
+	return @l;
+}
+
+my @assault_entities = ();
+
+my $obj_prev = undef;
+my $des_prev = undef;
+
+my @prevorigin = @ofs;
+
+for my $i(0.. at objectives - 1)
+{
+	my @origin =
+	(
+		$ofs[0] + ($i + 1) * 256,
+		$ofs[1] + 0,
+		$ofs[2] + 0
+	);
+
+	my $count = $objectives[$i];
+	$count =~ /^(\d+)(?:,(\d+))?$/s
+		or die "Invalid count spec: must be number or number,number";
+	my $count_destroy = $1;
+	my $count_push = $2 || 0;
+	$count = $count_destroy + $count_push;
+
+	my $obj = "obj$i";
+	my $des = "obj$i\_destructible";
+	my $dec = "obj$i\_decrease";
+
+	if($i == 0)
+	{
+		push @assault_entities, Entity
+			classname => "target_assault_roundstart",
+			target => $obj,
+			target2 => $des,
+			origin => "@prevorigin";
+	}
+	else
+	{
+		push @assault_entities, Entity
+			classname => "target_objective",
+			targetname => $obj_prev,
+			target => $obj,
+			target2 => $des,
+			origin => "@prevorigin";
+
+		push @assault_entities, ObjectiveSpawns $obj_prev, @prevorigin;
+
+		push @assault_entities, Entity
+			classname => "func_assault_wall",
+			target => $obj_prev,
+			model => [
+				BrushRectangle
+					"dsi/dsiglass",
+					$origin[0] - 128 - 32,
+					$origin[1] - 512,
+					$origin[2] - 512,
+					$origin[0] - 128 + 32,
+					$origin[1] + 512,
+					$origin[2] + 512
+			];
+	}
+
+	@prevorigin = @origin;
+
+	$origin[2] += 64;
+
+	my $dmg = FindDamage($count);
+
+	push @assault_entities, Entity
+		classname => "target_objective_decrease",
+		targetname => $dec,
+		target => $obj,
+		dmg => $dmg,
+		origin => "@origin";
+
+	$origin[2] += 64;
+
+	for(1..$count_destroy)
+	{
+		push @assault_entities, Entity
+			classname => "func_assault_destructible",
+			targetname => $des,
+			target => $dec,
+			health => 1000,
+			mdl => "rocket_explode",
+			count => 1,
+			noise => "weapons/rocket_impact.wav",
+			dmg => 50,
+			dmg_edge => 0,
+			dmg_radius => 150,
+			dmg_force => 200,
+			model => [
+				BrushRectangle
+					"dsi/cretebase",
+					$origin[0] - 16,
+					$origin[1] - 16,
+					$origin[2] - 16,
+					$origin[0] + 16,
+					$origin[1] + 16,
+					$origin[2] + 16
+			];
+
+		$origin[2] += 64;
+	}
+
+	for(1..$count_push)
+	{
+		push @assault_entities, Entity
+			classname => "func_button",
+			target => $dec,
+			angle => -2,
+			model => [
+				BrushRectangle
+					"dsi/dablue",
+					$origin[0] - 16,
+					$origin[1] - 16,
+					$origin[2] - 16,
+					$origin[0] + 16,
+					$origin[1] + 16,
+					$origin[2] + 16
+			];
+
+		$origin[2] += 64;
+	}
+
+	$obj_prev = $obj;
+	$des_prev = $des;
+}
+
+my $obj = "roundend";
+my @origin =
+(
+	$ofs[0] + (@objectives + 1) * 256,
+	$ofs[1] + 0,
+	$ofs[2] + 0
+);
+
+push @assault_entities, Entity
+	classname => "target_objective",
+	targetname => $obj_prev,
+	target => $obj,
+	origin => "@prevorigin";
+
+push @assault_entities, ObjectiveSpawns $obj_prev, @prevorigin;
+
+push @assault_entities, Entity
+	classname => "target_assault_roundend",
+	targetname => $obj,
+	origin => "@origin";
+
+my $map = join "",
+(
+	Entity(classname => "worldspawn"),
+	@assault_entities
+);
+
+print $map;

Copied: trunk/misc/tools/autoshader.sh (from rev 5536, trunk/misc/autoshader.sh)
===================================================================
--- trunk/misc/tools/autoshader.sh	                        (rev 0)
+++ trunk/misc/tools/autoshader.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,195 @@
+#!/bin/sh
+
+if ! [ -d "textures" ] && ! [ -d "env" ]; then
+	echo "Sorry, must be run from a directory with a textures subfolder. Giving up."
+	exit 1
+fi
+
+case "$0" in
+	*/*)
+		mydir=${0%/*}
+		;;
+	*)
+		mydir=.
+		;;
+esac
+
+makeshader()
+{
+	s=`texnormalize "$1"`
+	dir=${s#textures/}
+	dir=${dir%%/*}
+	echo scripts/$dir.shader
+	mkdir -p scripts
+	cat <<EOF >>"scripts/$dir.shader"
+$s
+{
+	qer_editorimage $1
+	qer_trans 0.5
+	// maybe: surfaceparm nonsolid
+	surfaceparm trans
+	surfaceparm alphashadow
+	surfaceparm nomarks
+	cull disable
+	{
+		map $s
+		blendfunc blend
+		// or: alphafunc GE128
+	}
+	{
+		map \$lightmap
+		blendfunc filter
+		rgbGen identity
+	}
+}
+EOF
+}
+
+makeskyshader()
+{
+	coords=`sh "$mydir/brightspot.sh" "$1"`
+	s=`texnormalize "$1"`
+	case "$coords" in
+		*\ *)
+			;;
+		*)
+			coords="-42 -42"
+			echo >&2 "NOTE: brightspot tool did not work"
+			;;
+	esac
+	s=${s%_up}
+	s=${s#env/}
+	dir=${s%%/*}
+	echo >&2 "appending to scripts/$dir.shader"
+	echo scripts/$dir.shader
+	mkdir -p scripts
+	cat <<EOF >>"scripts/$dir.shader"
+textures/$s
+{
+	qer_editorimage $1
+	surfaceparm noimpact
+	surfaceparm nolightmap
+	surfaceparm sky
+	surfaceparm nomarks
+	q3map_sunExt .5 .5 .7 $coords 2 16 // red green blue intensity degrees elevation deviance samples
+	q3map_surfacelight 150 // intensity
+	skyparms env/$s - -
+}
+EOF
+}
+
+texnormalize()
+{
+	echo "$1" | sed 's/\.[Jj][Pp][Gg]$\|\.[Tt][Gg][Aa]$\|\.[Pp][Nn][Gg]$//;'
+}
+
+allshadernames() # prints all shader names or texture names
+{
+	cat scripts/*.shader 2>/dev/null | tr '\r' '\n' | {
+		mode=root
+		while IFS= read -r LINE; do
+			LINE=`echo "$LINE" | sed 's,//.*,,; s/\s\+/ /g; s/^ //; s/ $//; s/"//g;'`
+			[ -n "$LINE" ] || continue
+			set -- $LINE
+			case "$mode:$1" in
+				root:'{')
+					mode=shader
+					;;
+				root:*)
+					texnormalize "$1"
+					;;
+
+				shader:'{')
+					mode=stage
+					;;
+				shader:'}')
+					mode=root
+					;;
+				shader:skyparms)
+					echo "`texnormalize "$1"`_up"
+					;;
+
+				stage:'}')
+					mode=shader
+					;;
+				stage:map)
+					texnormalize "$2"
+					;;
+				stage:clampmap)
+					texnormalize "$2"
+					;;
+				stage:animmap)
+					shift
+					shift
+					for X in "$@"; do
+						texnormalize "$X"
+					done
+					;;
+			esac
+		done
+	}
+}
+
+allshaders=`allshadernames`
+lf="
+"
+
+has_shader()
+{
+	sh=`texnormalize "$1"`
+	case "$lf$allshaders$lf" in
+		*"$lf$sh$lf"*)
+			return 0
+			;;
+	esac
+	return 1
+}
+
+has_alpha()
+{
+	convert "$1" -depth 8 RGBA:- | xxd -c 4 -g 1 | grep -v " ff  " >/dev/null
+}
+
+autoshaders()
+{
+	{
+		[ -d "textures" ] && find textures -type f \( -iname \*.tga -o -iname \*.png \) -print | while IFS= read -r TEX; do
+			case `texnormalize "$TEX"` in
+				*_norm|*_shirt|*_pants|*_glow|*_gloss|*_bump)
+					# ignore these (they are used implicitly)
+					continue
+					;;
+			esac
+			if has_shader "$TEX"; then
+				echo>&2 "    $TEX has an associated shader, ignoring."
+			else
+				if has_alpha "$TEX"; then
+					echo>&2 "*** $TEX has alpha but no shader, creating default alpha shader."
+					makeshader "$TEX"
+				else
+					echo>&2 "    $TEX has no shader and no alpha, fine."
+				fi
+			fi
+		done
+		[ -d "env" ] && find env -type f \( -iname \*_up.tga -o -iname \*_up.png -o -iname \*_up.jpg \) -print | while IFS= read -r TEX; do
+			if has_shader "$TEX"; then
+				echo>&2 "    $TEX has an associated shader, ignoring."
+			else
+				echo>&2 "*** $TEX is sky but has no shader, creating default sky shader."
+				makeskyshader "$TEX"
+			fi
+		done
+	} | sort -u
+}
+
+aashaders=`autoshaders`
+
+if [ -n "$aashaders" ]; then
+	cat <<EOF
+The following shader files have been automatically created or appended to:
+
+$aashaders
+
+Please edit them to your needs, and possibly rename them.
+EOF
+fi

Copied: trunk/misc/tools/brightspot.c (from rev 5536, trunk/misc/brightspot.c)
===================================================================
--- trunk/misc/tools/brightspot.c	                        (rev 0)
+++ trunk/misc/tools/brightspot.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,195 @@
+#include <stdio.h>
+#include <math.h>
+
+// USAGE: see brightspot.sh (and in the future brightspot.bat)
+// It should output the right parameters for the sun direction in q3map2's format.
+// But probably is broken.
+
+#define false 0
+#define true 1
+
+int flip[6*3] =
+{
+	false, false,  true, // "rt"
+	 true,  true,  true, // "lf"
+	false,  true, false, // "bk"
+	 true, false, false, // "ft"
+	false, false,  true, // "up"
+	false, false,  true  // "dn"
+};
+
+static const double skyboxtexcoord2f[6*4*2] =
+{
+    // skyside[0]
+    0, 1,
+    1, 1,
+    1, 0,
+    0, 0,
+    // skyside[1]
+    1, 0,
+    0, 0,
+    0, 1,
+    1, 1,
+    // skyside[2]
+    1, 1,
+    1, 0,
+    0, 0,
+    0, 1,
+    // skyside[3]
+    0, 0,
+    0, 1,
+    1, 1,
+    1, 0,
+    // skyside[4]
+    0, 1,
+    1, 1,
+    1, 0,
+    0, 0,
+    // skyside[5]
+    0, 1,
+    1, 1,
+    1, 0,
+    0, 0
+};
+
+
+static const double skyboxvertex3f[6*4*3] =
+{
+        // skyside[0]
+         16, -16,  16,
+         16, -16, -16,
+         16,  16, -16,
+         16,  16,  16,
+        // skyside[1]
+        -16,  16,  16,
+        -16,  16, -16,
+        -16, -16, -16,
+        -16, -16,  16,
+        // skyside[2]
+         16,  16,  16,
+         16,  16, -16,
+        -16,  16, -16,
+        -16,  16,  16,
+        // skyside[3]
+        -16, -16,  16,
+        -16, -16, -16,
+         16, -16, -16,
+         16, -16,  16,
+        // skyside[4]
+        -16, -16,  16,
+         16, -16,  16,
+         16,  16,  16,
+        -16,  16,  16,
+        // skyside[5]
+         16, -16, -16,
+        -16, -16, -16,
+        -16,  16, -16,
+         16,  16, -16
+};
+
+void Unmap2f(double x, double y, const double *corners, double *u, double *v)
+{
+	// x - corners[0] == *u * (corners[2] - corners[0]) + *v * (corners[4] - corners[2]);
+	// y - corners[1] == *u * (corners[3] - corners[1]) + *v * (corners[5] - corners[3]);
+	
+	double xc0 = x - corners[0];
+	double yc1 = y - corners[1];
+	double c20 = corners[2] - corners[0];
+	double c31 = corners[3] - corners[1];
+	double c42 = corners[4] - corners[2];
+	double c53 = corners[5] - corners[3];
+
+	// xc0 == *u * c20 + *v * c42;
+	// yc1 == *u * c31 + *v * c53;
+
+	double det = c20 * c53 - c31 * c42;
+	double du = xc0 * c53 - yc1 * c42;
+	double dv = c20 * yc1 - c31 * xc0;
+
+	*u = du / det;
+	*v = dv / det;
+}
+
+void Map3f(double u, double v, const double *corners, double *x, double *y, double *z)
+{
+	*x = corners[0] + u * (corners[3] - corners[0]) + v * (corners[6] - corners[3]);
+	*y = corners[1] + u * (corners[4] - corners[1]) + v * (corners[7] - corners[4]);
+	*z = corners[2] + u * (corners[5] - corners[2]) + v * (corners[8] - corners[5]);
+}
+
+void MapCoord(int pic, int y, int x, double vec[3])
+{
+	int h;
+	int flipx = flip[3*pic+0];
+	int flipy = flip[3*pic+1];
+	int flipdiag = flip[3*pic+2];
+	double u, v;
+
+	if(flipx)
+		x = 511 - x;
+
+	if(flipy)
+		y = 511 - y;
+
+	if(flipdiag)
+	{
+		h = x; x = y; y = h;
+	}
+
+	Unmap2f((x + 0.5) / 512.0, (y + 0.5) / 512.0, skyboxtexcoord2f + 4*2*pic, &u, &v);
+	Map3f(u, v, skyboxvertex3f + 6*2*pic, &vec[0], &vec[1], &vec[2]);
+}
+
+int main(int argc, char **argv)
+{
+	FILE *f;
+	int i, j, k;
+	unsigned char picture[6][512][512];
+	unsigned char max;
+	double brightvec[3];
+	double pitch, yaw, l;
+
+	if(argc != 2)
+	{
+		fprintf(stderr, "Usage: %s imagefile.gray\n", *argv);
+		return 1;
+	}
+
+	f = fopen(argv[1], "rb");
+	if(!f)
+	{
+		perror("fopen");
+		return 1;
+	}
+	fread(&picture, sizeof(picture), 1, f);
+	fclose(f);
+
+	brightvec[0] = brightvec[1] = brightvec[2] = 0;
+	max = 0;
+	for(i = 0; i < 6; ++i)
+		for(j = 0; j < 512; ++j)
+			for(k = 0; k < 512; ++k)
+				if(picture[i][j][k] > max)
+					max = picture[i][j][k];
+	for(i = 0; i < 6; ++i)
+		for(j = 0; j < 512; ++j)
+			for(k = 0; k < 512; ++k)
+			{
+				double vec[3], f;
+				MapCoord(i, j, k, vec);
+				f = pow(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2], -1.5); // I know what I am doing.
+				f *= exp(10 * (picture[i][j][k] - max));
+				brightvec[0] += f * vec[0];
+				brightvec[1] += f * vec[1];
+				brightvec[2] += f * vec[2];
+			}
+
+	l = sqrt(brightvec[0]*brightvec[0] + brightvec[1]*brightvec[1] + brightvec[2]*brightvec[2]);
+	fprintf(stderr, "vec = %f %f %f\n", brightvec[0] / l, brightvec[1] / l, brightvec[2] / l);
+	
+	pitch = atan2(brightvec[2], sqrt(brightvec[0]*brightvec[0] + brightvec[1]*brightvec[1]));
+	yaw = atan2(brightvec[1], brightvec[0]);
+
+	printf("%f %f\n", yaw * 180 / M_PI, pitch * 180 / M_PI);
+	return 0;
+}

Copied: trunk/misc/tools/brightspot.sh (from rev 5536, trunk/misc/brightspot.sh)
===================================================================
--- trunk/misc/tools/brightspot.sh	                        (rev 0)
+++ trunk/misc/tools/brightspot.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+if [ -z "$1" ]; then
+	echo>&2 "Usage: $0 foo_rt.jpg"
+	exit 1
+fi
+
+brightspot=
+if which brightspot-bin >/dev/null; then
+	brightspot=brightspot-bin
+else
+	case "$0" in
+		*/*)
+			mydir=${0%/*}
+			;;
+		*)
+			mydir=.
+			;;
+	esac
+	brightspot="$mydir/brightspot-bin"
+	[ "$brightspot" -nt "$mydir/brightspot.c" ] || gcc -lm -O3 -Wall -Wextra "$mydir/brightspot.c" -o "$brightspot" || exit 1
+fi
+
+i=$1
+ext=${i##*.}
+name=${i%.*}
+name=${name%_[rlbfud][tfktpn]}
+
+{
+	convert "$name"_rt."$ext" -depth 8 -geometry 512x512 GRAY:-
+	convert "$name"_lf."$ext" -depth 8 -geometry 512x512 GRAY:-
+	convert "$name"_bk."$ext" -depth 8 -geometry 512x512 GRAY:-
+	convert "$name"_ft."$ext" -depth 8 -geometry 512x512 GRAY:-
+	convert "$name"_up."$ext" -depth 8 -geometry 512x512 GRAY:-
+	convert "$name"_dn."$ext" -depth 8 -geometry 512x512 GRAY:-
+} | "$brightspot" /dev/stdin

Copied: trunk/misc/tools/bsp2ent (from rev 5536, trunk/misc/bsp2ent)
===================================================================
--- trunk/misc/tools/bsp2ent	                        (rev 0)
+++ trunk/misc/tools/bsp2ent	2009-01-15 11:30:44 UTC (rev 5541)
@@ -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;

Copied: trunk/misc/tools/bsptool.pl (from rev 5536, trunk/misc/bsptool.pl)
===================================================================
--- trunk/misc/tools/bsptool.pl	                        (rev 0)
+++ trunk/misc/tools/bsptool.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,515 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Image::Magick;
+use POSIX qw/floor ceil/;
+
+my @lumpname = qw/entities textures planes nodes leafs leaffaces leafbrushes models brushes brushsides vertices triangles effects faces lightmaps lightgrid pvs advertisements/;
+my %lumpid = map { $lumpname[$_] => $_ } 0.. at lumpname-1;
+my $msg = "";
+my @bsp;
+
+# READ THE BSP
+
+if(!@ARGV || $ARGV[0] eq '-h' || $ARGV[0] eq '--help')
+{
+	print <<EOF;
+Usage:
+  $0 filename.bsp [operations...]
+
+Operations are:
+  Information requests:
+    -i                print info about the BSP file
+    -xlumpname        extract a lump (see -i)
+
+  Changes:
+    -dlumpname        delete a lump (see -i)
+    -rlumpname        replace a lump (see -i) by the data from standard input
+    -gfilename.tga    save the lightgrid as filename.tga (debugging)
+    -Gratio           scale down the lightgrid to reduce BSP file size
+    -ljpgNNN          externalize the lightmaps as JPEG, quality NNN (number from 1 to 100)
+    -lpng             externalize the lightmaps as PNG
+    -ltga             externalize the lightmaps as TGA
+    -mMESSAGE         set the BSP file comment message
+
+  Save commands:
+    -o                actually apply the changes to the BSP
+    -ofilename2.bsp   save the changes to a new BSP file
+EOF
+	exit;
+}
+
+my $fn = shift @ARGV;
+$fn =~ /(.*)\.bsp$/
+	or die "invalid input file name (must be a .bsp): $fn";
+my $basename = $1;
+open my $fh, "<", $fn
+	or die "$fn: $!";
+
+read $fh, my $header, 8;
+
+die "Invalid BSP format"
+	if $header ne "IBSP\x2e\x00\x00\x00";
+
+for(0..16)
+{
+	read $fh, my $lump, 8;
+	my ($offset, $length) = unpack "VV", $lump;
+
+	push @bsp, [$offset, $length, undef];
+}
+
+for(@bsp)
+{
+	my ($offset, $length, $data) = @$_;
+	seek $fh, $offset, 0;
+	read $fh, $data, $length;
+	length $data == $length
+		or die "Incomplete BSP lump at $offset\n";
+	$_->[2] = $data;
+}
+
+close $fh;
+
+# STRUCT DECODING
+
+sub DecodeLump($@)
+{
+	my ($lump, @fields) = @_;
+	my @decoded;
+
+	my $spec = "";
+	my @decoders;
+
+	my $item;
+	my @data;
+	my $idx;
+
+	for(@fields)
+	{
+		if(/^(\w*)=(.*?)(\d*)$/)
+		{
+			$spec .= "$2$3 ";
+			my $f = $1;
+			my $n = $3;
+			if($n eq '')
+			{
+				push @decoders, sub { $item->{$f} = $data[$idx++]; };
+			}
+			else
+			{
+				push @decoders, sub { $item->{$f} = [ map { $data[$idx++] } 1..$n ]; };
+			}
+		}
+	}
+
+	my $itemlen = length pack $spec, ();
+	my $len = length $lump;
+
+	die "Invalid lump size: $len not divisible by $itemlen"
+		if $len % $itemlen;
+
+	my $items = $len / $itemlen;
+	for(0..$items - 1)
+	{
+		@data = unpack $spec, substr $lump, $_ * $itemlen, $itemlen;
+		$item = {};
+		$idx = 0;
+		$_->() for @decoders;
+		push @decoded, $item;
+	}
+	@decoded;
+}
+
+sub EncodeLump($@)
+{
+	my ($items, @fields) = @_;
+	my @decoded;
+
+	my @encoders;
+
+	my $item;
+	my @data;
+	my $idx;
+	my $data = "";
+
+	for(@fields)
+	{
+		if(/^(\w*)=(.*?)(\d*)$/)
+		{
+			my $spec = "$2$3";
+			my $f = $1;
+			my $n = $3;
+			if($n eq '')
+			{
+				push @encoders, sub { $data .= pack $spec, $item->{$f}; };
+			}
+			else
+			{
+				push @encoders, sub { $data .= pack $spec, @{$item->{$f}}; };
+			}
+		}
+	}
+
+	for my $i(@$items)
+	{
+		$item = $i;
+		$_->() for @encoders;
+	}
+
+	$data;
+}
+
+sub EncodeDirection(@)
+{
+	my ($x, $y, $z) = @_;
+
+	return [
+		map { ($_ / 0.02454369260617025967) & 0xFF }
+		(
+			atan2(sqrt($x * $x + $y * $y), $z),
+			atan2($y, $x)
+		)
+	];
+}
+
+sub DecodeDirection($)
+{
+	my ($dir) = @_;
+
+	my ($pitch, $yaw) = map { $_ * 0.02454369260617025967 } @$dir; # maps 256 to 2pi
+
+	return (
+		cos($yaw) * sin($pitch),
+		sin($yaw) * sin($pitch),
+		cos($pitch)
+	);
+}
+
+sub IntervalIntersection($$$$)
+{
+	my ($a, $al, $b, $bl) = @_;
+	my $a0 = $a - 0.5 * $al;
+	my $a1 = $a + 0.5 * $al;
+	my $b0 = $b - 0.5 * $bl;
+	my $b1 = $b + 0.5 * $bl;
+	my $left = ($a0 > $b0) ? $a0 : $b0;
+	my $right = ($a1 > $b1) ? $b1 : $a1;
+	die "Non-intersecting intervals $a $al $b $bl"
+		if $right < $left;
+	return $right - $left;
+}
+
+sub BoxIntersection(@)
+{
+	my ($x, $y, $z, $w, $h, $d, $x2, $y2, $z2, $w2, $h2, $d2) = @_;
+	return
+		IntervalIntersection($x, $w, $x2, $w2)
+		*
+		IntervalIntersection($y, $h, $y2, $h2)
+		*
+		IntervalIntersection($z, $d, $z2, $d2);
+}
+
+# OPTIONS
+
+for(@ARGV)
+{
+	if(/^-i$/) # info
+	{
+		my $total = 17 * 8 + 8 + length($msg);
+		my $max = 0;
+		for(0.. at bsp-1)
+		{
+			my $nl = length $bsp[$_]->[2];
+			$total += $nl;
+			print "BSP lump $_ ($lumpname[$_]): offset $bsp[$_]->[0] length $bsp[$_]->[1] newlength $nl\n";
+			my $endpos = $bsp[$_]->[0] + $bsp[$_]->[1];
+			$max = $endpos if $max < $endpos;
+		}
+		print "BSP file size will change from $max to $total bytes\n";
+	}
+	elsif(/^-d(.+)$/) # delete a lump
+	{
+		my $id = $lumpid{$1};
+		die "invalid lump $1 to remove"
+			unless defined $id;
+		$bsp[$id]->[2] = "";
+	}
+	elsif(/^-r(.+)$/) # replace a lump
+	{
+		my $id = $lumpid{$1};
+		die "invalid lump $1 to replace"
+			unless defined $id;
+		$bsp[$id]->[2] = do { undef local $/; scalar <STDIN>; };
+	}
+	elsif(/^-m(.*)$/) # change the message
+	{
+		$msg = $1;
+	}
+	elsif(/^-l(jpg|png|tga)(\d+)?$/) # externalize lightmaps (deleting the internal ones)
+	{
+		my $ext = $1;
+		my $quality = $2;
+		my %lightmaps = ();
+		my $faces = $bsp[$lumpid{faces}]->[2];
+		my $lightmaps = $bsp[$lumpid{lightmaps}]->[2];
+		my @values = DecodeLump $faces,
+			qw/texture=V effect=V type=V vertex=V n_vertexes=V meshvert=V n_meshverts=V lm_index=V lm_start=f2 lm_size=f2 lm_origin=f3 lm_vec_0=f3 lm_vec_1=f3 normal=f3 size=V2/;
+		my $oddfound = 0;
+		for(@values)
+		{
+			my $l = $_->{lm_index};
+			next if $l >= 2**31; # signed
+			$oddfound = 1
+				if $l % 2;
+			++$lightmaps{$l};
+		}
+		if(!$oddfound)
+		{
+			$lightmaps{$_+1} = $lightmaps{$_} for keys %lightmaps;
+		}
+		for(sort { $a <=> $b } keys %lightmaps)
+		{
+			print STDERR "Lightmap $_ was used $lightmaps{$_} times\n";
+
+			# export that lightmap
+			my $lmsize = 128 * 128 * 3;
+			next if length $lightmaps < ($_ + 1) * $lmsize;
+			my $lmdata = substr $lightmaps, $_ * $lmsize, $lmsize;
+			my $img = Image::Magick->new(size => '128x128', depth => 8, magick => 'RGB');
+			$img->BlobToImage($lmdata);
+			my $outfn = sprintf "%s/lm_%04d.$ext", $basename, $_;
+			mkdir $basename;
+			$img->Set(quality => $quality)
+				if defined $quality;
+			my $err = $img->Write($outfn);
+			die $err
+				if $err;
+			print STDERR "Wrote $outfn\n";
+		}
+
+		# nullify the lightmap lump
+		$bsp[$lumpid{lightmaps}]->[2] = "";
+	}
+	elsif(/^-g(.+)$/) # export light grid as an image (for debugging)
+	{
+		my $filename = $1;
+		my @models = DecodeLump $bsp[$lumpid{models}]->[2],
+			qw/mins=f3 maxs=f3 face=V n_faces=V brush=V n_brushes=V/;
+		my $entities = $bsp[$lumpid{entities}]->[2];
+		my @entitylines = split /\r?\n/, $entities;
+		my $gridsize = "64 64 128";
+		for(@entitylines)
+		{
+			last if $_ eq '}';
+			/^\s*"gridsize"\s+"(.*)"$/
+				and $gridsize = $1;
+		}
+		my @scale = map { 1 / $_ } split / /, $gridsize;
+		my @imins = map { ceil($models[0]{mins}[$_] * $scale[$_]) } 0..2;
+		my @imaxs = map { floor($models[0]{maxs}[$_] * $scale[$_]) } 0..2;
+		my @isize = map { $imaxs[$_] - $imins[$_] + 1 } 0..2;
+		my $isize = $isize[0] * $isize[1] * $isize[2];
+		my @gridcells = DecodeLump $bsp[$lumpid{lightgrid}]->[2],
+			qw/ambient=C3 directional=C3 dir=C2/;
+		die "Cannot decode light grid"
+			unless $isize == @gridcells;
+
+		# sum up the "ambient" light over all pixels
+		my @pixels;
+		my $max = 1;
+		for my $y(0..$isize[1]-1)
+		{
+			for my $x(0..$isize[0]-1)
+			{
+				my ($r, $g, $b) = (0, 0, 0);
+				for my $z(0..$isize[2]-1)
+				{
+					my $cell = $gridcells[$x + $y * $isize[0] + $z * $isize[0] * $isize[1]];
+					$r += $cell->{ambient}->[0];
+					$g += $cell->{ambient}->[1];
+					$b += $cell->{ambient}->[2];
+				}
+				push @pixels, [$r, $g, $b];
+				$max = $r if $max < $r;
+				$max = $g if $max < $g;
+				$max = $b if $max < $b;
+			}
+		}
+		my $pixeldata = "";
+		for my $p(@pixels)
+		{
+			$pixeldata .= pack "CCC", map { 255 * $p->[$_] / $max } 0..2;
+		}
+
+		my $img = Image::Magick->new(size => sprintf("%dx%d", $isize[0], $isize[1]), depth => 8, magick => 'RGB');
+		$img->BlobToImage($pixeldata);
+		$img->Write($filename);
+		print STDERR "Wrote $filename\n";
+	}
+	elsif(/^-G(.+)$/) # decimate light grid
+	{
+		my $decimate = $1;
+		my $filter = 1; # 0 = nearest, 1 = box filter
+
+		my @models = DecodeLump $bsp[$lumpid{models}]->[2],
+			qw/mins=f3 maxs=f3 face=V n_faces=V brush=V n_brushes=V/;
+		my $entities = $bsp[$lumpid{entities}]->[2];
+		my @entitylines = split /\r?\n/, $entities;
+		my $gridsize = "64 64 128";
+		my $gridsizeindex = undef;
+		for(0.. at entitylines-1)
+		{
+			my $l = $entitylines[$_];
+			last if $l eq '}';
+			if($l =~ /^\s*"gridsize"\s+"(.*)"$/)
+			{
+				$gridsize = $1;
+				$gridsizeindex = $_;
+			}
+		}
+		my @scale = map { 1 / $_ } split / /, $gridsize;
+		my @imins = map { ceil($models[0]{mins}[$_] * $scale[$_]) } 0..2;
+		my @imaxs = map { floor($models[0]{maxs}[$_] * $scale[$_]) } 0..2;
+		my @isize = map { $imaxs[$_] - $imins[$_] + 1 } 0..2;
+		my $isize = $isize[0] * $isize[1] * $isize[2];
+		my @gridcells = DecodeLump $bsp[$lumpid{lightgrid}]->[2],
+			qw/ambient=C3 directional=C3 dir=C2/;
+		die "Cannot decode light grid"
+			unless $isize == @gridcells;
+
+		# get the new grid size values
+		my @newscale = map { $_ / $decimate } @scale;
+		my $newgridsize = join " ", map { 1 / $_ } @newscale;
+		my @newimins = map { ceil($models[0]{mins}[$_] * $newscale[$_]) } 0..2;
+		my @newimaxs = map { floor($models[0]{maxs}[$_] * $newscale[$_]) } 0..2;
+		my @newisize = map { $newimaxs[$_] - $newimins[$_] + 1 } 0..2;
+
+		# do the decimation
+		my @newgridcells = ();
+		for my $z($newimins[2]..$newimaxs[2])
+		{
+			# the coords are MIDPOINTS of the grid cells!
+			my @oldz = grep { $_ >= $imins[2] && $_ <= $imaxs[2] } floor(($z - 0.5) * $decimate + 0.5) .. ceil(($z + 0.5) * $decimate - 0.5);
+			my $innerz_raw = $z * $decimate;
+			my $innerz = floor($innerz_raw + 0.5);
+			$innerz = $imins[2] if $innerz < $imins[2];
+			$innerz = $imaxs[2] if $innerz > $imaxs[2];
+			for my $y($newimins[1]..$newimaxs[1])
+			{
+				my @oldy = grep { $_ >= $imins[1] && $_ <= $imaxs[1] } floor(($y - 0.5) * $decimate + 0.5) .. ceil(($y + 0.5) * $decimate - 0.5);
+				my $innery_raw = $y * $decimate;
+				my $innery = floor($innery_raw + 0.5);
+				$innery = $imins[1] if $innery < $imins[1];
+				$innery = $imaxs[1] if $innery > $imaxs[1];
+				for my $x($newimins[0]..$newimaxs[0])
+				{
+					my @oldx = grep { $_ >= $imins[0] && $_ <= $imaxs[0] } floor(($x - 0.5) * $decimate + 0.5) .. ceil(($x + 0.5) * $decimate - 0.5);
+					my $innerx_raw = $x * $decimate;
+					my $innerx = floor($innerx_raw + 0.5);
+					$innerx = $imins[0] if $innerx < $imins[0];
+					$innerx = $imaxs[0] if $innerx > $imaxs[0];
+
+					my @vec = (0, 0, 0);
+					my @dir = (0, 0, 0);
+					my @amb = (0, 0, 0);
+					my $weight = 0;
+					my $innercell = $gridcells[($innerx - $imins[0]) + $isize[0] * ($innery - $imins[1]) + $isize[0] * $isize[1] * ($innerz - $imins[2])];
+					for my $Z(@oldz)
+					{
+						for my $Y(@oldy)
+						{
+							for my $X(@oldx)
+							{
+								my $cell = $gridcells[($X - $imins[0]) + $isize[0] * ($Y - $imins[1]) + $isize[0] * $isize[1] * ($Z - $imins[2])];
+
+								my $cellweight = BoxIntersection(
+									$X, $Y, $Z, 1, 1, 1,
+									map { $_ * $decimate } $x, $y, $z, 1, 1, 1
+								);
+
+								$dir[$_] += $cellweight * $cell->{directional}->[$_] for 0..2;
+								$amb[$_] += $cellweight * $cell->{ambient}->[$_] for 0..2;
+								my @norm = DecodeDirection $cell->{dir};
+								$vec[$_] += $cellweight * $norm[$_] for 0..2;
+								$weight += $cellweight;
+							}
+						}
+					}
+					if($weight)
+					{
+						$dir[$_] /= $weight for 0..2;
+						$dir[$_] *= $filter for 0..2;
+						$dir[$_] += (1 - $filter) * $innercell->{directional}->[$_] for 0..2;
+
+						$amb[$_] /= $weight for 0..2;
+						$amb[$_] *= $filter for 0..2;
+						$amb[$_] += (1 - $filter) * $innercell->{ambient}->[$_] for 0..2;
+
+						my @norm = DecodeDirection $innercell->{dir};
+						$vec[$_] /= $weight for 0..2;
+						$vec[$_] *= $filter for 0..2;
+						$vec[$_] += (1 - $filter) * $norm[$_] for 0..2;
+
+						$innercell = {
+							ambient => \@amb,
+							directional => \@dir,
+							dir => EncodeDirection @norm
+						};
+					}
+
+					push @newgridcells, $innercell;
+				}
+			}
+		}
+
+		$bsp[$lumpid{lightgrid}]->[2] = EncodeLump \@newgridcells,
+			qw/ambient=C3 directional=C3 dir=C2/;
+		splice @entitylines, $gridsizeindex, 1, ()
+			if defined $gridsizeindex;
+		splice @entitylines, 1, 0, qq{"gridsize" "$newgridsize"};
+		$bsp[$lumpid{entities}]->[2] = join "\n", @entitylines;
+	}
+	elsif(/^-x(.+)$/) # extract lump to stdout
+	{
+		my $id = $lumpid{$1};
+		die "invalid lump $1 to extract"
+			unless defined $id;
+		print $bsp[$id]->[2];
+	}
+	elsif(/^-o(.+)?$/) # write the final BSP file
+	{
+		my $outfile = $1;
+		$outfile = $fn
+			if not defined $outfile;
+		open my $fh, ">", $outfile
+			or die "$outfile: $!";
+		print $fh $header;
+		my $pos = 17 * 8 + tell($fh) + length $msg;
+		for(@bsp)
+		{
+			$_->[0] = $pos;
+			$_->[1] = length $_->[2];
+			$pos += $_->[1];
+			print $fh pack "VV", $_->[0], $_->[1];
+		}
+		print $fh $msg;
+		for(@bsp)
+		{
+			print $fh $_->[2];
+		}
+		close $fh;
+		print STDERR "Wrote $outfile\n";
+	}
+	else
+	{
+		die "Invalid option: $_";
+	}
+}
+
+# TODO:
+#   features like:
+#     decimate light grid
+#     edit lightmaps/grid

Copied: trunk/misc/tools/crc16.c (from rev 5536, trunk/misc/crc16.c)
===================================================================
--- trunk/misc/tools/crc16.c	                        (rev 0)
+++ trunk/misc/tools/crc16.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,97 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+// this CRC matches DP
+// output is:
+//   filesize.crc16
+// usage:
+//   mv csprogs.dat csprogs.dat.`crc16 < csprogs.dat`
+// see script csqcarchive.sh
+
+/*
+============================================================================
+
+					CRC FUNCTIONS
+
+============================================================================
+*/
+
+// this is a 16 bit, non-reflected CRC using the polynomial 0x1021
+// and the initial and final xor values shown below...  in other words, the
+// CCITT standard CRC used by XMODEM
+
+#define CRC_INIT_VALUE	0xffff
+#define CRC_XOR_VALUE	0x0000
+
+static unsigned short crctable[256] =
+{
+	0x0000,	0x1021,	0x2042,	0x3063,	0x4084,	0x50a5,	0x60c6,	0x70e7,
+	0x8108,	0x9129,	0xa14a,	0xb16b,	0xc18c,	0xd1ad,	0xe1ce,	0xf1ef,
+	0x1231,	0x0210,	0x3273,	0x2252,	0x52b5,	0x4294,	0x72f7,	0x62d6,
+	0x9339,	0x8318,	0xb37b,	0xa35a,	0xd3bd,	0xc39c,	0xf3ff,	0xe3de,
+	0x2462,	0x3443,	0x0420,	0x1401,	0x64e6,	0x74c7,	0x44a4,	0x5485,
+	0xa56a,	0xb54b,	0x8528,	0x9509,	0xe5ee,	0xf5cf,	0xc5ac,	0xd58d,
+	0x3653,	0x2672,	0x1611,	0x0630,	0x76d7,	0x66f6,	0x5695,	0x46b4,
+	0xb75b,	0xa77a,	0x9719,	0x8738,	0xf7df,	0xe7fe,	0xd79d,	0xc7bc,
+	0x48c4,	0x58e5,	0x6886,	0x78a7,	0x0840,	0x1861,	0x2802,	0x3823,
+	0xc9cc,	0xd9ed,	0xe98e,	0xf9af,	0x8948,	0x9969,	0xa90a,	0xb92b,
+	0x5af5,	0x4ad4,	0x7ab7,	0x6a96,	0x1a71,	0x0a50,	0x3a33,	0x2a12,
+	0xdbfd,	0xcbdc,	0xfbbf,	0xeb9e,	0x9b79,	0x8b58,	0xbb3b,	0xab1a,
+	0x6ca6,	0x7c87,	0x4ce4,	0x5cc5,	0x2c22,	0x3c03,	0x0c60,	0x1c41,
+	0xedae,	0xfd8f,	0xcdec,	0xddcd,	0xad2a,	0xbd0b,	0x8d68,	0x9d49,
+	0x7e97,	0x6eb6,	0x5ed5,	0x4ef4,	0x3e13,	0x2e32,	0x1e51,	0x0e70,
+	0xff9f,	0xefbe,	0xdfdd,	0xcffc,	0xbf1b,	0xaf3a,	0x9f59,	0x8f78,
+	0x9188,	0x81a9,	0xb1ca,	0xa1eb,	0xd10c,	0xc12d,	0xf14e,	0xe16f,
+	0x1080,	0x00a1,	0x30c2,	0x20e3,	0x5004,	0x4025,	0x7046,	0x6067,
+	0x83b9,	0x9398,	0xa3fb,	0xb3da,	0xc33d,	0xd31c,	0xe37f,	0xf35e,
+	0x02b1,	0x1290,	0x22f3,	0x32d2,	0x4235,	0x5214,	0x6277,	0x7256,
+	0xb5ea,	0xa5cb,	0x95a8,	0x8589,	0xf56e,	0xe54f,	0xd52c,	0xc50d,
+	0x34e2,	0x24c3,	0x14a0,	0x0481,	0x7466,	0x6447,	0x5424,	0x4405,
+	0xa7db,	0xb7fa,	0x8799,	0x97b8,	0xe75f,	0xf77e,	0xc71d,	0xd73c,
+	0x26d3,	0x36f2,	0x0691,	0x16b0,	0x6657,	0x7676,	0x4615,	0x5634,
+	0xd94c,	0xc96d,	0xf90e,	0xe92f,	0x99c8,	0x89e9,	0xb98a,	0xa9ab,
+	0x5844,	0x4865,	0x7806,	0x6827,	0x18c0,	0x08e1,	0x3882,	0x28a3,
+	0xcb7d,	0xdb5c,	0xeb3f,	0xfb1e,	0x8bf9,	0x9bd8,	0xabbb,	0xbb9a,
+	0x4a75,	0x5a54,	0x6a37,	0x7a16,	0x0af1,	0x1ad0,	0x2ab3,	0x3a92,
+	0xfd2e,	0xed0f,	0xdd6c,	0xcd4d,	0xbdaa,	0xad8b,	0x9de8,	0x8dc9,
+	0x7c26,	0x6c07,	0x5c64,	0x4c45,	0x3ca2,	0x2c83,	0x1ce0,	0x0cc1,
+	0xef1f,	0xff3e,	0xcf5d,	0xdf7c,	0xaf9b,	0xbfba,	0x8fd9,	0x9ff8,
+	0x6e17,	0x7e36,	0x4e55,	0x5e74,	0x2e93,	0x3eb2,	0x0ed1,	0x1ef0
+};
+
+unsigned short CRC_Block(const unsigned char *data, size_t size)
+{
+	unsigned short crc = CRC_INIT_VALUE;
+	while (size--)
+		crc = (crc << 8) ^ crctable[(crc >> 8) ^ (*data++)];
+	return crc ^ CRC_XOR_VALUE;
+}
+
+int main()
+{
+	unsigned char *buf;
+	size_t bufsize = 0;
+	size_t newbufsize;
+	size_t nread;
+
+	for(;;)
+	{
+		newbufsize = 2 * bufsize + 1;
+		buf = realloc(buf, newbufsize);
+		nread = fread(buf + bufsize, 1, newbufsize - bufsize, stdin);
+		if(nread != newbufsize - bufsize)
+		{
+			// output checksum
+			unsigned short crc = CRC_Block(buf, bufsize + nread);
+			printf("%ju.%u\n", (uintmax_t) (bufsize + nread), crc);
+
+			// exit
+			break;
+		}
+		bufsize = newbufsize;
+	}
+
+	return 0;
+}

Copied: trunk/misc/tools/csqcarchive.sh (from rev 5536, trunk/misc/csqcarchive.sh)
===================================================================
--- trunk/misc/tools/csqcarchive.sh	                        (rev 0)
+++ trunk/misc/tools/csqcarchive.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+set -e
+
+make crc16
+crc16=`pwd`/crc16
+out=`pwd`/csqcarchive.zip
+
+t=`mktemp -dt csqcarchive.XXXXXX`
+cd "$t"
+
+revs()
+{
+	{
+		svn log svn://svn.icculus.org/nexuiz/$1/data/qcsrc/common
+		echo
+		svn log svn://svn.icculus.org/nexuiz/$1/data/qcsrc/client
+	} | {
+		while IFS= read -r LINE; do
+			if [ "$LINE" = "------------------------------------------------------------------------" ]; then
+				read -r REV REST
+				case "$REV" in
+					r*)
+						echo ${REV#r}
+						;;
+				esac
+			fi
+		done
+	} | sort -n
+}
+
+rm -f "$out"
+for repo in branches/nexuiz-2.0 trunk; do
+	for rev in `revs $repo`; do
+		if [ "$rev" -lt 3789 ]; then
+			continue
+		fi
+		svn checkout -r"$rev" svn://svn.icculus.org/nexuiz/$repo/data/qcsrc
+		rm -f Makefile csprogs.dat
+		wget -OMakefile "http://svn.icculus.org/*checkout*/nexuiz/$repo/data/Makefile?revision=$rev" || continue
+		make csprogs.dat || continue
+		nm="csprogs.dat.`$crc16 < csprogs.dat`"
+		mv csprogs.dat "$nm"
+		zip -9r "$out" "$nm"
+	done
+done

Copied: trunk/misc/tools/democonv-15-20.pl (from rev 5536, trunk/misc/democonv-15-20.pl)
===================================================================
--- trunk/misc/tools/democonv-15-20.pl	                        (rev 0)
+++ trunk/misc/tools/democonv-15-20.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+
+# usage:
+#   ./democonv-15-20.pl infile outfile
+
+use strict;
+use warnings;
+
+# constants
+my $svc_print = "\010";
+my $svc_serverinfo = "\013";
+
+my %maps = (
+	nexdm01 => 'basement',
+	nexdm02 => 'bleach',
+	nexdm03 => 'slimepit',
+	nexdm04 => 'skyway',
+	nexdm05 => 'downer',
+	nexdm06 => 'starship',
+	nexdm07 => 'dsi',
+	nexdm08 => 'glowarena',
+	nexdm09 => 'aneurysm',
+	nexdm10 => 'stormkeep',
+	nexdm11 => 'ruinsofslaughter',
+	nexdm12 => 'evilspace',
+	nexdm13 => 'dismal',
+	nexdm14 => 'soylent',
+	nexdm15 => 'oilrig',
+	nexdm16 => 'silvercity',
+	nexdm17 => 'dieselpower',
+	nexdm18 => 'runningman',
+	nexdm18_1on1remix => 'runningman_1on1remix',
+	nexdmextra1 => 'darkzone',
+	nexdmextra2 => 'aggressor',
+	nexctf01 => 'basementctf',
+	nexctf02 => 'runningmanctf',
+);
+
+# opening the files
+
+push @ARGV, "$ARGV[0]-converted.dem"
+	if @ARGV == 1;
+
+die "Usage: $0 infile outfile"
+	if @ARGV != 2;
+my ($in, $out) = @ARGV;
+
+$in ne $out
+	or die "Input and output file may not be the same!";
+
+open my $infh, "<", $in
+	or die "open $in: $!";
+binmode $infh;
+
+open my $outfh, ">", $out
+	or die "open $out: $!";
+binmode $outfh;
+
+sub TranslateMapname($)
+{
+	my ($map) = @_;
+	return $maps{$map}
+		if exists $maps{$map};
+	return $map;
+}
+
+# 1. CD track
+
+$/ = "\012";
+my $cdtrack = <$infh>;
+print $outfh $cdtrack;
+
+# 2. packets
+
+for(;;)
+{
+	last
+		unless 4 == read $infh, my $length, 4;
+	$length = unpack("V", $length);
+	die "Invalid demo packet"
+		unless 12 == read $infh, my $angles, 12;
+	die "Invalid demo packet"
+		unless $length == read $infh, my($data), $length;
+
+	$data =~ s{
+		^
+		($svc_print
+			[^\0]*\0
+		$svc_serverinfo....
+			[^\0]*\0
+			maps/)([^\0]*)(\.bsp\0)
+	}{$1 . TranslateMapname($2) . $3}sex;
+
+	print $outfh pack("V", length $data);
+	print $outfh $angles;
+	print $outfh $data;
+}
+
+close $outfh;
+close $infh;

Copied: trunk/misc/tools/demosplit.pl (from rev 5536, trunk/misc/demosplit.pl)
===================================================================
--- trunk/misc/tools/demosplit.pl	                        (rev 0)
+++ trunk/misc/tools/demosplit.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+
+# usage:
+#   ./demosplit.pl demo.dem
+# splits the demo into separate demos for each map played and writes them
+# to demo-0000.dem, demo-0001.dem ...
+
+use strict;
+use warnings;
+
+# constants
+my $svc_signon = "\001";
+
+# opening the files
+
+die "Usage: $0 infile"
+	if @ARGV != 1;
+my ($in) = @ARGV;
+
+my $demoname = [$in =~ /^(.*)\.dem$/]->[0];
+$demoname = "out"
+	if not defined $demoname;
+
+open my $infh, "<", $in
+	or die "open $in: $!";
+binmode $infh;
+
+# 1. CD track
+
+$/ = "\012";
+my $cdtrack = <$infh>;
+
+# 2. packets
+
+my $outfh;
+my $outnum = 0;
+
+for(;;)
+{
+	last
+		unless 4 == read $infh, my $length, 4;
+	$length = unpack("V", $length);
+	die "Invalid demo packet"
+		unless 12 == read $infh, my $angles, 12;
+	die "Invalid demo packet"
+		unless $length == read $infh, my($data), $length;
+
+	if($data =~ m{
+		^
+		$svc_signon
+		$
+	}sx)
+	{
+		close $outfh
+			if $outfh;
+		my $outname = sprintf("%s-%04d.dem", $demoname, $outnum++);
+		open $outfh, ">", $outname
+			or die "open $outname: $!";
+		binmode $outfh;
+		print $outfh $cdtrack;
+		print "Writing to $outname...\n";
+	}
+
+	die "No signon received"
+		unless $outfh;
+	print $outfh pack("V", length $data);
+	print $outfh $angles;
+	print $outfh $data;
+}
+
+close $outfh;
+close $infh;

Copied: trunk/misc/tools/demotc-race-record-extractor.sh (from rev 5536, trunk/misc/demotc-race-record-extractor.sh)
===================================================================
--- trunk/misc/tools/demotc-race-record-extractor.sh	                        (rev 0)
+++ trunk/misc/tools/demotc-race-record-extractor.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+d=$1
+i=0
+perl demotc.pl grep "$d" 'all-time fastest lap record with (.*)\n' | while IFS=" " read -r timecode result; do
+	timecode=${timecode%:}
+	result=${result#\"}
+	result=${result%\"}
+
+	echo "Possible record found at $timecode: $result, extracting..."
+
+	minutes=${result%%:*}
+	result=${result#*:}
+	seconds=${result%%.*}
+	result=${result#*.}
+	tenths=$result
+
+	timecode_start=`echo "$timecode - $minutes*60 - $seconds - $tenths*0.1 - 2" | bc -l`
+	timecode_end=`echo "$timecode + 2" | bc -l`
+	i=$(($i + 1))
+	perl demotc.pl cut "$d" "playback-$i.dem" "$timecode_start" "$timecode_end"
+	perl demotc.pl cut "$d" "capture-$i.dem" "$timecode_start" "$timecode_end" --capture
+done

Copied: trunk/misc/tools/demotc.pl (from rev 5536, trunk/misc/demotc.pl)
===================================================================
--- trunk/misc/tools/demotc.pl	                        (rev 0)
+++ trunk/misc/tools/demotc.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,172 @@
+#!/usr/bin/perl
+
+# Fake demo "cutting" tool
+# works by looking for time codes in the demo
+# and injecting playback speed commands
+
+use strict;
+use warnings;
+
+sub sanitize($)
+{
+	my ($str) = @_;
+	$str =~ y/\000-\037//d;
+	return $str;
+}
+
+# opening the files
+
+my ($in, $out, $tc0, $tc1, $pattern, $capture);
+
+my $mode = shift @ARGV;
+$mode = 'help' if not defined $mode;
+
+if($mode eq 'grep' && @ARGV == 2)
+{
+	$in = $ARGV[0];
+	$pattern = $ARGV[1];
+}
+elsif($mode eq 'uncut' && @ARGV == 2)
+{
+	$in = $ARGV[0];
+	$out = $ARGV[1];
+}
+elsif($mode eq 'cut' && (@ARGV == 4 || @ARGV == 5))
+{
+	$in = $ARGV[0];
+	$out = $ARGV[1];
+	$tc0 = $ARGV[2];
+	$tc1 = $ARGV[3];
+	$capture = (@ARGV == 5);
+}
+else
+{
+	die "Usage: $0 cut infile outfile tc_start tc_end [--capture], or $0 uncut infile outfile, or $0 grep infile pattern\n"
+}
+
+if($mode ne 'grep')
+{
+	$in ne $out
+		or die "Input and output file may not be the same!";
+}
+
+open my $infh, "<", $in
+	or die "open $in: $!";
+binmode $infh;
+
+my $outfh;
+if($mode ne 'grep') # cutting
+{
+	open $outfh, ">", $out
+		or die "open $out: $!";
+	binmode $outfh;
+}
+
+# 1. CD track
+
+$/ = "\012";
+my $cdtrack = <$infh>;
+print $outfh $cdtrack if $mode ne 'grep';
+
+# 2. packets
+
+my $tc = undef;
+
+my $first = 1;
+my $demo_started = 0;
+my $demo_stopped = 0;
+my $inject_buffer = "";
+
+for(;;)
+{
+	last
+		unless 4 == read $infh, my $length, 4;
+	$length = unpack("V", $length);
+	die "Invalid demo packet"
+		unless 12 == read $infh, my $angles, 12;
+	die "Invalid demo packet"
+		unless $length == read $infh, my($data), $length;
+	
+	# remove existing cut marks
+	$data =~ s{^\011\n//CUTMARK\n[^\0]*\0}{};
+	
+	if(substr($data, 0, 1) eq "\007") # svc_time
+	{
+		$tc = unpack "f", substr $data, 1, 4;
+	}
+
+	if($mode eq 'cut' && defined $tc)
+	{
+		if($first)
+		{
+			$inject_buffer = "\011\n//CUTMARK\nslowmo 100\n\000";
+			$first = 0;
+		}
+		if($demo_started < 1 && $tc > $tc0 - 50)
+		{
+			$inject_buffer = "\011\n//CUTMARK\nslowmo 10\n\000";
+			$demo_started = 1;
+		}
+		if($demo_started < 2 && $tc > $tc0 - 5)
+		{
+			$inject_buffer = "\011\n//CUTMARK\nslowmo 1\n\000";
+			$demo_started = 2;
+		}
+		if($demo_started < 3 && $tc > $tc0)
+		{
+			if($capture)
+			{
+				$inject_buffer = "\011\n//CUTMARK\ncl_capturevideo 1\n\000";
+			}
+			else
+			{
+				$inject_buffer = "\011\n//CUTMARK\nslowmo 0; defer 1 \"slowmo 1\"\n\000";
+			}
+			$demo_started = 3;
+		}
+		if(!$demo_stopped && $tc > $tc1)
+		{
+			if($capture)
+			{
+				$inject_buffer = "\011\n//CUTMARK\ncl_capturevideo 0; defer 0.5 \"disconnect\"\n\000";
+			}
+			else
+			{
+				$inject_buffer = "\011\n//CUTMARK\ndefer 0.5 \"disconnect\"\n\000";
+			}
+			$demo_stopped = 1;
+		}
+	}
+	elsif($mode eq 'grep')
+	{
+		if(my @l = ($data =~ /$pattern/))
+		{
+			if(defined $tc)
+			{
+				print "$tc:";
+			}
+			else
+			{
+				print "start:";
+			}
+			for(@l)
+			{
+				print " \"", sanitize($_), "\"";
+			}
+			print "\n";
+		}
+	}
+	
+	next if $mode eq 'grep';
+	if(length($inject_buffer . $data) < 65536)
+	{
+		$data = $inject_buffer . $data;
+		$inject_buffer = "";
+	}
+	print $outfh pack("V", length $data);
+	print $outfh $angles;
+	print $outfh $data;
+}
+
+close $outfh if $mode ne 'grep';
+close $infh;

Copied: trunk/misc/tools/dependencies.pl (from rev 5536, trunk/misc/dependencies.pl)
===================================================================
--- trunk/misc/tools/dependencies.pl	                        (rev 0)
+++ trunk/misc/tools/dependencies.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,303 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my %files = ();
+my %shaders = ();
+
+sub ReadShaders()
+{
+	for my $sf(<scripts/*.shader>)
+	{
+		my $curshader = undef;
+		my @tex = ();
+		my $level = 0;
+		open my $fh, "<", $sf
+			or die "<$sf: $!";
+		while(<$fh>)
+		{
+			s/\r//gs;
+			chomp;
+
+			s/\/\/.*//s;
+			s/^\s+//;
+			s/\s+$//;
+			next if /^$/;
+
+			my @line = map { s/"//g; $_; } split /\s+/, $_;
+
+			if($line[0] eq '{')
+			{
+				++$level;
+			}
+			elsif($line[0] eq '}')
+			{
+				--$level;
+				if($level <= 0)
+				{
+					$level = 0;
+					if(defined $curshader)
+					{
+						$shaders{lc $curshader} = { shaderfile => $sf, textures => [ @tex ] };
+					}
+					$curshader = undef;
+				}
+			}
+			elsif($level == 0)
+			{
+				$curshader = $line[0];
+				@tex = ();
+			}
+			elsif($level == 1 and lc $line[0] eq 'qer_editorimage')
+			{
+				push @tex, $line[1];
+			}
+			elsif($level == 1 and lc $line[0] eq 'qer_lightimage')
+			{
+				push @tex, $line[1];
+			}
+			elsif($level == 1 and lc $line[0] eq 'skyparms')
+			{
+				for(qw/rt lf ft bk up dn/)
+				{
+					push @tex, "$line[1]_$_";
+					push @tex, "$line[3]_$_";
+				}
+			}
+			elsif($level == 2 and lc $line[0] eq 'map')
+			{
+				push @tex, $line[1];
+			}
+			elsif($level == 2 and lc $line[0] eq 'animmap')
+			{
+				for(2..(@line - 1))
+				{
+					push @tex, $line[$_];
+				}
+			}
+		}
+	}
+}
+
+sub AddFile($)
+{
+	my ($file) = @_;
+	return 0
+		unless -e $file;
+	++$files{$file};
+	return 1;
+}
+
+sub AddSound($)
+{
+	my ($tex) = @_;
+	$tex =~ s/\.ogg$|\.wav$//i;
+	AddFile "$tex.ogg" or
+	AddFile "$tex.wav" or
+	AddFile "sound/$tex.ogg" or
+	AddFile "sound/$tex.wav";
+}
+
+sub AddTexture($)
+{
+	my ($tex) = @_;
+	$tex =~ s/\.jpg$|\.tga$|\.png$//i;
+	AddFile "$tex.jpg" or
+	AddFile "$tex.tga" or
+	AddFile "$tex.png"
+		or return 0;
+	for('_shirt', '_pants', '_glow', '_norm', '_bump', '_gloss')
+	{
+		AddFile "$tex$_.jpg" or
+		AddFile "$tex$_.tga" or
+		AddFile "$tex$_.png";
+	}
+	return 1;
+}
+
+sub AddShader($)
+{
+	my ($shader) = @_;
+	$shader =~ s/\.jpg$|\.tga$|\.png$//i;
+	my $si = $shaders{lc $shader};
+	if(not defined $si)
+	{
+		AddTexture $shader
+			or warn "Unknown shader used: $shader";
+	}
+	else
+	{
+		AddFile $si->{shaderfile};
+		AddTexture $_
+			for @{$si->{textures}};
+	}
+}
+
+sub AddMapDependencies($)
+{
+	my ($data) = @_;
+	for(/^"noise.*" "(.*)"/gm)
+	{
+		AddSound $1;
+	}
+	for(/^"sound.*" "(.*)"/gm)
+	{
+		AddSound $1;
+	}
+	for(/^"music" "(.*)"/gm)
+	{
+		AddSound $1;
+	}
+	for(/^"model" "(.*)"/gm)
+	{
+		# TODO make this AddModel
+		# TODO and find the shaders the model uses
+		AddFile $1;
+	}
+	for(/^"lodmodel.*" "(.*)"/gm)
+	{
+		AddFile $1;
+	}
+}
+
+sub AddMapinfoDependencies($)
+{
+	my ($data) = @_;
+	for($data =~ /^cdtrack (.*)$/gm)
+	{
+		AddSound "sound/cdtracks/$1";
+	}
+}
+
+sub AddCfgDependencies($)
+{
+	my ($data) = @_;
+	for($data =~ /^cd loop "?(.*?)"?$/gm)
+	{
+		AddSound "sound/cdtracks/$1";
+	}
+}
+
+sub AddShaderDependencies($)
+{
+	my ($data) = @_;
+
+	my $n = length($data) / 72;
+	for(0..($n-1))
+	{
+		my $s = substr $data, $_ * 72, 64;
+		$s =~ s/\0.*$//s;
+		AddShader $s;
+	}
+}
+
+sub AddFaceDependencies($$)
+{
+	my ($base, $data) = @_;
+
+	my $n = length($data) / 104;
+	for(0..($n-1))
+	{
+		my $l = unpack "V", substr $data, $_ * 104 + 28, 4;
+		AddTexture sprintf "maps/%s/lm_%04d", $base, $l;
+		AddTexture sprintf "maps/%s/lm_%04d", $base, $l | 1; # deluxe
+	}
+}
+
+
+ReadShaders();
+
+for(<maps/*.ent>)
+{
+	AddFile $_;
+
+	my $data = do {
+		undef local $/;
+		open my $fh, "<", $_
+			or die "<$_: $!";
+		<$fh>;
+	};
+	AddMapDependencies $data;
+}
+
+for(<maps/*.bsp>)
+{
+	AddFile $_;
+
+	m!^maps/(.*)\.bsp! or die "perl is stupid";
+	my $b = $1;
+	AddFile "maps/$b.mapinfo";
+	AddFile "maps/$b.jpg";
+	AddFile "maps/$b.cfg";
+	AddFile "maps/$b.waypoints";
+	AddFile "maps/$b.rtlights";
+	AddTexture "gfx/$b\_radar.tga";
+	AddTexture "gfx/$b\_mini.tga";
+
+	my $data = do {
+		undef local $/;
+		open my $fh, "<", "maps/$b.mapinfo"
+			or warn "<maps/$b.mapinfo: $!";
+		<$fh>;
+	};
+	AddMapinfoDependencies $data;
+
+	$data = do {
+		undef local $/;
+		open my $fh, "<", "maps/$b.cfg"
+			or warn "<maps/$b.cfg: $!";
+		<$fh>;
+	};
+	AddCfgDependencies $data;
+
+	$data = do {
+		undef local $/;
+		open my $fh, "-|", 'bsptool.pl', $_, '-xentities'
+			or die "<$_: $!";
+		<$fh>;
+	};
+	AddMapDependencies $data;
+
+	$data = do {
+		undef local $/;
+		open my $fh, "-|", 'bsptool.pl', $_, '-xfaces'
+			or die "<$_: $!";
+		<$fh>;
+	};
+	AddFaceDependencies $b, $data;
+
+	$data = do {
+		undef local $/;
+		open my $fh, "-|", 'bsptool.pl', $_, '-xtextures'
+			or die "<$_: $!";
+		<$fh>;
+	};
+	AddShaderDependencies $data;
+}
+
+sub RecurseDir($);
+sub RecurseDir($)
+{
+	my ($dir) = @_;
+	if(-d $dir)
+	{
+		for(<$dir/*>)
+		{
+			RecurseDir $_;
+		}
+	}
+	else
+	{
+		warn "Unused file: $dir"
+			unless $files{$dir};
+	}
+}
+
+for(<*>)
+{
+	RecurseDir $_;
+}
+
+print "$_\0"
+	for sort keys %files;

Copied: trunk/misc/tools/entmerge.pl (from rev 5536, trunk/misc/entmerge.pl)
===================================================================
--- trunk/misc/tools/entmerge.pl	                        (rev 0)
+++ trunk/misc/tools/entmerge.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,595 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Carp;
+$SIG{__DIE__} = sub { 
+	Carp::cluck "Exception: $@";
+};
+
+# ent file managing tool
+# usage:
+#
+#   map -> ent:
+#     perl entmerge.pl $scalefactor             < mapname.map > mapname.ent
+#
+#   ent -> map:
+#     perl entmerge.pl $scalefactor mapname.ent < mapname.map > mapname-merged.map
+#
+#   bsp -> ent:
+#     perl bsptool.pl mapname.bsp -xentities                  > mapname.ent
+#                                                          
+#   ent -> bsp:                                            
+#     perl bsptool.pl mapname.bsp -rentities                  < mapname.ent
+
+sub DotProduct($$)
+{
+	my ($a, $b) = @_;
+	return	$a->[0]*$b->[0]
+		+	$a->[1]*$b->[1]
+		+	$a->[2]*$b->[2];
+}
+
+sub CrossProduct($$)
+{
+	my ($a, $b) = @_;
+	return	[
+		$a->[1]*$b->[2] - $a->[2]*$b->[1],
+		$a->[2]*$b->[0] - $a->[0]*$b->[2],
+		$a->[0]*$b->[1] - $a->[1]*$b->[0]
+	];
+}
+
+sub VectorMAM(@)
+{
+	my (@data) = @_;
+	my $out = [0, 0, 0];
+	for my $coord(0..2)
+	{
+		my $c = 0;
+		$c += $data[2*$_ + 0] * $data[2*$_ + 1]->[$coord]
+			for 0..(@data/2 - 1);
+		$out->[$coord] = $c;
+	}
+	return $out;
+}
+
+sub VectorLength2($)
+{
+	my ($v) = @_;
+	return DotProduct $v, $v;
+}
+
+sub VectorLength($)
+{
+	my ($v) = @_;
+	return sqrt VectorLength2 $v;
+}
+
+sub VectorNormalize($)
+{
+	my ($v) = @_;
+	return VectorMAM 1/VectorLength($v), $v;
+}
+
+sub Polygon_QuadForPlane($$)
+{
+	my ($plane, $quadsize) = @_;
+
+	my $quadup;
+	if(abs($plane->[2]) > abs($plane->[0]) && abs($plane->[2]) > abs($plane->[1]))
+	{
+		$quadup = [1, 0, 0];
+	}
+	else
+	{
+		$quadup = [0, 0, 1];
+	}
+
+	$quadup = VectorMAM 1, $quadup, -DotProduct($quadup, $plane), $plane;
+	$quadup = VectorMAM $plane->[3], VectorNormalize $quadup;
+
+	my $quadright = CrossProduct $quadup, $plane;
+
+	return [
+		VectorMAM($plane->[3], $plane, -$quadsize*2, $quadright, +$quadsize*2, $quadup),
+		VectorMAM($plane->[3], $plane, +$quadsize*2, $quadright, +$quadsize*2, $quadup),
+		VectorMAM($plane->[3], $plane, +$quadsize*2, $quadright, -$quadsize*2, $quadup),
+		VectorMAM($plane->[3], $plane, -$quadsize*2, $quadright, -$quadsize*2, $quadup)
+	];
+}
+
+sub Polygon_Clip($$$)
+{
+	my ($points, $plane, $epsilon) = @_;
+
+	if(@$points < 1)
+	{
+		return [];
+	}
+
+	my $n = 0;
+	my $ndist = DotProduct($points->[$n], $plane) - $plane->[3];
+
+	my @outfrontpoints = ();
+
+	for my $i(0..@$points - 1)
+	{
+		my $p = $n;
+		my $pdist = $ndist;
+		$n = ($i+1) % @$points;
+		$ndist = DotProduct($points->[$n], $plane) - $plane->[3];
+		if($pdist >= -$epsilon)
+		{
+			push @outfrontpoints, $points->[$p];
+		}
+		if(($pdist > $epsilon && $ndist < -$epsilon) || ($pdist < -$epsilon && $ndist > $epsilon))
+		{
+			my $frac = $pdist / ($pdist - $ndist);
+			push @outfrontpoints, VectorMAM 1-$frac, $points->[$p], $frac, $points->[$n];
+		}
+	}
+
+	return \@outfrontpoints;
+}
+
+sub MakePlane($$$)
+{
+	my ($p, $q, $r) = @_;
+
+	my $a = VectorMAM 1, $q, -1, $p;
+	my $b = VectorMAM 1, $r, -1, $p;
+	my $n = VectorNormalize CrossProduct $a, $b;
+
+	return [ @$n, DotProduct $n, $p ];
+}
+
+sub GetBrushWindings($)
+{
+	my ($planes) = @_;
+
+	my @windings = ();
+
+	for my $i(0..(@$planes - 1))
+	{
+		my $winding = Polygon_QuadForPlane $planes->[$i], 65536;
+
+		for my $j(0..(@$planes - 1))
+		{
+			next
+				if $i == $j;
+			$winding = Polygon_Clip $winding, $planes->[$j], 1/64.0;
+		}
+
+		push @windings, $winding
+			unless @$winding == 0;
+	}
+
+	return \@windings;
+}
+
+sub GetBrushMinMax($)
+{
+	my ($brush) = @_;
+
+	if($brush->[0] =~ /^\(/)
+	{
+		# plain brush
+		my @planes = ();
+		for(@$brush)
+		{
+			/^\(\s+(\S+)\s+(\S+)\s+(\S+)\s+\)\s+\(\s+(\S+)\s+(\S+)\s+(\S+)\s+\)\s+\(\s+(\S+)\s+(\S+)\s+(\S+)\s+\)\s+/
+				or die "Invalid line in plain brush: $_";
+			push @planes, MakePlane [ $1, $2, $3 ], [ $4, $5, $6 ], [ $7, $8, $9 ];
+			# for any three planes, find their intersection
+			# check if the intersection is inside all other planes
+		}
+		
+		my $windings = GetBrushWindings \@planes;
+
+		my (@mins, @maxs);
+
+		for(@$windings)
+		{
+			for my $v(@$_)
+			{
+				if(@mins)
+				{
+					for(0..2)
+					{
+						$mins[$_] = $v->[$_] if $mins[$_] > $v->[$_];
+						$maxs[$_] = $v->[$_] if $maxs[$_] < $v->[$_];
+					}
+				}
+				else
+				{
+					@mins = @$v;
+					@maxs = @$v;
+				}
+			}
+		}
+
+		return undef
+			unless @mins;
+		return \@mins, \@maxs;
+	}
+
+	die "Cannot decode this brush yet! brush is @$brush";
+}
+
+sub BrushOrigin($)
+{
+	my ($brushes) = @_;
+
+	my @org = ();
+
+	for my $brush(@$brushes)
+	{
+		my $isorigin = 0;
+		for(@$brush)
+		{
+			$isorigin = 1
+				if /\bcommon\/origin\b/;
+		}
+		if($isorigin)
+		{
+			my ($mins, $maxs) = GetBrushMinMax $brush;
+			@org = map { 0.5 * ($mins->[$_] + $maxs->[$_]) } 0..2
+				if defined $mins;
+		}
+	}
+
+	return \@org
+		if @org;
+	return undef;
+}
+
+sub ParseEntity($)
+{
+	my ($fh) = @_;
+
+	my %ent = ( );
+	my @brushes = ( );
+
+	while(<$fh>)
+	{
+		chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
+
+		if(/^\{$/)
+		{
+			# entity starts
+			while(<$fh>)
+			{
+				chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
+
+				if(/^"(.*?)" "(.*)"$/)
+				{
+					# key-value pair
+					$ent{$1} = $2;
+				}
+				elsif(/^\{$/)
+				{
+					my $brush = [];
+					push @brushes, $brush;
+
+					while(<$fh>)
+					{
+						chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
+
+						if(/^\{$/)
+						{
+							# patch?
+							push @$brush, $_;
+
+							while(<$fh>)
+							{
+								chomp; s/\r//g; s/\0//g; s/\/\/.*$//; s/^\s+//; s/\s+$//; next if /^$/;
+
+								if(/^\}$/)
+								{
+									push @$brush, $_;
+
+									last;
+								}
+								else
+								{
+									push @$brush, $_;
+								}
+							}
+						}
+						elsif(/^\}$/)
+						{
+							# end of brush
+							last;
+						}
+						else
+						{
+							push @$brush, $_;
+						}
+					}
+				}
+				elsif(/^\}$/)
+				{
+					return \%ent, \@brushes;
+				}
+			}
+		}
+		else
+		{
+			die "Unexpected line in top level: >>$_<<";
+		}
+	}
+
+	return undef;
+}
+
+sub UnparseEntity($$)
+{
+	my ($ent, $brushes) = @_;
+	my %ent = %$ent;
+
+	my $s = "{\n";
+
+	for(sort keys %ent)
+	{
+		$s .= "\"$_\" \"$ent{$_}\"\n";
+	}
+
+	if(defined $brushes)
+	{
+		for(@$brushes)
+		{
+			$s .= "{\n";
+			$s .= "$_\n" for @$_;
+			$s .= "}\n";
+		}
+	}
+
+	$s .= "}\n";
+	return $s;
+}
+
+my ($scale, $in_ent) = @ARGV;
+
+$scale = 1
+	if not defined $scale;
+
+my @submodels = ();
+my @entities = ();
+my @entities_skipped = ();
+
+# THIS part is always a .map file
+my $first = 1;
+my $keeplights;
+for(;;)
+{
+	my ($ent, $brushes) = ParseEntity \*STDIN;
+
+	defined $ent
+		or last;
+	
+	if($first && $ent->{classname} eq 'worldspawn')
+	{
+		$keeplights = $ent->{_keeplights};
+		delete $ent->{_keeplights};
+		@submodels = ($brushes);
+	}
+	else
+	{
+		if($first)
+		{
+			push @entities, { classname => "worldspawn" };
+			@submodels = ([]);
+		}
+
+		if($ent->{classname} eq 'worldspawn')
+		{
+			$ent->{classname} = "worldspawn_renamed";
+		}
+
+		if(grep { $_ eq $ent->{classname} } qw/group_info func_group misc_model _decal _skybox/)
+		{
+			push @entities_skipped, [$ent, $brushes];
+			next;
+		}
+
+		if(!$keeplights && $ent->{classname} =~ /^light/)
+		{
+			push @entities_skipped, [$ent, $brushes];
+			next;
+		}
+
+		if(@$brushes)
+		{
+			my $i = @submodels;
+			push @submodels, $brushes;
+			$ent->{model} = sprintf "*%d", $i;
+		}
+	}
+
+	push @entities, $ent;
+
+	$first = 0;
+}
+
+if($first)
+{
+	push @entities, { classname => "worldspawn" };
+	@submodels = ([]);
+}
+
+if(defined $in_ent)
+{
+	# translate map using ent to map
+	open my $fh, "<", $in_ent
+		or die "$in_ent: $!";
+
+	# THIS part is always an .ent file now
+	my @entities_entfile = ();
+	$first = 1;
+	
+	my $clear_all_worldlights;
+
+	for(;;)
+	{
+		my ($ent, $brushes) = ParseEntity $fh;
+
+		defined $ent
+			or last;
+		
+		if($first && $ent->{classname} eq 'worldspawn')
+		{
+		}
+		else
+		{
+			if($first)
+			{
+				push @entities_entfile, { classname => "worldspawn" };
+			}
+
+			if($ent->{classname} eq 'worldspawn')
+			{
+				$ent->{classname} = "worldspawn_renamed";
+			}
+
+			if(!$keeplights && $ent->{classname} =~ /^light/)
+			{
+				# light entity detected!
+				# so let's replace all light entities
+				$clear_all_worldlights = 1;
+			}
+		}
+
+		if(defined $ent->{model} and $ent->{model} =~ /^\*(\d+)$/)
+		{
+			my $entfileorigin = [ split /\s+/, ($ent->{origin} || "0 0 0") ];
+			my $baseorigin = BrushOrigin $submodels[$1];
+
+			if(defined $baseorigin)
+			{
+				my $org = VectorMAM 1, $entfileorigin, -1, $baseorigin;
+				$ent->{origin} = sprintf "%.6f %.6f %.6f", @$org;
+			}
+		}
+
+		push @entities_entfile, $ent;
+		$first = 0;
+	}
+	close $fh;
+
+	if($keeplights && !$entities_entfile[0]->{keeplights})
+	{
+		# PROBLEM:
+		# the .ent file was made without keeplights
+		# merging it with the .map would delete all lights
+		# so insert all light entities here!
+		@entities_skipped = (@entities_skipped,
+			map
+			{
+				my $submodel = undef;
+				if(defined $_->{model} and $_->{model} =~ /^\*(\d+)$/)
+				{
+					$submodel = $submodels[$1];
+				}
+				[ $_, $submodel ]
+			}
+			grep
+			{
+				$_->{classname} =~ /^light/
+			}
+			@entities
+		);
+	}
+
+	if($clear_all_worldlights)
+	{
+		# PROBLEM:
+		# the .ent file was made with keeplights
+		# the .map did not indicate so!
+		# so we must delete all lights from the skipped entity list
+		@entities_skipped = grep { $_->[0]->{classname} !~ /^light/ } @entities_skipped;
+	}
+
+	if($first)
+	{
+		push @entities_entfile, { classname => "worldspawn" };
+	}
+
+	$first = 1;
+	for(@entities_entfile)
+	{
+		my %e = %$_;
+		my $submodel = undef;
+
+		$e{gridsize} = "64 64 128" if not exists $e{gridsize} and $first;
+		$e{lip} /= $scale if exists $e{lip};
+		$e{origin} = sprintf '%.6f %.6f %.6f', map { $_ / $scale } split /\s+/, $e{origin} if exists $e{origin};
+		$e{gridsize} = sprintf '%.6f %.6f %.6f', map { $_ / $scale } split /\s+/, $e{gridsize} if exists $e{gridsize} and $first;
+
+		if($first)
+		{
+			$submodel = $submodels[0];
+			if($keeplights)
+			{
+				$e{_keeplights} = 1;
+			}
+			else
+			{
+				delete $e{_keeplights};
+			}
+		}
+		elsif(defined $e{model} and $e{model} =~ /^\*(\d+)$/)
+		{
+			$submodel = $submodels[$1];
+			delete $e{model};
+		}
+		print UnparseEntity \%e, $submodel;
+		$first = 0;
+	}
+	for(@entities_skipped)
+	{
+		print UnparseEntity $_->[0], $_->[1];
+		$first = 0;
+	}
+}
+else
+{
+	# translate map to ent
+	$first = 1;
+	for(@entities)
+	{
+		my %e = %$_;
+
+		if($first)
+		{
+			if($keeplights)
+			{
+				$e{_keeplights} = 1;
+			}
+			else
+			{
+				delete $e{_keeplights};
+			}
+		}
+
+		if(defined $e{model} and $e{model} =~ /^\*(\d+)$/)
+		{
+			my $oldorigin = [ split /\s+/, ($e{origin} || "0 0 0") ];
+			my $org = BrushOrigin $submodels[$1];
+
+			if(defined $org)
+			{
+				$org = VectorMAM 1, $org, 1, $oldorigin;
+				$e{origin} = sprintf "%.6f %.6f %.6f", @$org;
+			}
+		}
+
+		$e{gridsize} = "64 64 128" if not exists $e{gridsize} and $first;
+		$e{lip} *= $scale if exists $e{lip};
+		$e{origin} = sprintf '%.6f %.6f %.6f', map { $_ * $scale } split /\s+/, $e{origin} if exists $e{origin};
+		$e{gridsize} = sprintf '%.6f %.6f %.6f', map { $_ * $scale } split /\s+/, $e{gridsize} if exists $e{gridsize} and $first;
+
+		print UnparseEntity \%e, undef;
+		$first = 0;
+	}
+}

Copied: trunk/misc/tools/fiximage.pl (from rev 5536, trunk/misc/fiximage.pl)
===================================================================
--- trunk/misc/tools/fiximage.pl	                        (rev 0)
+++ trunk/misc/tools/fiximage.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,105 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+# Usage:
+#   convert image.tga -depth 8 RGBA:- | perl fiximage.pl 72 | convert -depth 8 -size 72x56 RGBA:- output.tga
+
+my ($width) = @ARGV;
+
+my @pixels = ();
+
+for(;;)
+{
+	read STDIN, my $data, 4
+		or last;
+	my ($r, $g, $b, $a) = unpack "CCCC", $data;
+	push @pixels, [$r, $g, $b, $a];
+}
+
+my $height = @pixels / $width;
+my @fixlater;
+for my $y(0..($height-1))
+{
+	for my $x(0..($width-1))
+	{
+		next
+			if $pixels[$x + $y * $width][3] != 0;
+		# alpha is zero? Replace by weighted average.
+		my ($r, $g, $b, $a) = (0, 0, 0);
+		for my $dy(-1..1)
+		{
+			next if $y + $dy < 0;
+			next if $y + $dy >= $height;
+			for my $dx(-1..1)
+			{
+				next if $x + $dx < 0;
+				next if $x + $dx >= $width;
+				my $pix = $pixels[($x + $dx) + ($y + $dy) * $width];
+				$r += $pix->[0] * $pix->[3];
+				$g += $pix->[1] * $pix->[3];
+				$b += $pix->[2] * $pix->[3];
+				$a += $pix->[3];
+			}
+		}
+		if($a == 0)
+		{
+			push @fixlater, [$x, $y];
+			$pixels[$x + $y * $width] = [0, 0, 0, 0, undef];
+			next;
+		}
+		$r = int ($r / $a);
+		$g = int ($g / $a);
+		$b = int ($b / $a);
+		print STDERR "Fixing ($x, $y -> $r, $g, $b, $a)\n";
+		$pixels[$x + $y * $width] = [$r, $g, $b, 0];
+	}
+}
+
+while(@fixlater)
+{
+	print STDERR "Pixels left: ", scalar(@fixlater), "\n";
+
+	# These pixels have no neighbors with a non-zero alpha.
+	my @fixels = @fixlater;
+	@fixlater = ();
+	my @pixelsorig = @pixels;
+	for(@fixels)
+	{
+		my ($x, $y) = @$_;
+		my ($r, $g, $b, $a) = (0, 0, 0, 0);
+		for my $dy(-1..1)
+		{
+			next if $y + $dy < 0;
+			next if $y + $dy >= $height;
+			for my $dx(-1..1)
+			{
+				next if $x + $dx < 0;
+				next if $x + $dx >= $width;
+				my $pix = $pixelsorig[($x + $dx) + ($y + $dy) * $width];
+				next
+					if @$pix == 5;
+				$r += $pix->[0];
+				$g += $pix->[1];
+				$b += $pix->[2];
+				$a += 1;
+			}
+		}
+		if($a == 0)
+		{
+			push @fixlater, [$x, $y];
+			next;
+		}
+		$r = int ($r / $a);
+		$g = int ($g / $a);
+		$b = int ($b / $a);
+		#print STDERR "Fixing later ($x, $y -> $r, $g, $b, $a)\n";
+		$pixels[$x + $y * $width] = [$r, $g, $b, 0];
+	}
+}
+
+for(@pixels)
+{
+	print pack "CCCC", @$_;
+}

Copied: trunk/misc/tools/hslimage.c (from rev 5536, trunk/misc/hslimage.c)
===================================================================
--- trunk/misc/tools/hslimage.c	                        (rev 0)
+++ trunk/misc/tools/hslimage.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,104 @@
+#include <math.h>
+#include <stdio.h>
+
+#define MARGIN_X 0
+#define MARGIN_Y 0
+
+void hsl_to_rgb(float hsl_x, float hsl_y, float hsl_z, float *rgb_x, float *rgb_y, float *rgb_z)
+{
+	float mi, ma, maminusmi, h;
+
+	if(hsl_z <= 0.5)
+		maminusmi = hsl_y * 2 * hsl_z;
+	else
+		maminusmi = hsl_y * (2 - 2 * hsl_z);
+	
+	// hsl_z     = 0.5 * mi + 0.5 * ma
+	// maminusmi =     - mi +       ma
+	mi = hsl_z - 0.5 * maminusmi;
+	ma = hsl_z + 0.5 * maminusmi;
+
+	h = hsl_x - 6 * floor(hsl_x / 6);
+
+	//else if(ma == rgb_x)
+	//	h = 60 * (rgb_y - rgb_z) / (ma - mi);
+	if(h <= 1)
+	{
+		*rgb_x = ma;
+		*rgb_y = h * (ma - mi) + mi;
+		*rgb_z = mi;
+	}
+	//else if(ma == rgb_y)
+	//	h = 60 * (rgb_z - rgb_x) / (ma - mi) + 120;
+	else if(h <= 2)
+	{
+		*rgb_x = (2 - h) * (ma - mi) + mi;
+		*rgb_y = ma;
+		*rgb_z = mi;
+	}
+	else if(h <= 3)
+	{
+		*rgb_x = mi;
+		*rgb_y = ma;
+		*rgb_z = (h - 2) * (ma - mi) + mi;
+	}
+	//else // if(ma == rgb_z)
+	//	h = 60 * (rgb_x - rgb_y) / (ma - mi) + 240;
+	else if(h <= 4)
+	{
+		*rgb_x = mi;
+		*rgb_y = (4 - h) * (ma - mi) + mi;
+		*rgb_z = ma;
+	}
+	else if(h <= 5)
+	{
+		*rgb_x = (h - 4) * (ma - mi) + mi;
+		*rgb_y = mi;
+		*rgb_z = ma;
+	}
+	//else if(ma == rgb_x)
+	//	h = 60 * (rgb_y - rgb_z) / (ma - mi);
+	else // if(h <= 6)
+	{
+		*rgb_x = ma;
+		*rgb_y = mi;
+		*rgb_z = (6 - h) * (ma - mi) + mi;
+	}
+}
+
+void hslimage_color(float v_x, float v_y, float margin_x, float margin_y, float *rgb_x, float *rgb_y, float *rgb_z)
+{
+	v_x = (v_x - margin_x) / (1 - 2 * margin_x);
+	v_y = (v_y - margin_y) / (1 - 2 * margin_y);
+	if(v_x < 0) v_x = 0;
+	if(v_y < 0) v_y = 0;
+	if(v_x > 1) v_x = 1;
+	if(v_y > 1) v_y = 1;
+	if(v_y > 0.875) // grey bar
+		hsl_to_rgb(0, 0, v_x, rgb_x, rgb_y, rgb_z);
+	else
+		hsl_to_rgb(v_x * 6, 1, (v_y / 0.875), rgb_x, rgb_y, rgb_z);
+}
+
+int main()
+{
+	int x, y;
+	float r, g, b;
+
+	for(y = 0; y < 512; ++y)
+	{
+		for(x = 0; x < 512; ++x)
+		{
+			hslimage_color(x / 512.0, y / 512.0, MARGIN_X, MARGIN_Y, &r, &g, &b);
+			/*
+			putc(floor(r * 15 + 0.5) * 17, stdout);
+			putc(floor(g * 15 + 0.5) * 17, stdout);
+			putc(floor(b * 15 + 0.5) * 17, stdout);
+			*/
+			putc(floor(r * 255 + 0.5), stdout);
+			putc(floor(g * 255 + 0.5), stdout);
+			putc(floor(b * 255 + 0.5), stdout);
+		}
+	}
+	return 0;
+}

Copied: trunk/misc/tools/jpeg-if-not-alpha.sh (from rev 5536, trunk/misc/jpeg-if-not-alpha.sh)
===================================================================
--- trunk/misc/tools/jpeg-if-not-alpha.sh	                        (rev 0)
+++ trunk/misc/tools/jpeg-if-not-alpha.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -e
+
+: ${qual:=95}
+
+for X in "$@"; do
+	case "$X" in
+		*.jpg)
+			if [ -n "$scaledown" ]; then
+				mogrify -geometry "$scaledown>" -quality 100 "$X"
+			fi
+			jpegoptim --strip-all -m$qual "$X"
+			;;
+		*.png|*.tga)
+			if [ -n "$scaledown" ]; then
+				mogrify -geometry "$scaledown>" -quality 100 "$X"
+			fi
+			if convert "$X" -depth 16 RGBA:- | perl -e 'while(read STDIN, $_, 8) { substr($_, 6, 2) eq "\xFF\xFF" or exit 1; ++$pix; } exit not $pix;'; then
+				echo "$X has no alpha, converting"
+				convert "$X" -quality 100 "${X%.*}.jpg"
+				jpegoptim --strip-all -m$qual "${X%.*}.jpg"
+				rm -f "$X"
+			else
+				echo "$X has alpha, not converting"
+			fi
+			;;
+	esac
+done

Copied: trunk/misc/tools/makebuild.sh (from rev 5538, trunk/misc/makebuild.sh)
===================================================================
--- trunk/misc/tools/makebuild.sh	                        (rev 0)
+++ trunk/misc/tools/makebuild.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,377 @@
+#!/bin/bash
+
+set -e
+
+# Options:
+#   pw=foo          extract password
+#   version=2.5     make a FINAL build
+#   tag=FOO         insert FOO before the date in build names
+
+base=`pwd`
+
+# customizable specific stuff
+basepk3=$base/data20080229.pk3 # 2.4
+hotbasepk3= # hotfix
+nexdir=$base/nexuiz
+havocdir=$base/nexuiz/havoc
+dpdir=$base/darkplaces
+tmpdir=/tmp/NEX
+zipdir=$base/builds
+buildfiles=$base/nexuiz/misc/buildfiles
+mingwdlls=$buildfiles/w32
+osxapps=$buildfiles/osx
+copystrip=$buildfiles/copystrip
+zipdiff=$base/nexuiz/misc/tools/zipdiff
+fteqccdir="$base/fteqcc"
+fteqccflags=""
+menuqc=menu
+newest=NEWEST
+aft="perl -I/chroot/debian-etch/usr/share/aft /chroot/debian-etch/usr/bin/aft"
+# end system specific stuff
+
+case "$pw" in
+	'')
+		zipflags=
+		;;
+	*)
+		zipflags="-P $pw"
+		;;
+esac
+
+: ${date:=`date +%Y%m%d`}
+: ${versiontag:=}
+echo "date stamp: $date"
+
+case "$version" in
+	'')
+		version=2-svntest-$date
+		versiontag=test
+		defaultcfg=
+		ext=
+		;;
+	*)
+		version=$version
+		versiontag=$versiontag
+		defaultcfg=
+		ext=_$version
+		;;
+esac
+
+mk7z()
+{
+	7za a -tzip -mx=9 "$@"
+	chmod 644 "$1"
+}
+
+#if [ -n "$EXPERIMENTAL" ]; then
+#	basepk3=$base/data20071231.pk3 # newer build to make smaller patches
+#	nexdir=$base/nexuiz
+#fi
+
+# TODO normalize the builds
+platforms='x86 amd64 osx'
+buildon()
+{
+	host=$1
+	prefix=$2
+	fteqccname=$3
+	path=$4
+	makeflags=$5
+	strip=$6
+
+	fteqcc_cflags=
+	case "$fteqccname" in
+		*.exe)
+			fteqcc_cflags=win
+			;;
+	esac
+
+	rm -f "$fteqccdir"/*.o
+	rm -f "$fteqccdir"/*.bin
+	rsync --exclude "*.o" --exclude "*.d" --exclude "nexuiz-*" --delete-excluded --delete -zvaSHP . "$copystrip" "$fteqccdir" "$host:$path"
+	ssh "$host" ". ~/.profile && cd $path && COPYSTRIP_STRIP=$strip PATH=$path/copystrip:\$PATH make $makeflags clean nexuiz && cd ${fteqccdir##*/} && make $makeflags $fteqcc_cflags"
+	rsync --exclude "*.o" --exclude "*.d" --delete-excluded --delete -zvaSHP "$host:$path/." .
+	for P in -dedicated -sdl -glx -wgl -agl -dedicated.exe -sdl.exe .exe; do
+		[ -f nexuiz$P ] && mv nexuiz$P "$tmpdir/$prefix$P"
+		[ -f nexuiz$P-withdebug ] && mv nexuiz$P-withdebug "$tmpdir/debuginfo/$prefix$P"
+	done
+	case "$fteqccname" in
+		*.exe)
+			mv "${fteqccdir##*/}"/fteqcc.exe "$tmpdir/fteqcc/$fteqccname"
+			;;
+		*)
+			mv "${fteqccdir##*/}"/fteqcc.bin "$tmpdir/fteqcc/$fteqccname"
+			;;
+	esac
+	make clean
+}
+
+build()
+{
+	buildon nexmacbuild                           nexuiz-osx          fteqcc-osx          /tmp/Darkplaces.build 'CC="gcc -g -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"' strip
+	buildon eos.thruhere.net                      nexuiz-linux-686    fteqcc-linux-686    /tmp/Darkplaces.build 'CC="gcc -g" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-i386/lib' strip
+	buildon alientrap.org                         nexuiz-linux-x86_64 fteqcc-linux-x86_64 /tmp/Darkplaces.build 'CC="gcc -g -Wl,--hash-style=sysv" DP_MODPLUG_STATIC_LIBDIR=/home/divverent/modplug-x86_64/lib' strip
+	buildon alientrap.org                         nexuiz              fteqcc.exe          /tmp/Darkplaces.build 'DP_MAKE_TARGET=mingw CC="/chroot/debian-etch/usr/bin/i586-mingw32msvc-gcc -g -DSUPPORTDIRECTX -I/home/divverent/dxheaders" WINDRES=/chroot/debian-etch/usr/bin/i586-mingw32msvc-windres SDL_CONFIG=/home/divverent/sdl-win32/SDL-1.2.13/bin/sdl-config' /chroot/debian-etch/usr/bin/i586-mingw32msvc-strip
+		mv "$tmpdir/nexuiz-osx-agl"     "$tmpdir/Nexuiz.app/Contents/MacOS/nexuiz-osx-agl-bin"
+		mv "$tmpdir/nexuiz-osx-sdl"     "$tmpdir/Nexuiz-SDL.app/Contents/MacOS/nexuiz-osx-sdl-bin"
+}
+
+# avoid dupes
+i=
+while [ -f "$zipdir/nexuiz$date$i$ext.zip" ]; do
+	if [ -z "$i" ]; then
+		i=a
+	else
+		i=`echo "$i" | tr a-y b-z`
+	fi
+done
+ext=$i$ext
+
+echo "Using build name nexuiz$date$ext"
+sleep 3
+
+# check for remains
+conflicts=`find "$dpdir" "$nexdir" -name '*.orig' -o -name '*.rej' -o -name '*.mine' -o -name '.#*' -o -name '.*~'`
+if [ -n "$conflicts" ]; then
+	echo "CONFLICTS OR UNNEEDED FILES HAVE BEEN FOUND!"
+	echo "NOT PROCEEDING"
+	echo
+	echo "$conflicts"
+	exit 1
+fi
+
+set -x
+
+# prepare temp dir
+rm -rf "$tmpdir"
+mkdir -p "$tmpdir"
+
+# clean up and patch DP
+cd "$dpdir"
+quilt pop -a || true
+svn revert -R .
+if [ -s patches/series ]; then
+	quilt push -a # apply all patches
+fi
+
+# prepare directory structure
+cp -r "$osxapps"/*.app "$tmpdir"
+mkdir "$tmpdir/debuginfo"
+mkdir "$tmpdir/fteqcc"
+
+# prepare fteqcc build
+svn export "$fteqccdir" "$tmpdir/fteqcc/source"
+svn info "$fteqccdir" > "$tmpdir/fteqcc/source/fteqcc-base-revision.txt"
+fteqccrev=$((`grep "Last Changed Rev:" "$tmpdir/fteqcc/source/fteqcc-base-revision.txt" | cut -d : -f 2`))
+echo "fteqcc rev $fteqccrev"
+
+# build all executables
+rm -f *.exe nexuiz-* *-withdebug* *.o
+make clean
+build
+rm -f *.exe nexuiz-* *-withdebug '.#'* *.o
+rm -rf fteqcc copystrip
+make clean
+
+# move shell scripts and license
+cd "$tmpdir"
+cp "$nexdir/"nexuiz-*.sh "$tmpdir/"
+cp "$nexdir/gpl.txt" "$tmpdir/"
+
+# prepare data
+cd "$nexdir/data"
+svn export . "$tmpdir/data"
+svn info . > "$tmpdir/data/nexuiz-data-base-revision.txt"
+svn log > "$tmpdir/data/ChangeLog"
+
+# prepare havoc
+cd "$havocdir"
+svn export . "$tmpdir/havoc"
+
+# prepare Docs
+cd "$nexdir/Docs"
+svn export . "$tmpdir/Docs"
+
+# prepare server
+cd "$nexdir/server"
+svn export . "$tmpdir/server"
+
+# make gamesource
+cd "$tmpdir/data"
+mkdir -p "$tmpdir/sources"
+mk7z ../sources/gamesource$date.zip qcsrc nexuiz-data-base-revision.txt ChangeLog
+
+# make enginesource
+cd "$dpdir"
+svn export . "$tmpdir/darkplaces"
+svn info > "$tmpdir/darkplaces/nexuiz-base-revision.txt"
+svn diff > "$tmpdir/darkplaces/nexuiz-engine-changes.diff"
+svn log > "$tmpdir/darkplaces/ChangeLog"
+cd "$tmpdir"
+mk7z "$tmpdir/sources/enginesource$date.zip" "darkplaces"
+rm -rf darkplaces
+
+# make fteqcc archive
+cd "$tmpdir"
+zip -9r "$tmpdir/sources/fteqcc-binaries-and-source-rev$fteqccrev.zip" "fteqcc"
+rm -rf fteqcc
+
+# clean fteqcc dir
+cd "$fteqccdir"
+rm -f *.o *.bin
+make
+
+# make local compiler
+cd "$tmpdir/data"
+make FTEQCC="$fteqccdir/fteqcc.bin"
+
+# prepare root
+rm -rf "$tmpdir/data/qcsrc"
+cd "$tmpdir/Docs"
+perl -pi -e '/^#---SET nexversion=([0-9.]*)$/ and $_ = "#---SET nexversion='$version'\n"' FAQ.aft
+perl -pi -e '/^\s*Version ([0-9.]*)<\/div>$/ and $_ = "Version '$version'</div>\n"' Readme.htm
+cp "$dpdir/darkplaces.txt" .
+$aft FAQ.aft
+$aft FAQ.aft
+rm FAQ.aft-TOC
+cd "$tmpdir/data"
+mv common-spog.pk3 ..
+perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version'\n"' default.cfg
+if [ -n "$versiontag" ]; then
+	perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
+	cp "$buildfiles/brand/$versiontag.tga" gfx/brand.tga
+fi
+echo >> default.cfg
+echo "$defaultcfg" >> default.cfg
+mk7z ../data.pk3 .
+cd "$tmpdir/havoc"
+perl -pi -e '/^set g_nexuizversion "?([0-9.]*)[^"]*"?/ and $_ = "set g_nexuizversion '$version-havoc'\n"' default.cfg
+if [ -n "$versiontag" ]; then
+	perl -pi -e '/^set g_nexuizversion/ and $_ = "showbrand 3\n$_"' default.cfg
+fi
+echo >> default.cfg
+echo "$defaultcfg" >> default.cfg
+mk7z ../havoc.pk3 .
+
+# make data pk3
+cd "$tmpdir"
+rm -rf data
+mkdir data
+mv data.pk3 data/data$tag$date.pk3
+mv common-spog.pk3 data/
+rm -rf havoc
+mkdir havoc
+mv havoc.pk3 havoc/data$tag${date}havoc.pk3
+
+cp -r "$mingwdlls"/* .
+# fix up permissions
+chmod 644 *.dll *.exe
+
+# make main structure
+mkdir Nexuiz
+mv * Nexuiz/ || true
+
+find . -name .svn -exec rm -rf {} \; -prune
+
+rm -f "$zipdir/nexuiz$date$ext.zip"
+zip $zipflags -9yr "$zipdir/nexuiz$date$ext.zip"           Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/data$tag$date.pk3 Nexuiz/data/common-spog.pk3 Nexuiz/havoc/*
+ln -snf nexuiz$date$ext.zip "$zipdir/nexuiz-$newest.zip"
+
+rm -f "$zipdir/nexuizengineonly$date$ext.zip"
+zip $zipflags -9yr "$zipdir/nexuizengineonly$date$ext.zip" Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll
+ln -snf nexuizengineonly$date$ext.zip "$zipdir/nexuizengineonly-$newest.zip"
+
+rm -f "$zipdir/nexuizsource$date$ext.zip"
+zip $zipflags -9yr "$zipdir/nexuizsource$date$ext.zip"     Nexuiz/gpl.txt                                            Nexuiz/sources
+ln -snf nexuizsource$date$ext.zip "$zipdir/nexuizsource-$newest.zip"
+
+# TODO remove these excludes after the version after 2.4.2
+$zipdiff -o "Nexuiz/data/datapatch$tag$date.pk3" -f "$basepk3" -t Nexuiz/data/data$tag$date.pk3 \
+	-x 'sound/cdtracks/track*.ogg' \
+	-x 'sound/cdtracks/brainsukker.ogg' \
+	-x 'sound/cdtracks/breakdown-easy.ogg' \
+	-x 'sound/cdtracks/calling-bogus.ogg' \
+	-x 'sound/cdtracks/chaos-fog.ogg' \
+	-x 'sound/cdtracks/digital-pursuit.ogg' \
+	-x 'sound/cdtracks/infight.ogg' \
+	-x 'sound/cdtracks/neuronal-diving.ogg' \
+	-x 'sound/cdtracks/subcities.ogg' \
+	-x 'sound/cdtracks/thru-the-mirror.ogg'
+mkdir -p sound/cdtracks
+ln -snf track001.ogg sound/cdtracks/digital-pursuit.ogg
+ln -snf track002.ogg sound/cdtracks/breakdown-easy.ogg
+ln -snf track003.ogg sound/cdtracks/brainsukker.ogg
+ln -snf track004.ogg sound/cdtracks/chaos-fog.ogg
+ln -snf track005.ogg sound/cdtracks/infight.ogg
+ln -snf track006.ogg sound/cdtracks/neuronal-diving.ogg
+ln -snf track007.ogg sound/cdtracks/subcities.ogg
+ln -snf track008.ogg sound/cdtracks/thru-the-mirror.ogg
+ln -snf track009.ogg sound/cdtracks/calling-bogus.ogg
+zip -9yr "Nexuiz/data/datapatch$tag$date.pk3" sound/cdtracks/*
+rm -rf sound
+[ -n "$hotbasepk3" ] && $zipdiff -o "Nexuiz/data/datapatch$tag$date""hotfix.pk3" -f "$hotbasepk3" -t Nexuiz/data/data$tag$date.pk3
+mkdir -p gfx
+if unzip "Nexuiz/data/data$tag$date.pk3" gfx/brand.tga; then
+	zip -9r "Nexuiz/data/datapatch$tag$date.pk3" gfx/brand.tga
+	[ -n "$hotbasepk3" ] && zip -9r "Nexuiz/data/datapatch$tag$date""hotfix.pk3" gfx/brand.tga
+	rm -rf gfx
+fi
+
+rm -f "$zipdir/nexuizpatch$date$ext.zip"
+zip $zipflags -9yr "$zipdir/nexuizpatch$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/datapatch$tag$date.pk3 Nexuiz/havoc/*
+ln -snf nexuizpatch$date$ext.zip "$zipdir/nexuizpatch-$newest.zip"
+
+[ -n "$hotbasepk3" ] && rm -f "$zipdir/nexuizhotfix$date$ext.zip"
+[ -n "$hotbasepk3" ] && zip $zipflags -9yr "$zipdir/nexuizhotfix$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/nexuiz* Nexuiz/Nexuiz* Nexuiz/*.dll Nexuiz/sources Nexuiz/Docs Nexuiz/server Nexuiz/data/datapatch$tag$date""hotfix.pk3 Nexuiz/havoc/*
+[ -n "$hotbasepk3" ] && ln -snf nexuizhotfix$date$ext.zip "$zipdir/nexuizhotfix-$newest.zip"
+
+rm -f "$zipdir/nexuizdocs$date$ext.zip"
+zip $zipflags -9yr "$zipdir/nexuizdocs$date$ext.zip"       Nexuiz/gpl.txt Nexuiz/Docs
+ln -snf nexuizdocs$date$ext.zip "$zipdir/nexuizdocs-$newest.zip"
+
+rm -f "$zipdir/nexuizdebug$date$ext.zip"
+zip $zipflags -9yr "$zipdir/nexuizdebug$date$ext.zip"      Nexuiz/gpl.txt Nexuiz/debuginfo/* Nexuiz/sources
+ln -snf nexuizdebug$date$ext.zip "$zipdir/nexuizdebug-$newest.zip"
+
+case "$versiontag" in
+	test)
+		;;
+	*)
+		cat <<'EOF'
+
+NOTE: This is a RELEASE BUILD.
+
+To upload and finish the build, these things have to be done:
+
+- Test the build:
+  - On Linux/ATI
+  - On Vista/nvidia
+  - On Vista/ATI
+  - On Vista/Intel
+  - On OSX/ATI
+  - Turn on "developer 1"; watch out for suspicious messages.
+  - While testing, make sure all campaign levels are tested. In CTF/KH levels,
+    try to do a capture. After that, finish the game by prvm_edictset server 1
+    frags 1000.
+  - Play on a server running the new code. Ideally, that server should be public
+    and "somewhat compatible" to old clients, and some other players should be
+    on it.
+- Post the build on the forum as a test release. E.g. run this script again
+  with the "version" variable NOT SET, so the build gets marked "testing only",
+  and upload it and post it on the forum for testing. Mention the test server
+  that is already running the new code. Wait for at least one week for critical
+  bug reports.
+- If needed, fix the reported bugs and re-run this script for a release build.
+  Possibly repeat the testing process.
+- Upload the "final" build you have just made to Sourceforge (upload.sf.net,
+  incoming). Use the naming scheme nexuiz-25.zip, nexuizpatch-24-to-25.zip
+- Make the download available on sourceforge.
+- Announce the build on the forum; update the downloads website. Note that the
+  download may be still unavailable because of the SF mirror system.
+- Wait for the mirrors to catch up.
+- Edit the website: make a new news item for the new release, change the logo
+  image in the top left for the new version (ask [-z-]).
+
+EOF
+		;;
+esac

Copied: trunk/misc/tools/nexuiz-map-compiler (from rev 5536, trunk/misc/nexuiz-map-compiler)
===================================================================
--- trunk/misc/tools/nexuiz-map-compiler	                        (rev 0)
+++ trunk/misc/tools/nexuiz-map-compiler	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,233 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use POSIX;
+
+# change these to match your system, or define them in ~/.nexuiz-map-compiler
+# (just copy paste this part to the file ~/.nexuiz-map-compiler)
+
+	# Path to Nexuiz (where the data directory is in)
+	our $NEXUIZDIR   = '/home/polzer/Nexvn/nexuiz';
+
+	# Path to your q3map2 program. You find it in your GtkRadiant/install
+	# directory.
+	our $Q3MAP2      = '/home/users4/ommz/polzer/bin/q3map2.x86';
+
+	# General flags for q3map2 (for example -threads 4)
+	our $Q3MAP2FLAGS = '';
+
+	# Default flags for the -bsp stage
+	our $BSPFLAGS    = '-samplesize 8 -minsamplesize 4 -mv 1000000 -mi 6000000';
+
+	# Default flags for the -vis stage
+	our $VISFLAGS    = '';
+
+	# Default flags for the -light stage
+	our $LIGHTFLAGS  = '-deluxe -patchshadows -samples 3 -lightmapsize 512 -bounce 8 -fastbounce -bouncegrid';
+
+# end of user changable part
+
+do "$ENV{HOME}/.nexuiz-map-compiler";
+
+sub Usage()
+{
+	print <<EOF;
+Usage:
+$0 mapname [-bsp bspflags...] [-vis visflags...] [-light lightflags...]
+EOF
+	exit 1;
+}
+
+my $options =
+{
+	bsp => [split /\s+/, $BSPFLAGS],
+	vis => [split /\s+/, $VISFLAGS],
+	light => [split /\s+/, $LIGHTFLAGS],
+	maps => [],
+	scale => 1
+};
+
+my $curmode = 'maps';
+
+while(@ARGV)
+{
+	$_ = shift @ARGV;
+	my $enterflags = undef;
+	if($_ eq '-bsp' or $_ eq '-meta')
+	{
+		$enterflags = 'bsp';
+	}
+	elsif($_ eq '-vis')
+	{
+		$enterflags = 'vis';
+	}
+	elsif($_ eq '-light')
+	{
+		$enterflags = 'light';
+	}
+	elsif($_ eq '-map')
+	{
+		$curmode = 'maps';
+	}
+	elsif($_ eq '-scale')
+	{
+		$options->{scale} = (shift @ARGV) || 1;
+	}
+	elsif($_ eq '-novis')
+	{
+		$options->{vis} = undef;
+	}
+	elsif($_ eq '-nolight')
+	{
+		$options->{light} = undef;
+	}
+	elsif($_ =~ /^-/ and $curmode eq 'maps')
+	{
+		$curmode = 'bsp';
+		push @{$options->{$curmode}}, $_;
+	}
+	else
+	{
+		push @{$options->{$curmode}}, $_;
+	}
+	if(defined $enterflags)
+	{
+		$curmode = $enterflags;
+		if($ARGV[0] eq '+')
+		{
+			shift @ARGV;
+		}
+		else
+		{
+			$options->{$curmode} = [];
+		}
+	}
+}
+
+my $game = 'compile.' . int rand 99999999; # mktemp on win32?
+
+sub q3map2(@)
+{
+	my @args = ($Q3MAP2, split(/\s+/, $Q3MAP2FLAGS), '-game', 'nexuiz', '-fs_basepath', $NEXUIZDIR, '-fs_game', $game, '-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.";
+};
+
+my ($prescale, $postscale) = ($options->{scale} =~ /^([0-9.]+)(?::([0-9.]+))?$/);
+$postscale = 1 if not defined $postscale;
+
+for my $m(@{$options->{maps}})
+{
+	if($prescale != 1 or $postscale != 1)
+	{
+		open my $checkfh, "<", "$m.map"
+			or die "open $m.map: $!";
+		my $keeplights = 0;
+		while(<$checkfh>)
+		{
+			/^\s*"_keeplights"\s+"1"\s*$/
+				or next;
+			$keeplights = 1;
+		}
+		close $checkfh;
+		die "$m does not define _keeplights to 1"
+			unless $keeplights;
+	}
+
+	my %shaders = map { m!/([^/.]*)\.shader(?:$)! ? ($1 => 1) : () } glob "../scripts/*.shader";
+	open my $shaderlist, "+<", "$NEXUIZDIR/data/scripts/shaderlist.txt"
+		or die "open $NEXUIZDIR/data/scripts/shaderlist.txt: $!";
+	my $previous_shaderlist = "";
+	while(<$shaderlist>)
+	{
+		$previous_shaderlist .= $_;
+		y/\r\n//d;
+		delete $shaders{$_};
+	}
+	my $restore_shaderlist = sub
+	{
+		open $shaderlist, ">", "$NEXUIZDIR/data/scripts/shaderlist.txt";
+		print $shaderlist $previous_shaderlist;
+		close $shaderlist;
+	};
+	local $SIG{INT} = sub
+	{
+		print "SIGINT caught, cleaning up...\n";
+		$restore_shaderlist->();
+		exit 0;
+	};
+	eval
+	{
+		for(keys %shaders)
+		{
+			print $shaderlist "$_\n";
+		}
+		close $shaderlist;
+
+		unlink <$m/lm_*>; # delete old external lightmaps
+		q3map2 '-bsp', '-meta', @{$options->{bsp}},   "$m.map"
+			or die "-bsp: $?";
+		if($prescale != 1)
+		{
+			q3map2 '-scale', $prescale, "$m.bsp"
+				or die "-scale: $?";
+			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($postscale != 1)
+		{
+			q3map2 '-scale', $postscale, "$m.bsp"
+				or die "-scale: $?";
+			rename "${m}_s.bsp", "$m.bsp"
+				or die "rename ${m}_s.bsp $m.bsp: $!";
+		}
+
+		unlink "$m.srf";
+
+		$restore_shaderlist->();
+		1;
+	}
+	or do
+	{
+		$restore_shaderlist->();
+		die $@;
+	};
+}

Copied: trunk/misc/tools/polycount.pl (from rev 5536, trunk/misc/polycount.pl)
===================================================================
--- trunk/misc/tools/polycount.pl	                        (rev 0)
+++ trunk/misc/tools/polycount.pl	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+for(@ARGV)
+{
+	my $data = do {
+		open my $fh, "<", $_;
+		undef local $/;
+		<$fh>;
+	};
+
+	my $vertex = undef;
+	my $poly = undef;
+	my $type = undef;
+
+	if("IDP3" eq substr $data, 0, 4)
+	{
+		# MD3 model
+		my $num_meshes = unpack "V", substr $data, 4+4+64+4+4+4, 4;
+		my $ofs_meshes = unpack "V", substr $data, 4+4+64+4+4+4+4+4+4+4, 4;
+		$vertex = $poly = 0;
+		for(1..$num_meshes)
+		{
+			$vertex     += unpack "V", substr $data, $ofs_meshes+4+64+4+4+4, 4;
+			$poly       += unpack "V", substr $data, $ofs_meshes+4+64+4+4+4+4, 4;
+			$ofs_meshes += unpack "V", substr $data, $ofs_meshes+4+64+4+4+4+4+4+4+4+4+4, 4;
+		}
+		$type = "md3";
+	}
+	elsif("ZYMOTICMODEL" eq substr $data, 0, 12)
+	{
+		# ZYM model
+		$vertex = unpack "N", substr $data, 12+4+4+4*3+4*3+4, 4;
+		$poly   = unpack "N", substr $data, 12+4+4+4*3+4*3+4+4, 4;
+		$type = "zym";
+	}
+
+	if(defined $type)
+	{
+		printf "%8d %8d %-3s %s\n", $vertex, $poly, $type, $_;
+	}
+	else
+	{
+		printf "%8s %8s %-3s %s\n", "-", "-", "-", $_;
+	}
+}

Copied: trunk/misc/tools/spherefunc2skybox.c (from rev 5536, trunk/misc/spherefunc2skybox.c)
===================================================================
--- trunk/misc/tools/spherefunc2skybox.c	                        (rev 0)
+++ trunk/misc/tools/spherefunc2skybox.c	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,269 @@
+#include <stdio.h>
+#include <err.h>
+#include <stdint.h>
+#include <math.h>
+#include <string.h>
+#include <stdlib.h>
+
+double rnd()
+{
+	return rand() / (RAND_MAX + 1.0);
+}
+
+typedef void (*mapfunc_t) (double x_in, double y_in, double *x_out, double *y_out, double *z_out);
+typedef void (*colorfunc_t) (double x, double y, double z, double *r, double *g, double *b);
+
+void color_test(double x, double y, double z, double *r, double *g, double *b)
+{
+	// put in a nice function here
+	*r = 0.5 + 0.5 * x;
+	*g = 0.5 + 0.5 * y;
+	*b = 0.5 + 0.5 * z;
+}
+
+double mandelbrot_iter(double zx, double zy, double cx, double cy, int maxiter)
+{
+	double tmp;
+	int i;
+
+	double f, fprev;
+
+	f = 0;
+
+	for(i = 1; i < maxiter; ++i)
+	{
+		tmp = zx;
+		zx = zx * zx - zy * zy + cx;
+		zy = 2 * tmp * zy + cy;
+		fprev = f;
+		f = zx * zx + zy * zy;
+		if(f > 4)
+			break;
+	}
+
+	if(i >= maxiter)
+		return i;
+	else
+	{
+		// f: the greater, the more in 0 direction
+		//    the smaller, the more in 1 direction
+		// fprev:
+		//    the greater, the more in 0 direction
+		return i + 1 / (f - 4 + 1); // f = 16: + 0, f = 4: + 1
+	}
+	// i.e. 0 for i=1, 1 for i=maxiter
+}
+
+double mandelbrot_range(double zx, double zy, double cx, double cy, int maxiter, double offset)
+{
+	double i = mandelbrot_iter(zx, zy, cx, cy, maxiter);
+	// map linearily 1/(offset + iter) so that:
+	//   0       -> 0
+	//   maxiter -> 1
+	// i.e. solve:
+	//   f(iter) = A/(offset + iter) + B
+	// that is:
+	//   f(0)       = A/offset + B = 0
+	//   f(maxiter) = A/(offset + maxiter) + B = 1
+	// -->
+	//   1/(1/(offset + maxiter) - 1/offset) = A
+	//   B =          1 + offset / maxiter
+	//   A = -offset (1 + offset / maxiter)
+	// -->
+	//   f(iter) = -offset (1 + offset / maxiter) / (offset + iter) + 1 + offset / maxiter
+	//           = -offset (1 + offset / maxiter) / (offset + iter) + 1 + offset / maxiter
+	//           = iter (offset + maxiter)   /   maxiter (offset + iter)
+	return (i * (offset + maxiter)) / ((i + offset) * maxiter);
+}
+
+double color_mandelbrot_parms[13];
+double mandelbrot_miniter = -1;
+#define MAXITER 8192
+
+double iter_mandelbrot_raw(double x, double y, double z)
+{
+	z -= color_mandelbrot_parms[6];
+	x /= fabs(z);
+	y /= fabs(z);
+
+	if(z > 0)
+		return mandelbrot_range(color_mandelbrot_parms[4], color_mandelbrot_parms[5], color_mandelbrot_parms[0] + x * color_mandelbrot_parms[2], color_mandelbrot_parms[1] + y * color_mandelbrot_parms[3], MAXITER, color_mandelbrot_parms[9]);
+	else
+		return 0;
+}
+
+void iter_mandelbrot_raw_initialize_min()
+{
+	if(mandelbrot_miniter >= 0)
+		return;
+	// randomly sample 256 points
+	// mandelbrot them
+	// set that as miniter
+	int i = 0;
+	double x, y, z;
+	mandelbrot_miniter = MAXITER;
+	for(i = 0; i < 8192; ++i)
+	{
+		x = rnd() * 2 - 1;
+		y = rnd() * 2 - 1;
+		z = rnd() * 2 - 1;
+		double f = sqrt(x*x + y*y + z*z);
+		x /= f;
+		y /= f;
+		z /= f;
+		double a = (z - color_mandelbrot_parms[6]) / (color_mandelbrot_parms[7] - color_mandelbrot_parms[6]);
+		a = (a - color_mandelbrot_parms[8]) / (1 - color_mandelbrot_parms[8]);
+		if(a < 1)
+			continue;
+		double iterations = iter_mandelbrot_raw(x, y, z);
+		if(iterations == 0)
+			continue;
+		if(iterations < mandelbrot_miniter)
+			mandelbrot_miniter = iterations;
+	}
+}
+
+void color_mandelbrot(double x, double y, double z, double *r, double *g, double *b)
+{
+	iter_mandelbrot_raw_initialize_min();
+
+	double iterations = iter_mandelbrot_raw(x, y, z);
+	//printf("iter = %f\n", iterations);
+	double a = (z - color_mandelbrot_parms[6]) / (color_mandelbrot_parms[7] - color_mandelbrot_parms[6]);
+	a = (a - color_mandelbrot_parms[8]) / (1 - color_mandelbrot_parms[8]);
+	if(a < 0)
+		a = 0;
+	if(a > 1)
+		a = 1;
+	iterations = iterations * a + mandelbrot_miniter * (1-a);
+	*r = pow(iterations, color_mandelbrot_parms[10]);
+	*g = pow(iterations, color_mandelbrot_parms[11]);
+	*b = pow(iterations, color_mandelbrot_parms[12]);
+}
+
+void map_back(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
+{
+	*x_out = 2 * x_in - 1;
+	*y_out = +1;
+	*z_out = 1 - 2 * y_in;
+}
+
+void map_right(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
+{
+	*x_out = +1;
+	*y_out = 1 - 2 * x_in;
+	*z_out = 1 - 2 * y_in;
+}
+
+void map_front(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
+{
+	*x_out = 1 - 2 * x_in;
+	*y_out = -1;
+	*z_out = 1 - 2 * y_in;
+}
+
+void map_left(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
+{
+	*x_out = -1;
+	*y_out = 2 * x_in - 1;
+	*z_out = 1 - 2 * y_in;
+}
+
+void map_up(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
+{
+	*x_out = 2 * y_in - 1;
+	*y_out = 1 - 2 * x_in;
+	*z_out = +1;
+}
+
+void map_down(double x_in, double y_in, double *x_out, double *y_out, double *z_out)
+{
+	*x_out = 1 - 2 * y_in;
+	*y_out = 1 - 2 * x_in;
+	*z_out = -1;
+}
+
+void writepic(colorfunc_t f, mapfunc_t m, const char *fn, int width, int height)
+{
+	int x, y;
+	uint8_t tga[18];
+
+	FILE *file = fopen(fn, "wb");
+	if(!file)
+		err(1, "fopen %s", fn);
+
+	memset(tga, 0, sizeof(tga));
+	tga[2] = 2;          // uncompressed type
+	tga[12] = (width >> 0) & 0xFF;
+	tga[13] = (width >> 8) & 0xFF;
+	tga[14] = (height >> 0) & 0xFF;
+	tga[15] = (height >> 8) & 0xFF;
+	tga[16] = 24;        // pixel size
+
+	fwrite(&tga, sizeof(tga), 1, file);
+	for(y = height-1; y >= 0; --y)
+		for(x = 0; x < width; ++x)
+		{
+			uint8_t rgb[3];
+			double rr, gg, bb;
+			double xx, yy;
+			double xxx, yyy, zzz;
+			double r;
+			xx = (x + 0.5) / width;
+			yy = (y + 0.5) / height;
+			m(xx, yy, &xxx, &yyy, &zzz);
+			r = sqrt(xxx*xxx + yyy*yyy + zzz*zzz);
+			xxx /= r;
+			yyy /= r;
+			zzz /= r;
+			f(xxx, yyy, zzz, &rr, &gg, &bb);
+			rgb[2] = floor(rnd() + rr * 255);
+			rgb[1] = floor(rnd() + gg * 255);
+			rgb[0] = floor(rnd() + bb * 255);
+			fwrite(rgb, sizeof(rgb), 1, file);
+		}
+	
+	fclose(file);
+}
+
+void map_all(const char *fn, colorfunc_t f, int width, int height)
+{
+	char buf[1024];
+	snprintf(buf, sizeof(buf), "%s_bk.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_back, buf, width, height);
+	snprintf(buf, sizeof(buf), "%s_ft.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_front, buf, width, height);
+	snprintf(buf, sizeof(buf), "%s_rt.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_right, buf, width, height);
+	snprintf(buf, sizeof(buf), "%s_lf.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_left, buf, width, height);
+	snprintf(buf, sizeof(buf), "%s_up.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_up, buf, width, height);
+	snprintf(buf, sizeof(buf), "%s_dn.tga", fn); buf[sizeof(buf) - 1] = 0; writepic(f, map_down, buf, width, height);
+}
+
+int main(int argc, char **argv)
+{
+	colorfunc_t f;
+	if(argc < 4)
+		errx(1, "usage: %s filename res func parms...", *argv);
+	int res = atoi(argv[2]);
+	if(!strcmp(argv[3], "mandel"))
+	{
+		f = color_mandelbrot;
+		color_mandelbrot_parms[0]  = argc<= 4 ?  -0.740 :  atof(argv[4]); // shift xy
+		color_mandelbrot_parms[1]  = argc<= 5 ?  -0.314 :  atof(argv[5]);
+		color_mandelbrot_parms[2]  = argc<= 6 ?  -0.003 :  atof(argv[6]); // mul xy
+		color_mandelbrot_parms[3]  = argc<= 7 ?  -0.003 :  atof(argv[7]);
+		color_mandelbrot_parms[4]  = argc<= 8 ?   0.420 :  atof(argv[8]); // shift z
+		color_mandelbrot_parms[5]  = argc<= 9 ?   0.000 :  atof(argv[9]);
+		color_mandelbrot_parms[6]  = argc<=10 ?  -0.8   : atof(argv[10]); // horizon
+		color_mandelbrot_parms[7]  = argc<=11 ?  -0.7   : atof(argv[11]);
+		color_mandelbrot_parms[8]  = argc<=12 ?   0.5   : atof(argv[12]);
+		color_mandelbrot_parms[9]  = argc<=13 ? 400     : atof(argv[13]); // coloring
+		color_mandelbrot_parms[10] = argc<=14 ?   0.6   : atof(argv[14]);
+		color_mandelbrot_parms[11] = argc<=15 ?   0.5   : atof(argv[15]);
+		color_mandelbrot_parms[12] = argc<=16 ?   0.2   : atof(argv[16]);
+	}
+	else
+	{
+		f = color_test;
+	}
+	map_all(argv[1], color_mandelbrot, res, res);
+	return 0;
+}

Copied: trunk/misc/tools/testbuild.sh (from rev 5536, trunk/misc/testbuild.sh)
===================================================================
--- trunk/misc/tools/testbuild.sh	                        (rev 0)
+++ trunk/misc/tools/testbuild.sh	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd nexuiz
+../darkplaces/nexuiz-glx "$@"

Copied: trunk/misc/tools/ttf2conchars (from rev 5536, trunk/misc/ttf2conchars)

Copied: trunk/misc/tools/zipdiff (from rev 5536, trunk/misc/zipdiff)
===================================================================
--- trunk/misc/tools/zipdiff	                        (rev 0)
+++ trunk/misc/tools/zipdiff	2009-01-15 11:30:44 UTC (rev 5541)
@@ -0,0 +1,171 @@
+#!/bin/sh
+
+usage()
+{
+	cat <<EOF
+Usage:
+  $0 -o difference.zip -f from.zip -t to.zip
+  $0 -f from.zip -t to.zip
+EOF
+	exit 1
+}
+
+output=
+from=
+to=
+excludes=
+
+while [ $# -gt 0 ]; do
+	o=$1
+	shift
+	case "$o" in
+		-o)
+			output=$1
+			shift
+			;;
+		-f)
+			from=$1
+			shift
+			;;
+		-t)
+			to=$1
+			shift
+			;;
+		-x)
+			excludes="$excludes $1"
+			shift
+			;;
+		*)
+			usage
+			;;
+	esac
+done
+
+[ -n "$from" ] || usage
+[ -n "$to" ] || usage
+
+found()
+{
+	type=$1
+	source=$2
+	echo >&2 "$type: $source"
+	case "$type" in
+		new|changed|deleted)
+			echo "$source"
+			;;
+		excluded)
+			;;
+		deleted|*)
+			echo >&2 " * Sorry, can't handle deletion of $source."
+			;;
+	esac
+}
+
+tempdir=`mktemp -d -t zipdiff.XXXXXX`
+
+newline="
+"
+fromlist="$(zipinfo -1 "$from" | grep -v /\$)"
+tolist="$(zipinfo -1 "$to" | grep -v /\$)"
+
+diffit()
+{
+	echo "$fromlist" | while IFS= read -r line; do
+		case "$newline$tolist$newline" in
+			*$newline$line$newline*)
+				;;
+			*)
+				isexcluded=false
+
+				for P in $excludes; do
+					case "$line" in
+						$P)
+							found excluded "$line"
+							isexcluded=true
+							break
+							;;
+					esac
+				done
+
+				if ! $isexcluded; then
+					found deleted "$line"
+				fi
+				;;
+		esac
+	done
+	echo "$tolist" | while IFS= read -r line; do
+		case "$newline$fromlist$newline" in
+			*$newline$line$newline*)
+				# check if equal
+				isexcluded=false
+
+				for P in $excludes; do
+					case "$line" in
+						$P)
+							found excluded "$line"
+							isexcluded=true
+							break
+							;;
+					esac
+				done
+
+				if ! $isexcluded; then
+					unzip -p "$from" "$line" > "$tempdir/v1"
+					unzip -p "$to" "$line" > "$tempdir/v2"
+					if ! diff --brief "$tempdir/v1" "$tempdir/v2" >/dev/null 2>&1; then
+						found changed "$line"
+					fi
+					rm "$tempdir/v1"
+					rm "$tempdir/v2"
+				fi
+				;;
+			*)
+				# check if equal
+				isexcluded=false
+
+				for P in $excludes; do
+					case "$line" in
+						$P)
+							found excluded "$line"
+							isexcluded=true
+							break
+							;;
+					esac
+				done
+
+				if ! $isexcluded; then
+					found new "$line"
+				fi
+				;;
+		esac
+	done
+}
+
+result=`diffit`
+
+case "$output" in
+	'')
+		;;
+	*)
+		rm -f "$output"
+		echo "$result" | while IFS= read -r line; do
+			echo >&2 "extracting $line..."
+			dline=./$line
+			mkdir -p "$tempdir/${dline%/*}"
+			unzip -p "$to" "$line" > "$tempdir/$line" # this may create an empty file - don't care, DP handles this as deletion
+		done
+		case "$output" in
+			/*)
+				;;
+			*)
+				output=`pwd`/$output
+				;;
+		esac
+		cd "$tempdir"
+		#zip -9r "$output" .
+		7za a -tzip -mx=9 "$output" .
+		cd ..
+		;;
+esac
+
+rm -rf "$tempdir"

Deleted: trunk/misc/zipdiff
===================================================================
--- trunk/misc/zipdiff	2009-01-15 10:23:53 UTC (rev 5540)
+++ trunk/misc/zipdiff	2009-01-15 11:30:44 UTC (rev 5541)
@@ -1,171 +0,0 @@
-#!/bin/sh
-
-usage()
-{
-	cat <<EOF
-Usage:
-  $0 -o difference.zip -f from.zip -t to.zip
-  $0 -f from.zip -t to.zip
-EOF
-	exit 1
-}
-
-output=
-from=
-to=
-excludes=
-
-while [ $# -gt 0 ]; do
-	o=$1
-	shift
-	case "$o" in
-		-o)
-			output=$1
-			shift
-			;;
-		-f)
-			from=$1
-			shift
-			;;
-		-t)
-			to=$1
-			shift
-			;;
-		-x)
-			excludes="$excludes $1"
-			shift
-			;;
-		*)
-			usage
-			;;
-	esac
-done
-
-[ -n "$from" ] || usage
-[ -n "$to" ] || usage
-
-found()
-{
-	type=$1
-	source=$2
-	echo >&2 "$type: $source"
-	case "$type" in
-		new|changed|deleted)
-			echo "$source"
-			;;
-		excluded)
-			;;
-		deleted|*)
-			echo >&2 " * Sorry, can't handle deletion of $source."
-			;;
-	esac
-}
-
-tempdir=`mktemp -d -t zipdiff.XXXXXX`
-
-newline="
-"
-fromlist="$(zipinfo -1 "$from" | grep -v /\$)"
-tolist="$(zipinfo -1 "$to" | grep -v /\$)"
-
-diffit()
-{
-	echo "$fromlist" | while IFS= read -r line; do
-		case "$newline$tolist$newline" in
-			*$newline$line$newline*)
-				;;
-			*)
-				isexcluded=false
-
-				for P in $excludes; do
-					case "$line" in
-						$P)
-							found excluded "$line"
-							isexcluded=true
-							break
-							;;
-					esac
-				done
-
-				if ! $isexcluded; then
-					found deleted "$line"
-				fi
-				;;
-		esac
-	done
-	echo "$tolist" | while IFS= read -r line; do
-		case "$newline$fromlist$newline" in
-			*$newline$line$newline*)
-				# check if equal
-				isexcluded=false
-
-				for P in $excludes; do
-					case "$line" in
-						$P)
-							found excluded "$line"
-							isexcluded=true
-							break
-							;;
-					esac
-				done
-
-				if ! $isexcluded; then
-					unzip -p "$from" "$line" > "$tempdir/v1"
-					unzip -p "$to" "$line" > "$tempdir/v2"
-					if ! diff --brief "$tempdir/v1" "$tempdir/v2" >/dev/null 2>&1; then
-						found changed "$line"
-					fi
-					rm "$tempdir/v1"
-					rm "$tempdir/v2"
-				fi
-				;;
-			*)
-				# check if equal
-				isexcluded=false
-
-				for P in $excludes; do
-					case "$line" in
-						$P)
-							found excluded "$line"
-							isexcluded=true
-							break
-							;;
-					esac
-				done
-
-				if ! $isexcluded; then
-					found new "$line"
-				fi
-				;;
-		esac
-	done
-}
-
-result=`diffit`
-
-case "$output" in
-	'')
-		;;
-	*)
-		rm -f "$output"
-		echo "$result" | while IFS= read -r line; do
-			echo >&2 "extracting $line..."
-			dline=./$line
-			mkdir -p "$tempdir/${dline%/*}"
-			unzip -p "$to" "$line" > "$tempdir/$line" # this may create an empty file - don't care, DP handles this as deletion
-		done
-		case "$output" in
-			/*)
-				;;
-			*)
-				output=`pwd`/$output
-				;;
-		esac
-		cd "$tempdir"
-		#zip -9r "$output" .
-		7za a -tzip -mx=9 "$output" .
-		cd ..
-		;;
-esac
-
-rm -rf "$tempdir"




More information about the nexuiz-commits mailing list