r4381 - in branches/nexuiz-2.0: . data data/qcsrc/client data/qcsrc/common data/qcsrc/server misc/gtkradiant misc/gtkradiant/singlepatches

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Sep 6 12:44:32 EDT 2008


Author: div0
Date: 2008-09-06 12:44:32 -0400 (Sat, 06 Sep 2008)
New Revision: 4381

Modified:
   branches/nexuiz-2.0/.patchsets
   branches/nexuiz-2.0/data/defaultNexuiz.cfg
   branches/nexuiz-2.0/data/qcsrc/client/Main.qc
   branches/nexuiz-2.0/data/qcsrc/client/main.qh
   branches/nexuiz-2.0/data/qcsrc/client/sbar.qc
   branches/nexuiz-2.0/data/qcsrc/common/constants.qh
   branches/nexuiz-2.0/data/qcsrc/common/util.qc
   branches/nexuiz-2.0/data/qcsrc/common/util.qh
   branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc
   branches/nexuiz-2.0/data/qcsrc/server/cl_impulse.qc
   branches/nexuiz-2.0/data/qcsrc/server/cl_weapons.qc
   branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc
   branches/nexuiz-2.0/data/qcsrc/server/defs.qh
   branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc
   branches/nexuiz-2.0/data/qcsrc/server/portals.qc
   branches/nexuiz-2.0/data/qcsrc/server/vote.qc
   branches/nexuiz-2.0/data/qcsrc/server/w_porto.qc
   branches/nexuiz-2.0/misc/gtkradiant/gtkradiant-nexuiz-patchset.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/both-obj.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/gtkradiant-targetname.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTavgcolorfix.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTfloodlight.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTlmexposure.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTtrianglecheck.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-decomptexcoords.diff
   branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-snapplane.diff
Log:
enable g_tourney by default and see if div^h^h^hanyone complains now that its just for 60 seconds, has a simply display in the scoreboard and does not start with all guns :-)
update the radiant patches: fix unnecessary whitespace at line ends, and update line numbers
"impulse 99": set unlimited ammo
portal crash fixes


Modified: branches/nexuiz-2.0/.patchsets
===================================================================
--- branches/nexuiz-2.0/.patchsets	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/.patchsets	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,2 +1,2 @@
 master = svn://svn.icculus.org/nexuiz/trunk
-revisions_applied = 1-4366
+revisions_applied = 1-4380

Modified: branches/nexuiz-2.0/data/defaultNexuiz.cfg
===================================================================
--- branches/nexuiz-2.0/data/defaultNexuiz.cfg	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/defaultNexuiz.cfg	2008-09-06 16:44:32 UTC (rev 4381)
@@ -137,9 +137,10 @@
 set g_maxplayers_spectator_blocktime 5 //if the players voted for the "nospectators" command, this setting defines the number of seconds a observer/spectator has time to join the game before he gets kicked
 
 //tournament mod
-set g_tourney 0 //enables tourney mode which splits the game into a warmup- and match-stage
+set g_tourney 1 //enables tourney mode which splits the game into a warmup- and match-stage
 set g_tourney_warmup_limit 60 //if set to -1 the warmup-stage is not affected by any timelimit, if set to 0 the usual timelimit also affects warmup-stage, otherwise warmup will be limited to this time (useful for public matches)
 set g_tourney_warmup_allow_timeout 0 //if set to 0 you cannot use the calltimeout command during the warmup-stage but only during the match stage
+set g_tourney_warmup_allguns 0 //if set players start with all guns in warmup mode
 set g_tourney_disable_spec_chat 1 //if set the chat sent by spectators or observers while being in match-stage can only seen by other specs/observers
 set g_tourney_disable_spec_vote 1 //if set only players can call a vote during the match-stage (thus spectators and observers can't call a vote then)
 set g_tourney_start_health 250 //starting values when being in warmup-stage

Modified: branches/nexuiz-2.0/data/qcsrc/client/Main.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/client/Main.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/client/Main.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -764,6 +764,11 @@
 	current_viewzoom = 0.6;
 }
 
+void Net_ReadWarmupStage()
+{
+	warmup_stage = ReadByte();
+}
+
 // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
 // You must ALWAYS first acquire the temporary ID, which is sent as a byte.
 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
@@ -823,6 +828,10 @@
 			Net_ReadHoldAngles();
 			bHandled = true;
 			break;
+		case TE_CSQC_WARMUP:
+			Net_ReadWarmupStage();
+			bHandled = true;
+			break;
 		default:
 			// No special logic for this temporary entity; return 0 so the engine can handle it
 			bHandled = false;

Modified: branches/nexuiz-2.0/data/qcsrc/client/main.qh
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/client/main.qh	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/client/main.qh	2008-09-06 16:44:32 UTC (rev 4381)
@@ -122,5 +122,6 @@
 float zoomin_effect;
 float ignore_plus_zoom;
 float ignore_minus_zoom;
+float warmup_stage;
 
 float weaponimpulse[24];

Modified: branches/nexuiz-2.0/data/qcsrc/client/sbar.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/client/sbar.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/client/sbar.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -931,9 +931,17 @@
 		}
 	}
 	
+
 	pos_y += 1.5 * sbar_fontsize_y;
 	drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - sbar_fontsize_x * stringwidth(str, TRUE)), str, sbar_fontsize, 0.8, 0);
 
+	if(warmup_stage) 
+	{
+		str = "^1Currently just warmup phase";
+		pos_y += 1.5 * sbar_fontsize_y;
+		drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - sbar_fontsize_x * stringwidth(str, TRUE)), str, sbar_fontsize, 0.8, 0);
+	}
+	
 	sbar = sbar_save;
 }
 

Modified: branches/nexuiz-2.0/data/qcsrc/common/constants.qh
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/common/constants.qh	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/common/constants.qh	2008-09-06 16:44:32 UTC (rev 4381)
@@ -16,7 +16,8 @@
 // Revision 15: zoom
 // Revision 16: multi-weapons
 // Revision 17: multi-weaponimpulses
-#define CSQC_REVISION 17
+// Revision 18: warmup
+#define CSQC_REVISION 18
 
 // probably put these in common/
 // so server/ and client/ can be synced better
@@ -203,6 +204,7 @@
 const float TE_CSQC_SPAWN = 112;
 const float TE_CSQC_ZOOMNOTIFY = 113;
 const float TE_CSQC_HOLDANGLES = 114;
+const float TE_CSQC_WARMUP = 115;
 
 const float STAT_KH_KEYS = 32;
 const float STAT_CTF_STATE = 33;

Modified: branches/nexuiz-2.0/data/qcsrc/common/util.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/common/util.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/common/util.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -633,9 +633,9 @@
 	return 1;
 }
 
-// a makevectors that inverts vectoangles
 void fixedmakevectors(vector a)
 {
+	// a makevectors that actually inverts vectoangles
 	a_x = -a_x;
 	makevectors(a);
 }

Modified: branches/nexuiz-2.0/data/qcsrc/common/util.qh
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/common/util.qh	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/common/util.qh	2008-09-06 16:44:32 UTC (rev 4381)
@@ -70,4 +70,6 @@
 float CheckWireframeBox(entity forent, vector v0, vector dvx, vector dvy, vector dvz);
 
 void fixedmakevectors(vector a);
+#define fixedvectoangles2 vectoangles2
+#define fixedvectoangles vectoangles
 #endif

Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -586,6 +586,11 @@
 		WriteEntity(MSG_ONE, self);
 	}
 
+	msg_entity = self;
+	WriteByte(MSG_ONE, SVC_TEMPENTITY);
+	WriteByte(MSG_ONE, TE_CSQC_WARMUP);
+	WriteByte(MSG_ONE, !tourneyInMatchStage);
+
 	// player is dead and becomes observer
 	// FIXME fix LMS scoring for new system
 	if(g_lms)

Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_impulse.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_impulse.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_impulse.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -255,6 +255,7 @@
 			{
 				case 99:
 					self.weapons |= WEPBIT_ALL;
+					self.items |= IT_UNLIMITED_AMMO;
 					self.ammo_shells = g_pickup_shells_max;
 					self.ammo_nails = g_pickup_nails_max;
 					self.ammo_rockets = g_pickup_rockets_max;

Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_weapons.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_weapons.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_weapons.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -238,7 +238,10 @@
 		return;
 
 	wb = W_WeaponBit(w);
-	self.weapons = self.weapons - (self.weapons & wb);
+	if(self.weapons & wb != wb)
+		return;
+
+	self.weapons = self.weapons - wb;
 	W_SwitchWeapon_Force(self, w_getbestweapon(self));
 	a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo);
 	if(a < 0)

Modified: branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/clientcommands.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -402,21 +402,18 @@
 	if(g_tourney) {
 		tourneyInMatchStage = 1; //once the game is restarted the game is in match stage
 		//reset weapons and ammo, health and armor to default:
-		// TODO is this really the right way?!? see miscfunction.qc readlevelcvars()
-		start_weapons = WEPBIT_LASER | WEPBIT_SHOTGUN;
-		start_switchweapon = WEP_SHOTGUN;
-		start_ammo_shells = cvar("g_start_ammo_shells");
-		start_ammo_nails = cvar("g_start_ammo_nails");
-		start_ammo_rockets = cvar("g_start_ammo_rockets");
-		start_ammo_cells = cvar("g_start_ammo_cells");
-		start_health = cvar("g_balance_health_start");
-		start_armorvalue = cvar("g_balance_armor_start");
+		readplayerstartcvars();
 	}
 	restart_countdown = time + RESTART_COUNTDOWN;
 	restart_mapalreadyrestarted = 0; //reset this var, needed when cvar sv_ready_restart_repeatable is in use
 	//reset the .ready status of all players (also spectators)
 	FOR_EACH_CLIENTSLOT(e)
 	{
+		msg_entity = e;
+		WriteByte(MSG_ONE, SVC_TEMPENTITY);
+		WriteByte(MSG_ONE, TE_CSQC_WARMUP);
+		WriteByte(MSG_ONE, !tourneyInMatchStage);
+
 		e.ready = 0;
 	}
 	if(0<cvar("timelimit") || (g_tourney && (-1 == g_tourney_warmup_limit)) )

Modified: branches/nexuiz-2.0/data/qcsrc/server/defs.qh
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/defs.qh	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/defs.qh	2008-09-06 16:44:32 UTC (rev 4381)
@@ -20,6 +20,7 @@
 float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_laserguided_missile, g_midair, g_minstagib, g_nixnex, g_nixnex_with_laser, g_norecoil, g_rocketarena, g_vampire, g_minstagib_invis_alpha;
 float g_tourney;
 float g_tourney_warmup_limit;
+float g_tourney_warmup_allguns;
 float g_ctf_win_mode;
 float g_race_qualifying;
 float tourneyInMatchStage;
@@ -346,8 +347,8 @@
 
 .float version_nagtime;
 
+.float modelindex_lod0;
 #ifdef ALLOW_VARIABLE_LOD
-.float modelindex_lod0;
 .float modelindex_lod1;
 .float modelindex_lod2;
 #endif

Modified: branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -712,65 +712,12 @@
 
 entity get_weaponinfo(float w);
 
-void readlevelcvars(void)
+void readplayerstartcvars() 
 {
 	entity e;
 	float i;
 
-	sv_cheats = cvar("sv_cheats");
-	sv_gentle = cvar("sv_gentle");
-	sv_foginterval = cvar("sv_foginterval");
-	g_cloaked = cvar("g_cloaked");
-	g_jump_grunt = cvar("g_jump_grunt");
-	g_footsteps = cvar("g_footsteps");
-	g_grappling_hook = cvar("g_grappling_hook");
-	g_laserguided_missile = cvar("g_laserguided_missile");
-	g_midair = cvar("g_midair");
-	g_minstagib = cvar("g_minstagib");
-	g_nixnex = cvar("g_nixnex");
-	g_nixnex_with_laser = cvar("g_nixnex_with_laser");
-	g_norecoil = cvar("g_norecoil");
-	g_rocketarena = cvar("g_rocketarena");
-	g_vampire = cvar("g_vampire");
-	g_tourney = cvar("g_tourney");
-	g_tourney_warmup_limit = cvar("g_tourney_warmup_limit");
-	sv_maxidle = cvar("sv_maxidle");
-	sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
-	sv_pogostick = cvar("sv_pogostick");
-	sv_doublejump = cvar("sv_doublejump");
-
-	g_pickup_respawntime_short = cvar("g_pickup_respawntime_short");
-	g_pickup_respawntime_medium = cvar("g_pickup_respawntime_medium");
-	g_pickup_respawntime_long = cvar("g_pickup_respawntime_long");
-	g_pickup_respawntime_powerup = cvar("g_pickup_respawntime_powerup");
-
-	if(g_minstagib) g_nixnex = g_rocketarena = 0;
-	if(g_nixnex) g_rocketarena = 0;
-
-	g_pickup_shells                    = cvar("g_pickup_shells");
-	g_pickup_shells_max                = cvar("g_pickup_shells_max");
-	g_pickup_nails                     = cvar("g_pickup_nails");
-	g_pickup_nails_max                 = cvar("g_pickup_nails_max");
-	g_pickup_rockets                   = cvar("g_pickup_rockets");
-	g_pickup_rockets_max               = cvar("g_pickup_rockets_max");
-	g_pickup_cells                     = cvar("g_pickup_cells");
-	g_pickup_cells_max                 = cvar("g_pickup_cells_max");
-	g_pickup_armorsmall                = cvar("g_pickup_armorsmall");
-	g_pickup_armorsmall_max            = cvar("g_pickup_armorsmall_max");
-	g_pickup_armormedium               = cvar("g_pickup_armormedium");
-	g_pickup_armormedium_max           = cvar("g_pickup_armormedium_max");
-	g_pickup_armorlarge                = cvar("g_pickup_armorlarge");
-	g_pickup_armorlarge_max            = cvar("g_pickup_armorlarge_max");
-	g_pickup_healthsmall               = cvar("g_pickup_healthsmall");
-	g_pickup_healthsmall_max           = cvar("g_pickup_healthsmall_max");
-	g_pickup_healthmedium              = cvar("g_pickup_healthmedium");
-	g_pickup_healthmedium_max          = cvar("g_pickup_healthmedium_max");
-	g_pickup_healthlarge               = cvar("g_pickup_healthlarge");
-	g_pickup_healthlarge_max           = cvar("g_pickup_healthlarge_max");
-	g_pickup_healthmega                = cvar("g_pickup_healthmega");
-	g_pickup_healthmega_max            = cvar("g_pickup_healthmega_max");
-
-	// initialize starting values for players
+  	// initialize starting values for players
 	start_weapons = 0;
 	start_items = 0;
 	start_switchweapon = 0;
@@ -815,7 +762,7 @@
 			start_health = cvar("g_lms_start_health");
 			start_armorvalue = cvar("g_lms_start_armor");
 		}
-		else if(g_tourney) {
+		else if(g_tourney && !tourneyInMatchStage) {
 			start_ammo_shells = cvar("g_tourney_start_ammo_shells");
 			start_ammo_nails = cvar("g_tourney_start_ammo_nails");
 			start_ammo_rockets = cvar("g_tourney_start_ammo_rockets");
@@ -841,7 +788,7 @@
 			e = get_weaponinfo(i);
 			if(!(e.weapon))
 				continue;
-			if(((e.spawnflags & 1) && (g_lms || g_tourney)) || cvar(strcat("g_start_weapon_", e.netname)))
+			if(((e.spawnflags & 1) && (g_lms || (g_tourney && g_tourney_warmup_allguns))) || cvar(strcat("g_start_weapon_", e.netname)))
 			{
 				start_weapons |= e.weapons;
 				start_switchweapon = e.weapon;
@@ -851,6 +798,68 @@
 	}
 }
 
+void readlevelcvars(void)
+{
+	sv_cheats = cvar("sv_cheats");
+	sv_gentle = cvar("sv_gentle");
+	sv_foginterval = cvar("sv_foginterval");
+	g_cloaked = cvar("g_cloaked");
+	g_jump_grunt = cvar("g_jump_grunt");
+	g_footsteps = cvar("g_footsteps");
+	g_grappling_hook = cvar("g_grappling_hook");
+	g_laserguided_missile = cvar("g_laserguided_missile");
+	g_midair = cvar("g_midair");
+	g_minstagib = cvar("g_minstagib");
+	g_nixnex = cvar("g_nixnex");
+	g_nixnex_with_laser = cvar("g_nixnex_with_laser");
+	g_norecoil = cvar("g_norecoil");
+	g_rocketarena = cvar("g_rocketarena");
+	g_vampire = cvar("g_vampire");
+	g_tourney = cvar("g_tourney");
+	g_tourney_warmup_limit = cvar("g_tourney_warmup_limit");
+	g_tourney_warmup_allguns = cvar("g_tourney_warmup_allguns");
+	sv_maxidle = cvar("sv_maxidle");
+	sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
+	sv_pogostick = cvar("sv_pogostick");
+	sv_doublejump = cvar("sv_doublejump");
+
+	if(g_race && g_race_qualifying == 2)
+		g_tourney = 0; // these modes cannot work together
+
+	g_pickup_respawntime_short = cvar("g_pickup_respawntime_short");
+	g_pickup_respawntime_medium = cvar("g_pickup_respawntime_medium");
+	g_pickup_respawntime_long = cvar("g_pickup_respawntime_long");
+	g_pickup_respawntime_powerup = cvar("g_pickup_respawntime_powerup");
+
+	if(g_minstagib) g_nixnex = g_rocketarena = 0;
+	if(g_nixnex) g_rocketarena = 0;
+
+	g_pickup_shells                    = cvar("g_pickup_shells");
+	g_pickup_shells_max                = cvar("g_pickup_shells_max");
+	g_pickup_nails                     = cvar("g_pickup_nails");
+	g_pickup_nails_max                 = cvar("g_pickup_nails_max");
+	g_pickup_rockets                   = cvar("g_pickup_rockets");
+	g_pickup_rockets_max               = cvar("g_pickup_rockets_max");
+	g_pickup_cells                     = cvar("g_pickup_cells");
+	g_pickup_cells_max                 = cvar("g_pickup_cells_max");
+	g_pickup_armorsmall                = cvar("g_pickup_armorsmall");
+	g_pickup_armorsmall_max            = cvar("g_pickup_armorsmall_max");
+	g_pickup_armormedium               = cvar("g_pickup_armormedium");
+	g_pickup_armormedium_max           = cvar("g_pickup_armormedium_max");
+	g_pickup_armorlarge                = cvar("g_pickup_armorlarge");
+	g_pickup_armorlarge_max            = cvar("g_pickup_armorlarge_max");
+	g_pickup_healthsmall               = cvar("g_pickup_healthsmall");
+	g_pickup_healthsmall_max           = cvar("g_pickup_healthsmall_max");
+	g_pickup_healthmedium              = cvar("g_pickup_healthmedium");
+	g_pickup_healthmedium_max          = cvar("g_pickup_healthmedium_max");
+	g_pickup_healthlarge               = cvar("g_pickup_healthlarge");
+	g_pickup_healthlarge_max           = cvar("g_pickup_healthlarge_max");
+	g_pickup_healthmega                = cvar("g_pickup_healthmega");
+	g_pickup_healthmega_max            = cvar("g_pickup_healthmega_max");
+
+	readplayerstartcvars();
+}
+
 /*
 // TODO sound pack system
 string soundpack;

Modified: branches/nexuiz-2.0/data/qcsrc/server/portals.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/portals.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/portals.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -18,9 +18,8 @@
 {
 	vector m_forward, m_up;
 	fixedmakevectors(t2); m_forward = v_forward; m_up = v_up;
-	m_forward = Portal_Transform_Apply(t1, m_forward);
-	m_up = Portal_Transform_Apply(t1, m_up);
-	return vectoangles2(m_forward, m_up);
+	m_forward = Portal_Transform_Apply(t1, m_forward); m_up = Portal_Transform_Apply(t1, m_up);
+	return fixedvectoangles2(m_forward, m_up);
 }
 
 vector Portal_Transform_Invert(vector transform)
@@ -29,7 +28,7 @@
 	fixedmakevectors(transform);
 	// we want angles that turn v_forward into '1 0 0', v_right into '0 1 0' and v_up into '0 0 1'
 	// but these are orthogonal unit vectors!
-	// so to invert, we can simply vectoangles the TRANSPOSED matrix
+	// so to invert, we can simply fixedvectoangles the TRANSPOSED matrix
 	// TODO is this always -transform?
 	i_forward_x = v_forward_x;
 	i_forward_y = -v_right_x;
@@ -39,7 +38,7 @@
 	i_up_z = v_up_z;
 #ifdef DEBUG
 	vector v;
-	v = vectoangles2(i_forward, i_up);
+	v = fixedvectoangles2(i_forward, i_up);
 	print("Transform: ", vtos(transform), "\n");
 	print("Inverted: ", vtos(v), "\n");
 	print("Verify: ", vtos(Portal_Transform_Multiply(v, transform)), "\n");
@@ -48,7 +47,7 @@
 	print("Verify: ", vtos(v_right), "\n");
 	print("Verify: ", vtos(v_up), "\n");
 #endif
-	return vectoangles2(i_forward, i_up);
+	return fixedvectoangles2(i_forward, i_up);
 }
 
 vector Portal_Transform_TurnDirection(vector transform)
@@ -56,7 +55,7 @@
 	// turn 180 degrees around v_up
 	// changes in-direction to out-direction
 	fixedmakevectors(transform);
-	return vectoangles2(-1 * v_forward, 1 * v_up);
+	return fixedvectoangles2(-1 * v_forward, 1 * v_up);
 }
 
 vector Portal_Transform_Divide(vector to_transform, vector from_transform)
@@ -79,6 +78,10 @@
 float Portal_TeleportPlayer(entity teleporter, entity player)
 {
 	vector from, to, safe, step, transform, ang, newvel;
+	vector new_forward, new_up;
+	vector old_forward, old_up;
+	vector new_yawforward;
+	vector old_yawforward;
 	float planeshift, s, t;
 	from = teleporter.origin;
 	transform = teleporter.portal_transform;
@@ -127,8 +130,51 @@
 	if(player.classname == "player")
 	{
 		ang = player.v_angle;
+		/*
+		ang_x = bound(-89, mod(-ang_x + 180, 360) - 180, 89);
+		ang = Portal_Transform_Multiply(transform, ang);
+		*/
+
+		// PLAYERS use different math
 		ang_x = -ang_x;
-		ang = Portal_Transform_Multiply(transform, ang);
+
+		//print("reference: ", vtos(Portal_Transform_Multiply(transform, ang)), "\n");
+
+		fixedmakevectors(ang);
+		old_forward = v_forward;
+		old_up = v_up;
+		fixedmakevectors(ang_y * '0 1 0');
+		old_yawforward = v_forward;
+
+		// their aiming directions are portalled...
+		new_forward = Portal_Transform_Apply(transform, old_forward);
+		new_up = Portal_Transform_Apply(transform, old_up);
+		new_yawforward = Portal_Transform_Apply(transform, old_yawforward);
+
+		// but now find a new sense of direction
+		// this is NOT easy!
+		// assume new_forward points straight up.
+		// What is our yaw?
+		//
+		// new_up could now point forward OR backward... which direction to choose?
+
+		if(new_forward_z > 0.7 || new_forward_z < -0.7) // far up; in this case, the "up" vector points backwards
+		{
+			// new_yawforward and new_yawup define the new aiming half-circle
+			// we "just" need to find out whether new_up or -new_up is in that half circle
+			ang = fixedvectoangles(new_forward); // this still gets us a nice pitch value...
+			if(new_up * new_yawforward < 0)
+				new_up = -1 * new_up;
+			ang_y = vectoyaw(new_up); // this vector is the yaw we want
+			//print("UP/DOWN path: ", vtos(ang), "\n");
+		}
+		else
+		{
+			// good angles; here, "forward" suffices
+			ang = fixedvectoangles(new_forward);
+			//print("GOOD path: ", vtos(ang), "\n");
+		}
+
 		ang_z = player.angles_z;
 	}
 	else
@@ -219,10 +265,12 @@
 				other.effects += EF_BLUE - EF_RED;
 }
 
+void Portal_Think();
 void Portal_MakeBrokenPortal(entity portal)
 {
 	portal.solid = SOLID_NOT;
 	portal.touch = SUB_Null;
+	portal.think = SUB_Null;
 	portal.effects = 0;
 	//portal.colormod = '1 1 1';
 	portal.nextthink = 0;
@@ -233,6 +281,7 @@
 {
 	portal.solid = SOLID_NOT;
 	portal.touch = SUB_Null;
+	portal.think = SUB_Null;
 	portal.effects = EF_ADDITIVE;
 	portal.colormod = '1 1 1';
 	portal.nextthink = 0;
@@ -243,6 +292,7 @@
 {
 	portal.solid = SOLID_TRIGGER;
 	portal.touch = Portal_Touch;
+	portal.think = Portal_Think;
 	portal.effects = EF_RED;
 	portal.colormod = '1 0 0';
 	portal.nextthink = time;
@@ -253,6 +303,7 @@
 {
 	portal.solid = SOLID_NOT;
 	portal.touch = SUB_Null;
+	portal.think = SUB_Null;
 	portal.effects = EF_STARDUST | EF_BLUE;
 	portal.colormod = '0 0 1';
 	portal.nextthink = 0;
@@ -392,11 +443,17 @@
 	if(other.classname == "spectator")
 		other = other.enemy;
 	if(other == self.owner)
-		return TRUE;
-	if(IS_INDEPENDENT_PLAYER(other))
-		return FALSE;
-	if(IS_INDEPENDENT_PLAYER(self.owner))
-		return FALSE;
+	{
+		self.modelindex = self.modelindex_lod0;
+	}
+	else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.owner))
+	{
+		self.modelindex = 0;
+	}
+	else
+	{
+		self.modelindex = self.modelindex_lod0;
+	}
 	return TRUE;
 }
 
@@ -494,6 +551,7 @@
 	portal.event_damage = Portal_Damage;
 	portal.health = 300;
 	setmodel(portal, "models/portal.md3");
+	portal.modelindex_lod0 = portal.modelindex;
 	portal.customizeentityforclient = Portal_Customize;
 
 	if(!Portal_FindSafeOrigin(portal))
@@ -522,7 +580,7 @@
 	}
 
 	org = trace_endpos;
-	ang = vectoangles2(trace_plane_normal, dir);
+	ang = fixedvectoangles2(trace_plane_normal, dir);
 	fixedmakevectors(ang);
 
 	portal = Portal_Spawn(own, org, ang);
@@ -535,7 +593,6 @@
 
 	portal.portal_id = portal_id_val;
 	Portal_SetInPortal(own, portal);
-	sound(portal, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
 
 	return 1;
 }
@@ -554,7 +611,7 @@
 	}
 
 	org = trace_endpos;
-	ang = vectoangles2(trace_plane_normal, dir);
+	ang = fixedvectoangles2(trace_plane_normal, dir);
 	fixedmakevectors(ang);
 
 	portal = Portal_Spawn(own, org, ang);
@@ -567,7 +624,6 @@
 
 	portal.portal_id = portal_id_val;
 	Portal_SetOutPortal(own, portal);
-	sound(portal, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
 
 	return 1;
 }

Modified: branches/nexuiz-2.0/data/qcsrc/server/vote.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/vote.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/vote.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -433,8 +433,7 @@
 		}
 	} else {
 		//in g_tourney mode and if the vote is a timelimit-change, don't change it immediately but after restart
-		if(cvar("g_tourney")
-		   && substring(votecalledvote, 0, 10) == "timelimit ") {
+		if(g_tourney && substring(votecalledvote, 0, 10) == "timelimit ") {
 			if( stof(substring(votecalledvote, 10, strlen(votecalledvote) - 10)) > 0 ) {
 				timelimit_orig = stof(substring(votecalledvote, 10, strlen(votecalledvote) - 10));
 				bprint(strcat("The timelimit will be set to ", ftos(timelimit_orig), " minutes after the next restart!\n"));
@@ -552,7 +551,7 @@
 	}
 
 	//in tournament mode, if we have at least one player then don't make the vote dependent on spectators (so specs don't have to press F1)
-	if(cvar("g_tourney"))
+	if(g_tourney)
 	if(realplayercount > 0) {
 		yescount = realplayeryescount;
 		nocount = realplayernocount;

Modified: branches/nexuiz-2.0/data/qcsrc/server/w_porto.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/w_porto.qc	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/data/qcsrc/server/w_porto.qc	2008-09-06 16:44:32 UTC (rev 4381)
@@ -75,6 +75,8 @@
 		self.effects += EF_BLUE - EF_RED;
 		if(Portal_SpawnInPortalAtTrace(self.owner, self.right_vector, self.portal_id))
 		{
+			sound(self, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
+			centerprint(self.owner, "^1In^7-portal created.\n");
 			trace_plane_normal = norm;
 			self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal);
 			self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal));
@@ -89,6 +91,8 @@
 	{
 		if(Portal_SpawnOutPortalAtTrace(self.owner, self.right_vector, self.portal_id))
 		{
+			sound(self, CHAN_PROJECTILE, "misc/invshot.wav", VOL_BASE, ATTN_NORM);
+			centerprint(self.owner, "^4Out^7-portal created.\n");
 			W_Porto_Success();
 		}
 		else

Modified: branches/nexuiz-2.0/misc/gtkradiant/gtkradiant-nexuiz-patchset.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/gtkradiant-nexuiz-patchset.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/gtkradiant-nexuiz-patchset.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -10,8 +10,8 @@
 
 Index: libs/picomodel/pm_obj.c
 ===================================================================
---- libs/picomodel/pm_obj.c	(revision 290)
-+++ libs/picomodel/pm_obj.c	(working copy)
+--- libs/picomodel/pm_obj.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ libs/picomodel/pm_obj.c	2008-09-06 15:32:09.000000000 +0200
 @@ -215,10 +215,9 @@
  	}
  }
@@ -113,8 +113,8 @@
  	}
 Index: radiant/map.cpp
 ===================================================================
---- radiant/map.cpp	(revision 304)
-+++ radiant/map.cpp	(working copy)
+--- radiant/map.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/map.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -270,6 +270,100 @@
    ents->RemoveAll();
  }
@@ -192,7 +192,7 @@
 +			if(e_target != NULL)
 +			{
 +				const char *targetname = ValueForKey(e_target, "targetname");
-+				if( (targetname != NULL) && (strcmp(target, targetname) == 0) ) 
++				if( (targetname != NULL) && (strcmp(target, targetname) == 0) )
 +				{
 +					SetKeyValue(e_target, "targetname", newtarget);
 +				}
@@ -227,9 +227,7 @@
 -        entity_t *e_target;
 -        const char *target = ValueForKey(e, "target");
 -        qboolean bCollision=FALSE;
-+      // keep a list of ents added to avoid testing collisions against them
-+      g_ptr_array_add(new_ents, (gpointer)e);
- 
+-
 -        // check the current map entities for an actual collision
 -        for (e_target = entities.next; e_target != &entities; e_target = e_target->next)
 -        {
@@ -269,7 +267,9 @@
 -          g_ptr_array_free(t_ents, FALSE);
 -        }
 -      }
--
++      // keep a list of ents added to avoid testing collisions against them
++      g_ptr_array_add(new_ents, (gpointer)e);
+ 
        // add the entity to the end of the entity list
        Entity_AddToList(e, &entities);
        g_qeglobals.d_num_entities++;
@@ -295,8 +295,8 @@
    g_ptr_array_free(new_ents, FALSE);
 Index: radiant/drag.cpp
 ===================================================================
---- radiant/drag.cpp	(revision 304)
-+++ radiant/drag.cpp	(working copy)
+--- radiant/drag.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/drag.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -255,54 +255,6 @@
  
  entity_t *peLink;
@@ -354,8 +354,8 @@
  Drag_Begin
 Index: radiant/xywindow.cpp
 ===================================================================
---- radiant/xywindow.cpp	(revision 304)
-+++ radiant/xywindow.cpp	(working copy)
+--- radiant/xywindow.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/xywindow.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -270,16 +270,17 @@
  void DrawPathLines (void)
  {
@@ -440,8 +440,8 @@
  
 Index: radiant/targetname.cpp
 ===================================================================
---- radiant/targetname.cpp	(revision 304)
-+++ radiant/targetname.cpp	(working copy)
+--- radiant/targetname.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/targetname.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -24,11 +24,11 @@
  /*!
  connects two entities creating a unique target/targetname value 
@@ -535,8 +535,8 @@
  	if (fFound)
 Index: radiant/qe3.cpp
 ===================================================================
---- radiant/qe3.cpp	(revision 304)
-+++ radiant/qe3.cpp	(working copy)
+--- radiant/qe3.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/qe3.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -704,7 +704,7 @@
  from the first selected to the secon
  ===============
@@ -572,8 +572,8 @@
    }
 Index: radiant/qe3.h
 ===================================================================
---- radiant/qe3.h	(revision 304)
-+++ radiant/qe3.h	(working copy)
+--- radiant/qe3.h.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/qe3.h	2008-09-06 15:32:10.000000000 +0200
 @@ -229,7 +229,7 @@
  void SelectEdgeByRay (vec3_t org, vec3_t dir);
  void SelectVertexByRay (vec3_t org, vec3_t dir);
@@ -594,8 +594,8 @@
  // xywindow.cpp
 Index: tools/quake3/q3map2/convert_map.c
 ===================================================================
---- tools/quake3/q3map2/convert_map.c	(revision 191)
-+++ tools/quake3/q3map2/convert_map.c	(working copy)
+--- tools/quake3/q3map2/convert_map.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ tools/quake3/q3map2/convert_map.c	2008-09-06 15:32:11.000000000 +0200
 @@ -46,6 +46,105 @@
  #define	SNAP_FLOAT_TO_INT	4
  #define	SNAP_INT_TO_FLOAT	(1.0 / SNAP_FLOAT_TO_INT)
@@ -726,7 +726,7 @@
  		
 +		/* get plane */
 +		buildPlane = &mapplanes[ buildSide->planenum ];
-+		
++
  		/* dummy check */
  		if( buildSide->shaderInfo == NULL || buildSide->winding == NULL )
  			continue;
@@ -796,7 +796,7 @@
 +			else
 +				fprintf(stderr, "degenerate triangle found when solving texMat equations for\n(%f %f %f) (%f %f %f) (%f %f %f)\n( %f %f %f )\n( %f %f %f ) -> ( %f %f )\n( %f %f %f ) -> ( %f %f )\n( %f %f %f ) -> ( %f %f )\n",
 +					buildPlane->normal[0], buildPlane->normal[1], buildPlane->normal[2],
-+					vert[0]->normal[0], vert[0]->normal[1], vert[0]->normal[2], 
++					vert[0]->normal[0], vert[0]->normal[1], vert[0]->normal[2],
 +					texX[0], texX[1], texX[2], texY[0], texY[1], texY[2],
 +					vert[0]->xyz[0], vert[0]->xyz[1], vert[0]->xyz[2], xy1I[0], xy1I[1],
 +					vert[1]->xyz[0], vert[1]->xyz[1], vert[1]->xyz[2], xy1J[0], xy1J[1],
@@ -835,8 +835,8 @@
  
 Index: tools/quake3/q3map2/main.c
 ===================================================================
---- tools/quake3/q3map2/main.c	(revision 191)
-+++ tools/quake3/q3map2/main.c	(working copy)
+--- tools/quake3/q3map2/main.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ tools/quake3/q3map2/main.c	2008-09-06 15:32:11.000000000 +0200
 @@ -541,6 +541,18 @@
  					Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
  			}
@@ -858,8 +858,8 @@
  	/* clean up map name */
 Index: tools/quake3/q3map2/model.c
 ===================================================================
---- tools/quake3/q3map2/model.c	(revision 193)
-+++ tools/quake3/q3map2/model.c	(working copy)
+--- tools/quake3/q3map2/model.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ tools/quake3/q3map2/model.c	2008-09-06 15:32:12.000000000 +0200
 @@ -222,6 +222,8 @@
  	byte				*color;
  	picoIndex_t			*indexes;
@@ -1056,7 +1056,7 @@
 +						buildBrush->sides[ 2 ].planenum = FindFloatPlane( pb, pb[ 3 ], 2, &points[ 0 ] ); // pb contains points[0] and points[1]
 +						buildBrush->sides[ 3 ].planenum = FindFloatPlane( pc, pc[ 3 ], 2, &points[ 2 ] ); // pc contains points[2] and points[0] (copied to points[3]
 +						buildBrush->sides[ 4 ].planenum = FindFloatPlane( reverse, reverse[ 3 ], 3, backs );
- 					}
++					}
 +					else
 +					{
 +						free(buildBrush);
@@ -1074,7 +1074,7 @@
 +						buildBrush->next = entities[ mapEntityNum ].brushes;
 +						entities[ mapEntityNum ].brushes = buildBrush;
 +						entities[ mapEntityNum ].numBrushes++;
-+					}
+ 					}
 +					else
 +						free( buildBrush );
  				}
@@ -1082,8 +1082,8 @@
  		}
 Index: tools/quake3/q3map2/map.c
 ===================================================================
---- tools/quake3/q3map2/map.c	(revision 193)
-+++ tools/quake3/q3map2/map.c	(working copy)
+--- tools/quake3/q3map2/map.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/map.c	2008-09-06 15:32:12.000000000 +0200
 @@ -184,7 +184,7 @@
  snaps a plane to normal/distance epsilons
  */
@@ -1120,13 +1120,13 @@
  	int		i, j, hash, h;
  	plane_t	*p;
  	vec_t	d;
+-	
 +	vec3_t centerofweight;
 +
 +	VectorClear(centerofweight);
 +	for(i = 0; i < numPoints; ++i)
 +		VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
  	
--	
  	/* hash the plane */
 -	SnapPlane( normal, &dist );
 +	SnapPlane( normal, &dist, centerofweight );
@@ -1143,16 +1143,16 @@
 +	VectorClear(centerofweight);
 +	for(i = 0; i < numPoints; ++i)
 +		VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
-+	
++
 +	SnapPlane( normal, &dist, centerofweight );
  	for( i = 0, p = mapplanes; i < nummapplanes; i++, p++ )
  	{
  		if( PlaneEqual( p, normal, dist ) )
 Index: tools/quake3/q3map2/shaders.c
 ===================================================================
---- tools/quake3/q3map2/shaders.c	(revision 191)
-+++ tools/quake3/q3map2/shaders.c	(working copy)
-@@ -793,8 +793,14 @@
+--- tools/quake3/q3map2/shaders.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/shaders.c	2008-09-06 15:32:13.000000000 +0200
+@@ -794,8 +794,14 @@
  	}
  	
  	if( VectorLength( si->color ) <= 0.0f )
@@ -1170,9 +1170,9 @@
  
 Index: tools/quake3/q3map2/light_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/light_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/light_ydnar.c	(working copy)
-@@ -1767,6 +1864,8 @@
+--- tools/quake3/q3map2/light_ydnar.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/light_ydnar.c	2008-09-06 15:32:14.000000000 +0200
+@@ -1767,6 +1767,8 @@
  	float				tests[ 4 ][ 2 ] = { { 0.0f, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } };
  	trace_t				trace;
  	float				stackLightLuxels[ STACK_LL_SIZE ];
@@ -1181,7 +1181,7 @@
  	
  	
  	/* bail if this number exceeds the number of raw lightmaps */
-@@ -2223,6 +2332,78 @@
+@@ -2223,6 +2225,78 @@
  	FreeTraceLights( &trace );
  	
  	/*	-----------------------------------------------------------------
@@ -1196,7 +1196,7 @@
 +			/* early out */
 +			if( lm->superLuxels[ lightmapNum ] == NULL )
 +				continue;
-+			
++
 +			/* apply floodlight to each luxel */
 +			for( y = 0; y < lm->sh; y++ )
 +			{
@@ -1206,21 +1206,21 @@
 +					cluster	= SUPER_CLUSTER( x, y );
 +					//%	if( *cluster < 0 )
 +					//%		continue;
-+					
++
 +					/* get particulars */
 +					luxel = SUPER_LUXEL( lightmapNum, x, y );
 +					floodlight = SUPER_FLOODLIGHT( x, y );
-+					
++
 +					flood[0]=floodlightRGB[0]*floodlightIntensity;
 +					flood[1]=floodlightRGB[1]*floodlightIntensity;
 +					flood[2]=floodlightRGB[2]*floodlightIntensity;
-+					             
++
 +					/* scale light value */
 +					VectorScale( flood, *floodlight, flood );
 +					luxel[0]+=flood[0];
 +					luxel[1]+=flood[1];
 +					luxel[2]+=flood[2];
-+					
++
 +					if (luxel[3]==0) luxel[3]=1;
 +				}
 +			}
@@ -1234,7 +1234,7 @@
 +			/* early out */
 +			if( lm->superLuxels[ lightmapNum ] == NULL )
 +				continue;
-+			
++
 +			for( y = 0; y < lm->sh; y++ )
 +			{
 +				for( x = 0; x < lm->sw; x++ )
@@ -1243,11 +1243,11 @@
 +					cluster	= SUPER_CLUSTER( x, y );
 +					//%	if( *cluster < 0 )
 +					//%		continue;
-+					
++
 +					/* get particulars */
 +					luxel = SUPER_LUXEL( lightmapNum, x, y );
 +					normal = SUPER_NORMAL (  x, y );
-+               
++
 +					luxel[0]=(normal[0]*127)+127;
 +					luxel[1]=(normal[1]*127)+127;
 +					luxel[2]=(normal[2]*127)+127;
@@ -1255,39 +1255,39 @@
 +			}
 +		}
 +	}
-+	
++
 +	/*	-----------------------------------------------------------------
  		dirt pass
  		----------------------------------------------------------------- */
  	
-@@ -3587,7 +3768,320 @@
+@@ -3587,7 +3661,320 @@
  	CreateTraceLightsForBounds( mins, maxs, normal, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ], LIGHT_SURFACES, trace );
  }
  
 +/////////////////////////////////////////////////////////////
- 
++
 +#define FLOODLIGHT_CONE_ANGLE			88	/* degrees */
 +#define FLOODLIGHT_NUM_ANGLE_STEPS		16
 +#define FLOODLIGHT_NUM_ELEVATION_STEPS	4
 +#define FLOODLIGHT_NUM_VECTORS			(FLOODLIGHT_NUM_ANGLE_STEPS * FLOODLIGHT_NUM_ELEVATION_STEPS)
- 
++
 +static vec3_t	floodVectors[ FLOODLIGHT_NUM_VECTORS ];
 +static int		numFloodVectors = 0;
- 
++
 +void SetupFloodLight( void )
 +{
 +	int		i, j;
 +	float	angle, elevation, angleStep, elevationStep;
 +	const char	*value;
 +	double v1,v2,v3,v4,v5;
-+	
++
 +	/* note it */
 +	Sys_FPrintf( SYS_VRB, "--- SetupFloodLight ---\n" );
-+	
++
 +	/* calculate angular steps */
 +	angleStep = DEG2RAD( 360.0f / FLOODLIGHT_NUM_ANGLE_STEPS );
 +	elevationStep = DEG2RAD( FLOODLIGHT_CONE_ANGLE / FLOODLIGHT_NUM_ELEVATION_STEPS );
-+	
++
 +	/* iterate angle */
 +	angle = 0.0f;
 +	for( i = 0, angle = 0.0f; i < FLOODLIGHT_NUM_ANGLE_STEPS; i++, angle += angleStep )
@@ -1301,36 +1301,36 @@
 +			numFloodVectors++;
 +		}
 +	}
-+	
++
 +	/* emit some statistics */
 +	Sys_FPrintf( SYS_VRB, "%9d numFloodVectors\n", numFloodVectors );
  
 +      /* floodlight */
 +	value = ValueForKey( &entities[ 0 ], "_floodlight" );
-+	
+ 
 +	if( value[ 0 ] != '\0' )
 +	{
 +		v1=v2=v3=0;
 +		v4=floodlightDistance;
 +		v5=floodlightIntensity;
-+		
++
 +		sscanf( value, "%lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5);
-+		
++
 +		floodlightRGB[0]=v1;
 +		floodlightRGB[1]=v2;
 +		floodlightRGB[2]=v3;
-+		
++
 +		if (VectorLength(floodlightRGB)==0)
 +		{
 +			VectorSet(floodlightRGB,240,240,255);
 +		}
-+		
+ 
 +		if (v4<1) v4=1024;
 +		if (v5<1) v5=128;
-+		
++
 +		floodlightDistance=v4;
 +		floodlightIntensity=v5;
-+    
++
 +		floodlighty = qtrue;
 +		Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" );
 +	}
@@ -1352,14 +1352,14 @@
 +	rawLightmap_t		*lm;
 +	surfaceInfo_t		*info;
 +	trace_t				trace;
-+	
++
 +	/* bail if this number exceeds the number of raw lightmaps */
 +	if( rawLightmapNum >= numRawLightmaps )
 +		return;
-+	
++
 +	/* get lightmap */
 +	lm = &rawLightmaps[ rawLightmapNum ];
-+	
++
 +	memset(&trace,0,sizeof(trace_t));
 +	/* setup trace */
 +	trace.testOcclusion = qtrue;
@@ -1371,14 +1371,14 @@
 +	trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
 +	trace.testAll = qfalse;
 +	trace.distance = 1024;
-+	
++
 +	/* twosided lighting (may or may not be a good idea for lightmapped stuff) */
 +	//trace.twoSided = qfalse;
 +	for( i = 0; i < trace.numSurfaces; i++ )
 +	{
 +		/* get surface */
 +		info = &surfaceInfos[ trace.surfaces[ i ] ];
-+		
++
 +		/* check twosidedness */
 +		if( info->si->twoSided )
 +		{
@@ -1386,7 +1386,7 @@
 +			break;
 +		}
 +	}
-+	
++
 +	/* gather dirt */
 +	for( y = 0; y < lm->sh; y++ )
 +	{
@@ -1397,29 +1397,29 @@
 +			origin = SUPER_ORIGIN( x, y );
 +			normal = SUPER_NORMAL( x, y );
 +			floodlight = SUPER_FLOODLIGHT( x, y );
-+			
++
 +			/* set default dirt */
 +			*floodlight = 0.0f;
-+			
++
 +			/* only look at mapped luxels */
 +			if( *cluster < 0 )
 +				continue;
-+			
++
 +			/* copy to trace */
 +			trace.cluster = *cluster;
 +			VectorCopy( origin, trace.origin );
 +			VectorCopy( normal, trace.normal );
-+         
 +
-+		
++
++
 +			/* get dirt */
 +			*floodlight = FloodLightForSample( &trace );
 +		}
 +	}
-+	
++
 +	/* testing no filtering */
 +	return;
-+	
++
 +	/* filter "dirt" */
 +	for( y = 0; y < lm->sh; y++ )
 +	{
@@ -1428,7 +1428,7 @@
 +			/* get luxel */
 +			cluster = SUPER_CLUSTER( x, y );
 +			floodlight = SUPER_FLOODLIGHT( x, y );
-+			
++
 +			/* filter dirt by adjacency to unmapped luxels */
 +			average = *floodlight;
 +			samples = 1.0f;
@@ -1436,32 +1436,32 @@
 +			{
 +				if( sy < 0 || sy >= lm->sh )
 +					continue;
-+				
++
 +				for( sx = (x - 1); sx <= (x + 1); sx++ )
 +				{
 +					if( sx < 0 || sx >= lm->sw || (sx == x && sy == y) )
 +						continue;
-+					
++
 +					/* get neighboring luxel */
 +					cluster = SUPER_CLUSTER( sx, sy );
 +					floodlight2 = SUPER_FLOODLIGHT( sx, sy );
 +					if( *cluster < 0 || *floodlight2 <= 0.0f )
 +						continue;
-+					
++
 +					/* add it */
 +					average += *floodlight2;
 +					samples += 1.0f;
 +				}
-+				
++
 +				/* bail */
 +				if( samples <= 0.0f )
 +					break;
 +			}
-+			
++
 +			/* bail */
 +			if( samples <= 0.0f )
 +				continue;
-+			
++
 +			/* scale dirt */
 +			*floodlight = average / samples;
 +		}
@@ -1483,23 +1483,23 @@
 +	vec3_t	normal, worldUp, myUp, myRt, direction, displacement;
 +	float 	dd;
 +	int 	vecs = 0;
-+ 
++
 +	gatherLight=0;
 +	/* dummy check */
 +	//if( !dirty )
 +	//	return 1.0f;
 +	if( trace == NULL || trace->cluster < 0 )
 +		return 0.0f;
-+	
 +
++
 +	/* setup */
 +	dd = floodlightDistance;
 +	VectorCopy( trace->normal, normal );
-+	
++
 +	/* check if the normal is aligned to the world-up */
 +	if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f )
 +	{
-+		if( normal[ 2 ] == 1.0f )		
++		if( normal[ 2 ] == 1.0f )
 +		{
 +			VectorSet( myRt, 1.0f, 0.0f, 0.0f );
 +			VectorSet( myUp, 0.0f, 1.0f, 0.0f );
@@ -1528,7 +1528,7 @@
 +		}
 +
 +		vecs++;
-+         
++
 +		/* transform vector into tangent space */
 +		direction[ 0 ] = myRt[ 0 ] * floodVectors[ i ][ 0 ] + myUp[ 0 ] * floodVectors[ i ][ 1 ] + normal[ 0 ] * floodVectors[ i ][ 2 ];
 +		direction[ 1 ] = myRt[ 1 ] * floodVectors[ i ][ 0 ] + myUp[ 1 ] * floodVectors[ i ][ 1 ] + normal[ 1 ] * floodVectors[ i ][ 2 ];
@@ -1538,7 +1538,7 @@
 +		VectorMA( trace->origin, dd, direction, trace->end );
 +
 +		//VectorMA( trace->origin, 1, direction, trace->origin );
-+			
++
 +		SetupTrace( trace );
 +		/* trace */
 +	  	TraceLine( trace );
@@ -1553,21 +1553,21 @@
 +			VectorSubtract( trace->hit, trace->origin, displacement );
 +			d=VectorLength( displacement );
 +
-+			// d=trace->distance;            
++			// d=trace->distance;
 +			//if (d>256) gatherDirt+=1;
 +			contribution=d/dd;
-+			if (contribution>1) contribution=1.0f; 
-+             
++			if (contribution>1) contribution=1.0f;
++
 +			//gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
 +		}
-+         
++
 +		gatherLight+=contribution;
 +	}
-+   
++
 +	/* early out */
 +	if( gatherLight <= 0.0f )
 +		return 0.0f;
-+   	
++
 +	sub=vecs;
 +
 +	if (sub<1) sub=1;
@@ -1576,15 +1576,15 @@
 +	outLight=gatherLight;
 +	if( outLight > 1.0f )
 +		outLight = 1.0f;
-+	
++
 +	/* return to sender */
 +	return outLight;
 +}
-+
+ 
 Index: tools/quake3/q3map2/light.c
 ===================================================================
---- tools/quake3/q3map2/light.c	(revision 191)
-+++ tools/quake3/q3map2/light.c	(working copy)
+--- tools/quake3/q3map2/light.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/light.c	2008-09-06 15:32:14.000000000 +0200
 @@ -1378,6 +1378,56 @@
  			break;
  	}
@@ -1599,12 +1599,12 @@
 +		col[0]=col[1]=col[2]=floodlightIntensity;
 +		dir[0]=dir[1]=0;
 +		dir[2]=1;
-+      
++
 +		trace.testOcclusion = qtrue;
 +		trace.forceSunlight = qfalse;
 +		trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
-+		trace.testAll = qtrue;     
-+      
++		trace.testAll = qtrue;
++
 +		for (q=0;q<2;q++)
 +		{
 +			if (q==0) //upper hemisphere
@@ -1631,7 +1631,7 @@
 +			contributions[ numCon ].dir[2]=dir[2];
 +
 +			contributions[ numCon ].style = 0;
-+			numCon++;		
++			numCon++;
 +			/* push average direction around */
 +			addSize = VectorLength( col );
 +			VectorMA( gp->dir, addSize, dir, gp->dir );
@@ -1663,7 +1663,7 @@
  		
  		/* generate diffuse lights */
  		RadFreeLights();
-@@ -2191,6 +2256,21 @@
+@@ -2191,6 +2248,21 @@
  			cpmaHack = qtrue;
  			Sys_Printf( "Enabling Challenge Pro Mode Asstacular Vertex Lighting Mode (tm)\n" );
  		}
@@ -1685,7 +1685,7 @@
  		
  		/* r7: dirtmapping */
  		else if( !strcmp( argv[ i ], "-dirty" ) )
-@@ -2279,6 +2359,7 @@
+@@ -2279,6 +2351,7 @@
  	/* ydnar: set up optimization */
  	SetupBrushes();
  	SetupDirt();
@@ -1695,8 +1695,8 @@
  	/* initialize the surface facet tracing */
 Index: tools/quake3/q3map2/lightmaps_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/lightmaps_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/lightmaps_ydnar.c	(working copy)
+--- tools/quake3/q3map2/lightmaps_ydnar.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/lightmaps_ydnar.c	2008-09-06 15:32:14.000000000 +0200
 @@ -414,6 +414,12 @@
  		lm->superNormals = safe_malloc( size );
  	memset( lm->superNormals, 0, size );
@@ -1706,15 +1706,15 @@
 +	if( lm->superFloodLight == NULL )
 +		lm->superFloodLight = safe_malloc( size );
 +	memset( lm->superFloodLight, 0, size );
-+	
++
  	/* allocate cluster map storage */
  	size = lm->sw * lm->sh * sizeof( int );
  	if( lm->superClusters == NULL )
 Index: tools/quake3/q3map2/q3map2.h
 ===================================================================
---- tools/quake3/q3map2/q3map2.h	(revision 191)
-+++ tools/quake3/q3map2/q3map2.h	(working copy)
-@@ -267,6 +267,7 @@
+--- tools/quake3/q3map2/q3map2.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/q3map2.h	2008-09-06 15:32:14.000000000 +0200
+@@ -266,6 +266,7 @@
  #define SUPER_NORMAL_SIZE		4
  #define SUPER_DELUXEL_SIZE		3
  #define BSP_DELUXEL_SIZE		3
@@ -1722,23 +1722,23 @@
  
  #define VERTEX_LUXEL( s, v )	(vertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
  #define RAD_VERTEX_LUXEL( s, v )(radVertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
-@@ -279,6 +280,7 @@
+@@ -278,6 +279,7 @@
  #define SUPER_ORIGIN( x, y )	(lm->superOrigins + ((((y) * lm->sw) + (x)) * SUPER_ORIGIN_SIZE))
  #define SUPER_NORMAL( x, y )	(lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE))
  #define SUPER_DIRT( x, y )		(lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE) + 3)	/* stash dirtyness in normal[ 3 ] */
-+#define SUPER_FLOODLIGHT( x, y )	(lm->superFloodLight + ((((y) * lm->sw) + (x)) * SUPER_FLOODLIGHT_SIZE) )	
++#define SUPER_FLOODLIGHT( x, y )	(lm->superFloodLight + ((((y) * lm->sw) + (x)) * SUPER_FLOODLIGHT_SIZE) )
  
  
  
-@@ -1392,6 +1395,7 @@
+@@ -1400,6 +1402,7 @@
  	
  	float					*superDeluxels;	/* average light direction */
  	float					*bspDeluxels;
-+	float					*superFloodLight; 
++	float					*superFloodLight;
  }
  rawLightmap_t;
  
-@@ -1704,6 +1708,10 @@
+@@ -1712,6 +1715,10 @@
  float						DirtForSample( trace_t *trace );
  void						DirtyRawLightmap( int num );
  
@@ -1749,7 +1749,7 @@
  void						IlluminateRawLightmap( int num );
  void						IlluminateVertexes( int num );
  
-@@ -2098,6 +2106,13 @@
+@@ -2106,6 +2113,13 @@
  Q_EXTERN float				dirtScale Q_ASSIGN( 1.0f );
  Q_EXTERN float				dirtGain Q_ASSIGN( 1.0f );
  
@@ -1765,8 +1765,8 @@
  Q_EXTERN qboolean			debugUnused Q_ASSIGN( qfalse );
 Index: tools/quake3/q3map2/game_ja.h
 ===================================================================
---- tools/quake3/q3map2/game_ja.h	(revision 191)
-+++ tools/quake3/q3map2/game_ja.h	(working copy)
+--- tools/quake3/q3map2/game_ja.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_ja.h	2008-09-06 15:32:16.000000000 +0200
 @@ -67,6 +67,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1777,8 +1777,8 @@
  	1,					/* bsp file version */
 Index: tools/quake3/q3map2/game_tremulous.h
 ===================================================================
---- tools/quake3/q3map2/game_tremulous.h	(revision 191)
-+++ tools/quake3/q3map2/game_tremulous.h	(working copy)
+--- tools/quake3/q3map2/game_tremulous.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_tremulous.h	2008-09-06 15:32:16.000000000 +0200
 @@ -70,6 +70,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1789,8 +1789,8 @@
  	46,					/* bsp file version */
 Index: tools/quake3/q3map2/game_wolfet.h
 ===================================================================
---- tools/quake3/q3map2/game_wolfet.h	(revision 191)
-+++ tools/quake3/q3map2/game_wolfet.h	(working copy)
+--- tools/quake3/q3map2/game_wolfet.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_wolfet.h	2008-09-06 15:32:16.000000000 +0200
 @@ -66,6 +66,7 @@
  	qtrue,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1801,8 +1801,8 @@
  	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_wolf.h
 ===================================================================
---- tools/quake3/q3map2/game_wolf.h	(revision 191)
-+++ tools/quake3/q3map2/game_wolf.h	(working copy)
+--- tools/quake3/q3map2/game_wolf.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_wolf.h	2008-09-06 15:32:16.000000000 +0200
 @@ -129,6 +129,7 @@
  	qtrue,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1813,8 +1813,8 @@
  	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_sof2.h
 ===================================================================
---- tools/quake3/q3map2/game_sof2.h	(revision 191)
-+++ tools/quake3/q3map2/game_sof2.h	(working copy)
+--- tools/quake3/q3map2/game_sof2.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_sof2.h	2008-09-06 15:32:16.000000000 +0200
 @@ -139,6 +139,7 @@
  	qfalse,					/* wolf lighting model? */
  	128,					/* lightmap width/height */
@@ -1825,8 +1825,8 @@
  	1,						/* bsp file version */
 Index: tools/quake3/q3map2/game_etut.h
 ===================================================================
---- tools/quake3/q3map2/game_etut.h	(revision 191)
-+++ tools/quake3/q3map2/game_etut.h	(working copy)
+--- tools/quake3/q3map2/game_etut.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_etut.h	2008-09-06 15:32:16.000000000 +0200
 @@ -148,6 +148,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1837,8 +1837,8 @@
  	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_jk2.h
 ===================================================================
---- tools/quake3/q3map2/game_jk2.h	(revision 191)
-+++ tools/quake3/q3map2/game_jk2.h	(working copy)
+--- tools/quake3/q3map2/game_jk2.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_jk2.h	2008-09-06 15:32:16.000000000 +0200
 @@ -64,6 +64,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1849,8 +1849,8 @@
  	1,					/* bsp file version */
 Index: tools/quake3/q3map2/game_qfusion.h
 ===================================================================
---- tools/quake3/q3map2/game_qfusion.h	(revision 191)
-+++ tools/quake3/q3map2/game_qfusion.h	(working copy)
+--- tools/quake3/q3map2/game_qfusion.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_qfusion.h	2008-09-06 15:32:16.000000000 +0200
 @@ -115,6 +115,7 @@
  	qfalse,				/* wolf lighting model? */
  	512,				/* lightmap width/height */
@@ -1861,8 +1861,8 @@
  	1,					/* bsp file version */
 Index: tools/quake3/q3map2/game_tenebrae.h
 ===================================================================
---- tools/quake3/q3map2/game_tenebrae.h	(revision 191)
-+++ tools/quake3/q3map2/game_tenebrae.h	(working copy)
+--- tools/quake3/q3map2/game_tenebrae.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_tenebrae.h	2008-09-06 15:32:16.000000000 +0200
 @@ -112,6 +112,7 @@
  	qfalse,				/* wolf lighting model? */
  	512,				/* lightmap width/height */
@@ -1873,8 +1873,8 @@
  	46,					/* bsp file version */
 Index: tools/quake3/q3map2/game_quake3.h
 ===================================================================
---- tools/quake3/q3map2/game_quake3.h	(revision 191)
-+++ tools/quake3/q3map2/game_quake3.h	(working copy)
+--- tools/quake3/q3map2/game_quake3.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_quake3.h	2008-09-06 15:32:16.000000000 +0200
 @@ -112,6 +112,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1882,11 +1882,11 @@
 +	1.0f,				/* lightmap exposure */
  	1.0f,				/* lightmap compensate */
  	"IBSP",				/* bsp file prefix */
- 	46,					/* bsp file version */
+ 	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_ef.h
 ===================================================================
---- tools/quake3/q3map2/game_ef.h	(revision 191)
-+++ tools/quake3/q3map2/game_ef.h	(working copy)
+--- tools/quake3/q3map2/game_ef.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_ef.h	2008-09-06 15:32:16.000000000 +0200
 @@ -113,6 +113,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -1897,8 +1897,8 @@
  	46,					/* bsp file version */
 Index: tools/quake3/q3map2/light_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/light_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/light_ydnar.c	(working copy)
+--- tools/quake3/q3map2/light_ydnar.c.orig	2008-09-06 15:32:14.000000000 +0200
++++ tools/quake3/q3map2/light_ydnar.c	2008-09-06 15:32:16.000000000 +0200
 @@ -49,6 +49,7 @@
  	int		i;
  	float	max, gamma;
@@ -1907,10 +1907,19 @@
  	
  	
  	/* ydnar: scaling necessary for simulating r_overbrightBits on external lightmaps */
-@@ -72,16 +73,51 @@
+@@ -72,15 +73,50 @@
  		/* gamma */
  		sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f;
  	}
+-	
+-	/* clamp with color normalization */
+-	max = sample[ 0 ];
+-	if( sample[ 1 ] > max )
+-		max = sample[ 1 ];
+-	if( sample[ 2 ] > max )
+-		max = sample[ 2 ];
+-	if( max > 255.0f )
+-		VectorScale( sample, (255.0f / max), sample );
 +
 +	if (lightmapExposure == 1)
 +	{
@@ -1931,16 +1940,16 @@
 +		}
 +		inv=1.f/lightmapExposure;
 +		//Exposure
-+    	
++
 +		max = sample[ 0 ];
 +		if( sample[ 1 ] > max )
 +			max = sample[ 1 ];
 +		if( sample[ 2 ] > max )
-+			max = sample[ 2 ];  
-+      
++			max = sample[ 2 ];
++
 +		dif = (1-  exp(-max * inv) )  *  255;
 +
-+		if (max >0) 
++		if (max >0)
 +		{
 +			dif = dif / max;
 +		}
@@ -1956,42 +1965,13 @@
 +	}
 +
  	
--	/* clamp with color normalization */
--	max = sample[ 0 ];
--	if( sample[ 1 ] > max )
--		max = sample[ 1 ];
--	if( sample[ 2 ] > max )
--		max = sample[ 2 ];
--	if( max > 255.0f )
--		VectorScale( sample, (255.0f / max), sample );
--	
  	/* compensate for ingame overbrighting/bitshifting */
  	VectorScale( sample, (1.0f / lightmapCompensate), sample );
- 	
-Index: tools/quake3/q3map2/light.c
-===================================================================
---- tools/quake3/q3map2/light.c (revision 191)
-+++ tools/quake3/q3map2/light.c (working copy)
-@@ -1836,6 +1893,14 @@
- 			i++;
- 		}
- 		
-+		else if( !strcmp( argv[ i ], "-exposure" ) )
-+		{
-+			f = atof( argv[ i + 1 ] );
-+			lightmapExposure = f;
-+			Sys_Printf( "Lighting exposure set to %f\n", lightmapExposure );
-+			i++;
-+		}
-+		
- 		else if( !strcmp( argv[ i ], "-compensate" ) )
- 		{
- 			f = atof( argv[ i + 1 ] );
 Index: tools/quake3/q3map2/q3map2.h
 ===================================================================
---- tools/quake3/q3map2/q3map2.h	(revision 191)
-+++ tools/quake3/q3map2/q3map2.h	(working copy)
-@@ -543,6 +545,7 @@
+--- tools/quake3/q3map2/q3map2.h.orig	2008-09-06 15:32:14.000000000 +0200
++++ tools/quake3/q3map2/q3map2.h	2008-09-06 15:32:16.000000000 +0200
+@@ -553,6 +553,7 @@
  	qboolean			wolfLight;						/* when true, lights work like wolf q3map  */
  	int					lightmapSize;					/* bsp lightmap width/height */
  	float				lightmapGamma;					/* default lightmap gamma */
@@ -1999,7 +1979,7 @@
  	float				lightmapCompensate;				/* default lightmap compensate value */
  	char				*bspIdent;						/* 4-letter bsp file prefix */
  	int					bspVersion;						/* bsp version to use */
-@@ -2117,6 +2132,7 @@
+@@ -2139,6 +2140,7 @@
  
  /* ydnar: lightmap gamma/compensation */
  Q_EXTERN float				lightmapGamma Q_ASSIGN( 1.0f );
@@ -2007,11 +1987,30 @@
  Q_EXTERN float				lightmapCompensate Q_ASSIGN( 1.0f );
  
  /* ydnar: for runtime tweaking of falloff tolerance */
+Index: tools/quake3/q3map2/light.c
+===================================================================
+--- tools/quake3/q3map2/light.c.orig	2008-09-06 15:32:14.000000000 +0200
++++ tools/quake3/q3map2/light.c	2008-09-06 15:32:16.000000000 +0200
+@@ -1893,6 +1893,14 @@
+ 			i++;
+ 		}
+ 		
++		else if( !strcmp( argv[ i ], "-exposure" ) )
++		{
++			f = atof( argv[ i + 1 ] );
++			lightmapExposure = f;
++			Sys_Printf( "Lighting exposure set to %f\n", lightmapExposure );
++			i++;
++		}
++
+ 		else if( !strcmp( argv[ i ], "-compensate" ) )
+ 		{
+ 			f = atof( argv[ i + 1 ] );
 Index: tools/quake3/q3map2/light_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/light_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/light_ydnar.c	(working copy)
-@@ -384,7 +420,7 @@
+--- tools/quake3/q3map2/light_ydnar.c.orig	2008-09-06 15:32:16.000000000 +0200
++++ tools/quake3/q3map2/light_ydnar.c	2008-09-06 15:32:18.000000000 +0200
+@@ -420,7 +420,7 @@
  #define NUDGE			0.5f
  #define BOGUS_NUDGE		-99999.0f
  
@@ -2020,7 +2019,7 @@
  {
  	int				i, x, y, numClusters, *clusters, pointCluster, *cluster;
  	float			*luxel, *origin, *normal, d, lightmapSampleOffset;
-@@ -392,6 +428,12 @@
+@@ -428,6 +428,12 @@
  	vec3_t			pNormal;
  	vec3_t			vecs[ 3 ];
  	vec3_t			nudged;
@@ -2033,7 +2032,7 @@
  	float			*nudge;
  	static float	nudges[][ 2 ] =
  					{
-@@ -485,6 +527,51 @@
+@@ -521,6 +527,51 @@
  	/* non axial lightmap projection (explicit xyz) */
  	else
  		VectorCopy( dv->xyz, origin );
@@ -2047,7 +2046,7 @@
 +	{
 +		for (j=0;j<3;j++)
 +		{
-+			VectorCopy(worldverts[j],cverts[j]);    
++			VectorCopy(worldverts[j],cverts[j]);
 +		}
 +		PlaneFromPoints(hostplane,cverts[0],cverts[1],cverts[2]);
 +
@@ -2062,7 +2061,7 @@
 +				VectorAdd(temp,hostplane,temp);
 +				PlaneFromPoints(sideplane,cverts[i],cverts[ next ], temp);
 +
-+				//planetest sample point  
++				//planetest sample point
 +				e=DotProduct(origin,sideplane);
 +				e=e-sideplane[3];
 +				if (e>0)
@@ -2075,7 +2074,7 @@
 +					origin[2]-=sideplane[2]*(e+1);
 +#ifdef DEBUG_27_1
 +					VectorClear(origin);
-+#endif 
++#endif
 +				}
 +			}
 +		}
@@ -2085,7 +2084,7 @@
  	
  	/* planar surfaces have precalculated lightmap vectors for nudging */
  	if( lm->plane != NULL )
-@@ -516,8 +603,13 @@
+@@ -552,8 +603,13 @@
  	else
  		origin[ lm->axisNum ] += lightmapSampleOffset;
  	
@@ -2093,14 +2092,14 @@
 +	origintwo[0]+=vecs[2][0];
 +	origintwo[1]+=vecs[2][1];
 +	origintwo[2]+=vecs[2][2];
-+	
++
  	/* get cluster */
 -	pointCluster = ClusterForPointExtFilter( origin, LUXEL_EPSILON, numClusters, clusters );
 +	pointCluster = ClusterForPointExtFilter( origintwo, LUXEL_EPSILON, numClusters, clusters );
  	
  	/* another retarded hack, storing nudge count in luxel[ 1 ] */
  	luxel[ 1 ] = 0.0f;	
-@@ -533,14 +625,14 @@
+@@ -569,14 +625,14 @@
  			for( i = 0; i < 3; i++ )
  			{
  				/* set nudged point*/
@@ -2113,12 +2112,12 @@
  			pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters ); //% + 0.625 );
 -			if( pointCluster >= 0 )	
 -				VectorCopy( nudged, origin );
-+			//if( pointCluster >= 0 )	
++			//if( pointCluster >= 0 )
 +   			//	VectorCopy( nudged, origin );
  			luxel[ 1 ] += 1.0f;
  		}
  	}
-@@ -550,8 +642,8 @@
+@@ -586,8 +642,8 @@
  	{
  		VectorMA( dv->xyz, lightmapSampleOffset, dv->normal, nudged );
  		pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters );
@@ -2129,7 +2128,7 @@
  		luxel[ 1 ] += 1.0f;
  	}
  	
-@@ -597,7 +689,7 @@
+@@ -633,7 +689,7 @@
  than the distance between two luxels (thanks jc :)
  */
  
@@ -2138,7 +2137,7 @@
  {
  	bspDrawVert_t	mid, *dv2[ 3 ];
  	int				max;
-@@ -645,7 +737,7 @@
+@@ -681,7 +737,7 @@
  	
  	/* split the longest edge and map it */
  	LerpDrawVert( dv[ max ], dv[ (max + 1) % 3 ], &mid );
@@ -2147,7 +2146,7 @@
  	
  	/* push the point up a little bit to account for fp creep (fixme: revisit this) */
  	//%	VectorMA( mid.xyz, 2.0f, mid.normal, mid.xyz );
-@@ -653,12 +745,12 @@
+@@ -689,12 +745,12 @@
  	/* recurse to first triangle */
  	VectorCopy( dv, dv2 );
  	dv2[ max ] = &mid;
@@ -2162,7 +2161,7 @@
  }
  
  
-@@ -674,6 +766,7 @@
+@@ -710,6 +766,7 @@
  	int				i;
  	vec4_t			plane;
  	vec3_t			*stv, *ttv, stvStatic[ 3 ], ttvStatic[ 3 ];
@@ -2170,14 +2169,14 @@
  	
  	
  	/* get plane if possible */
-@@ -699,16 +792,20 @@
+@@ -735,16 +792,20 @@
  		ttv = NULL;
  	}
  	
 +	VectorCopy( dv[ 0 ]->xyz, worldverts[ 0 ] );
 +	VectorCopy( dv[ 1 ]->xyz, worldverts[ 1 ] );
 +	VectorCopy( dv[ 2 ]->xyz, worldverts[ 2 ] );
-+	
++
  	/* map the vertexes */
 -	MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv );
 -	MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv );
@@ -2195,7 +2194,7 @@
  		return qtrue;
  	}
  	
-@@ -730,7 +827,7 @@
+@@ -766,7 +827,7 @@
  			dv2[ 2 ] = dv[ (i + 1) % 3 ];
  			
  			/* map the degenerate triangle */
@@ -2204,7 +2203,7 @@
  		}
  	}
  	
-@@ -792,8 +889,8 @@
+@@ -828,8 +889,8 @@
  	LerpDrawVert( dv[ max + 2 ], dv[ (max + 3) % 4 ], &mid[ 1 ] );
  	
  	/* map the vertexes */
@@ -2215,7 +2214,7 @@
  	
  	/* 0 and 2 */
  	if( max == 0 )
-@@ -878,10 +975,10 @@
+@@ -914,10 +975,10 @@
  	}
  	
  	/* map the vertexes */
@@ -2230,7 +2229,7 @@
  	
  	/* subdivide the quad */
  	MapQuad_r( lm, info, dv, plane, stv, ttv );
-@@ -1173,7 +1270,7 @@
+@@ -1209,7 +1270,7 @@
  					continue;
  				
  				/* map the fake vert */
@@ -2239,7 +2238,7 @@
  			}
  		}
  	}
-@@ -1963,22 +2062,32 @@
+@@ -2001,22 +2062,32 @@
  					deluxel = SUPER_DELUXEL( x, y );
  					origin = SUPER_ORIGIN( x, y );
  					normal = SUPER_NORMAL( x, y );
@@ -2270,16 +2269,16 @@
 +					{
 +						/* set contribution count */
 +						lightLuxel[ 3 ] = 1.0f;
-+						
++
 +						/* setup trace */
 +						trace.cluster = *cluster;
 +						VectorCopy( origin, trace.origin );
 +						VectorCopy( normal, trace.normal );
-+						
++
 +						/* get light for this sample */
 +						LightContributionToSample( &trace );
 +						VectorCopy( trace.color, lightLuxel );
-+						
++
 +						/* add to count */
 +						if( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] )
 +							totalLighted++;

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/both-obj.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/both-obj.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/both-obj.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,7 +1,7 @@
 Index: libs/picomodel/pm_obj.c
 ===================================================================
---- libs/picomodel/pm_obj.c	(revision 290)
-+++ libs/picomodel/pm_obj.c	(working copy)
+--- libs/picomodel/pm_obj.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ libs/picomodel/pm_obj.c	2008-09-06 15:32:09.000000000 +0200
 @@ -215,10 +215,9 @@
  	}
  }

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/gtkradiant-targetname.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/gtkradiant-targetname.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/gtkradiant-targetname.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,7 +1,7 @@
 Index: radiant/map.cpp
 ===================================================================
---- radiant/map.cpp	(revision 304)
-+++ radiant/map.cpp	(working copy)
+--- radiant/map.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/map.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -270,6 +270,100 @@
    ents->RemoveAll();
  }
@@ -79,7 +79,7 @@
 +			if(e_target != NULL)
 +			{
 +				const char *targetname = ValueForKey(e_target, "targetname");
-+				if( (targetname != NULL) && (strcmp(target, targetname) == 0) ) 
++				if( (targetname != NULL) && (strcmp(target, targetname) == 0) )
 +				{
 +					SetKeyValue(e_target, "targetname", newtarget);
 +				}
@@ -114,9 +114,7 @@
 -        entity_t *e_target;
 -        const char *target = ValueForKey(e, "target");
 -        qboolean bCollision=FALSE;
-+      // keep a list of ents added to avoid testing collisions against them
-+      g_ptr_array_add(new_ents, (gpointer)e);
- 
+-
 -        // check the current map entities for an actual collision
 -        for (e_target = entities.next; e_target != &entities; e_target = e_target->next)
 -        {
@@ -156,7 +154,9 @@
 -          g_ptr_array_free(t_ents, FALSE);
 -        }
 -      }
--
++      // keep a list of ents added to avoid testing collisions against them
++      g_ptr_array_add(new_ents, (gpointer)e);
+ 
        // add the entity to the end of the entity list
        Entity_AddToList(e, &entities);
        g_qeglobals.d_num_entities++;
@@ -182,8 +182,8 @@
    g_ptr_array_free(new_ents, FALSE);
 Index: radiant/drag.cpp
 ===================================================================
---- radiant/drag.cpp	(revision 304)
-+++ radiant/drag.cpp	(working copy)
+--- radiant/drag.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/drag.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -255,54 +255,6 @@
  
  entity_t *peLink;
@@ -241,8 +241,8 @@
  Drag_Begin
 Index: radiant/xywindow.cpp
 ===================================================================
---- radiant/xywindow.cpp	(revision 304)
-+++ radiant/xywindow.cpp	(working copy)
+--- radiant/xywindow.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/xywindow.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -270,16 +270,17 @@
  void DrawPathLines (void)
  {
@@ -327,8 +327,8 @@
  
 Index: radiant/targetname.cpp
 ===================================================================
---- radiant/targetname.cpp	(revision 304)
-+++ radiant/targetname.cpp	(working copy)
+--- radiant/targetname.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/targetname.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -24,11 +24,11 @@
  /*!
  connects two entities creating a unique target/targetname value 
@@ -422,8 +422,8 @@
  	if (fFound)
 Index: radiant/qe3.cpp
 ===================================================================
---- radiant/qe3.cpp	(revision 304)
-+++ radiant/qe3.cpp	(working copy)
+--- radiant/qe3.cpp.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/qe3.cpp	2008-09-06 15:32:10.000000000 +0200
 @@ -704,7 +704,7 @@
  from the first selected to the secon
  ===============
@@ -459,8 +459,8 @@
    }
 Index: radiant/qe3.h
 ===================================================================
---- radiant/qe3.h	(revision 304)
-+++ radiant/qe3.h	(working copy)
+--- radiant/qe3.h.orig	2008-09-06 15:32:05.000000000 +0200
++++ radiant/qe3.h	2008-09-06 15:32:10.000000000 +0200
 @@ -229,7 +229,7 @@
  void SelectEdgeByRay (vec3_t org, vec3_t dir);
  void SelectVertexByRay (vec3_t org, vec3_t dir);

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTavgcolorfix.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTavgcolorfix.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTavgcolorfix.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,8 +1,8 @@
 Index: tools/quake3/q3map2/shaders.c
 ===================================================================
---- tools/quake3/q3map2/shaders.c	(revision 191)
-+++ tools/quake3/q3map2/shaders.c	(working copy)
-@@ -793,8 +793,14 @@
+--- tools/quake3/q3map2/shaders.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/shaders.c	2008-09-06 15:32:13.000000000 +0200
+@@ -794,8 +794,14 @@
  	}
  	
  	if( VectorLength( si->color ) <= 0.0f )

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTfloodlight.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTfloodlight.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTfloodlight.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,8 +1,8 @@
 Index: tools/quake3/q3map2/light_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/light_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/light_ydnar.c	(working copy)
-@@ -1767,6 +1864,8 @@
+--- tools/quake3/q3map2/light_ydnar.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/light_ydnar.c	2008-09-06 15:32:14.000000000 +0200
+@@ -1767,6 +1767,8 @@
  	float				tests[ 4 ][ 2 ] = { { 0.0f, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } };
  	trace_t				trace;
  	float				stackLightLuxels[ STACK_LL_SIZE ];
@@ -11,7 +11,7 @@
  	
  	
  	/* bail if this number exceeds the number of raw lightmaps */
-@@ -2223,6 +2332,78 @@
+@@ -2223,6 +2225,78 @@
  	FreeTraceLights( &trace );
  	
  	/*	-----------------------------------------------------------------
@@ -26,7 +26,7 @@
 +			/* early out */
 +			if( lm->superLuxels[ lightmapNum ] == NULL )
 +				continue;
-+			
++
 +			/* apply floodlight to each luxel */
 +			for( y = 0; y < lm->sh; y++ )
 +			{
@@ -36,21 +36,21 @@
 +					cluster	= SUPER_CLUSTER( x, y );
 +					//%	if( *cluster < 0 )
 +					//%		continue;
-+					
++
 +					/* get particulars */
 +					luxel = SUPER_LUXEL( lightmapNum, x, y );
 +					floodlight = SUPER_FLOODLIGHT( x, y );
-+					
++
 +					flood[0]=floodlightRGB[0]*floodlightIntensity;
 +					flood[1]=floodlightRGB[1]*floodlightIntensity;
 +					flood[2]=floodlightRGB[2]*floodlightIntensity;
-+					             
++
 +					/* scale light value */
 +					VectorScale( flood, *floodlight, flood );
 +					luxel[0]+=flood[0];
 +					luxel[1]+=flood[1];
 +					luxel[2]+=flood[2];
-+					
++
 +					if (luxel[3]==0) luxel[3]=1;
 +				}
 +			}
@@ -64,7 +64,7 @@
 +			/* early out */
 +			if( lm->superLuxels[ lightmapNum ] == NULL )
 +				continue;
-+			
++
 +			for( y = 0; y < lm->sh; y++ )
 +			{
 +				for( x = 0; x < lm->sw; x++ )
@@ -73,11 +73,11 @@
 +					cluster	= SUPER_CLUSTER( x, y );
 +					//%	if( *cluster < 0 )
 +					//%		continue;
-+					
++
 +					/* get particulars */
 +					luxel = SUPER_LUXEL( lightmapNum, x, y );
 +					normal = SUPER_NORMAL (  x, y );
-+               
++
 +					luxel[0]=(normal[0]*127)+127;
 +					luxel[1]=(normal[1]*127)+127;
 +					luxel[2]=(normal[2]*127)+127;
@@ -85,39 +85,39 @@
 +			}
 +		}
 +	}
-+	
++
 +	/*	-----------------------------------------------------------------
  		dirt pass
  		----------------------------------------------------------------- */
  	
-@@ -3587,7 +3768,320 @@
+@@ -3587,7 +3661,320 @@
  	CreateTraceLightsForBounds( mins, maxs, normal, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ], LIGHT_SURFACES, trace );
  }
  
 +/////////////////////////////////////////////////////////////
- 
++
 +#define FLOODLIGHT_CONE_ANGLE			88	/* degrees */
 +#define FLOODLIGHT_NUM_ANGLE_STEPS		16
 +#define FLOODLIGHT_NUM_ELEVATION_STEPS	4
 +#define FLOODLIGHT_NUM_VECTORS			(FLOODLIGHT_NUM_ANGLE_STEPS * FLOODLIGHT_NUM_ELEVATION_STEPS)
- 
++
 +static vec3_t	floodVectors[ FLOODLIGHT_NUM_VECTORS ];
 +static int		numFloodVectors = 0;
- 
++
 +void SetupFloodLight( void )
 +{
 +	int		i, j;
 +	float	angle, elevation, angleStep, elevationStep;
 +	const char	*value;
 +	double v1,v2,v3,v4,v5;
-+	
++
 +	/* note it */
 +	Sys_FPrintf( SYS_VRB, "--- SetupFloodLight ---\n" );
-+	
++
 +	/* calculate angular steps */
 +	angleStep = DEG2RAD( 360.0f / FLOODLIGHT_NUM_ANGLE_STEPS );
 +	elevationStep = DEG2RAD( FLOODLIGHT_CONE_ANGLE / FLOODLIGHT_NUM_ELEVATION_STEPS );
-+	
++
 +	/* iterate angle */
 +	angle = 0.0f;
 +	for( i = 0, angle = 0.0f; i < FLOODLIGHT_NUM_ANGLE_STEPS; i++, angle += angleStep )
@@ -131,36 +131,36 @@
 +			numFloodVectors++;
 +		}
 +	}
-+	
++
 +	/* emit some statistics */
 +	Sys_FPrintf( SYS_VRB, "%9d numFloodVectors\n", numFloodVectors );
  
 +      /* floodlight */
 +	value = ValueForKey( &entities[ 0 ], "_floodlight" );
-+	
+ 
 +	if( value[ 0 ] != '\0' )
 +	{
 +		v1=v2=v3=0;
 +		v4=floodlightDistance;
 +		v5=floodlightIntensity;
-+		
++
 +		sscanf( value, "%lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5);
-+		
++
 +		floodlightRGB[0]=v1;
 +		floodlightRGB[1]=v2;
 +		floodlightRGB[2]=v3;
-+		
++
 +		if (VectorLength(floodlightRGB)==0)
 +		{
 +			VectorSet(floodlightRGB,240,240,255);
 +		}
-+		
+ 
 +		if (v4<1) v4=1024;
 +		if (v5<1) v5=128;
-+		
++
 +		floodlightDistance=v4;
 +		floodlightIntensity=v5;
-+    
++
 +		floodlighty = qtrue;
 +		Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" );
 +	}
@@ -182,14 +182,14 @@
 +	rawLightmap_t		*lm;
 +	surfaceInfo_t		*info;
 +	trace_t				trace;
-+	
++
 +	/* bail if this number exceeds the number of raw lightmaps */
 +	if( rawLightmapNum >= numRawLightmaps )
 +		return;
-+	
++
 +	/* get lightmap */
 +	lm = &rawLightmaps[ rawLightmapNum ];
-+	
++
 +	memset(&trace,0,sizeof(trace_t));
 +	/* setup trace */
 +	trace.testOcclusion = qtrue;
@@ -201,14 +201,14 @@
 +	trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
 +	trace.testAll = qfalse;
 +	trace.distance = 1024;
-+	
++
 +	/* twosided lighting (may or may not be a good idea for lightmapped stuff) */
 +	//trace.twoSided = qfalse;
 +	for( i = 0; i < trace.numSurfaces; i++ )
 +	{
 +		/* get surface */
 +		info = &surfaceInfos[ trace.surfaces[ i ] ];
-+		
++
 +		/* check twosidedness */
 +		if( info->si->twoSided )
 +		{
@@ -216,7 +216,7 @@
 +			break;
 +		}
 +	}
-+	
++
 +	/* gather dirt */
 +	for( y = 0; y < lm->sh; y++ )
 +	{
@@ -227,29 +227,29 @@
 +			origin = SUPER_ORIGIN( x, y );
 +			normal = SUPER_NORMAL( x, y );
 +			floodlight = SUPER_FLOODLIGHT( x, y );
-+			
++
 +			/* set default dirt */
 +			*floodlight = 0.0f;
-+			
++
 +			/* only look at mapped luxels */
 +			if( *cluster < 0 )
 +				continue;
-+			
++
 +			/* copy to trace */
 +			trace.cluster = *cluster;
 +			VectorCopy( origin, trace.origin );
 +			VectorCopy( normal, trace.normal );
-+         
 +
-+		
++
++
 +			/* get dirt */
 +			*floodlight = FloodLightForSample( &trace );
 +		}
 +	}
-+	
++
 +	/* testing no filtering */
 +	return;
-+	
++
 +	/* filter "dirt" */
 +	for( y = 0; y < lm->sh; y++ )
 +	{
@@ -258,7 +258,7 @@
 +			/* get luxel */
 +			cluster = SUPER_CLUSTER( x, y );
 +			floodlight = SUPER_FLOODLIGHT( x, y );
-+			
++
 +			/* filter dirt by adjacency to unmapped luxels */
 +			average = *floodlight;
 +			samples = 1.0f;
@@ -266,32 +266,32 @@
 +			{
 +				if( sy < 0 || sy >= lm->sh )
 +					continue;
-+				
++
 +				for( sx = (x - 1); sx <= (x + 1); sx++ )
 +				{
 +					if( sx < 0 || sx >= lm->sw || (sx == x && sy == y) )
 +						continue;
-+					
++
 +					/* get neighboring luxel */
 +					cluster = SUPER_CLUSTER( sx, sy );
 +					floodlight2 = SUPER_FLOODLIGHT( sx, sy );
 +					if( *cluster < 0 || *floodlight2 <= 0.0f )
 +						continue;
-+					
++
 +					/* add it */
 +					average += *floodlight2;
 +					samples += 1.0f;
 +				}
-+				
++
 +				/* bail */
 +				if( samples <= 0.0f )
 +					break;
 +			}
-+			
++
 +			/* bail */
 +			if( samples <= 0.0f )
 +				continue;
-+			
++
 +			/* scale dirt */
 +			*floodlight = average / samples;
 +		}
@@ -313,23 +313,23 @@
 +	vec3_t	normal, worldUp, myUp, myRt, direction, displacement;
 +	float 	dd;
 +	int 	vecs = 0;
-+ 
++
 +	gatherLight=0;
 +	/* dummy check */
 +	//if( !dirty )
 +	//	return 1.0f;
 +	if( trace == NULL || trace->cluster < 0 )
 +		return 0.0f;
-+	
 +
++
 +	/* setup */
 +	dd = floodlightDistance;
 +	VectorCopy( trace->normal, normal );
-+	
++
 +	/* check if the normal is aligned to the world-up */
 +	if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f )
 +	{
-+		if( normal[ 2 ] == 1.0f )		
++		if( normal[ 2 ] == 1.0f )
 +		{
 +			VectorSet( myRt, 1.0f, 0.0f, 0.0f );
 +			VectorSet( myUp, 0.0f, 1.0f, 0.0f );
@@ -358,7 +358,7 @@
 +		}
 +
 +		vecs++;
-+         
++
 +		/* transform vector into tangent space */
 +		direction[ 0 ] = myRt[ 0 ] * floodVectors[ i ][ 0 ] + myUp[ 0 ] * floodVectors[ i ][ 1 ] + normal[ 0 ] * floodVectors[ i ][ 2 ];
 +		direction[ 1 ] = myRt[ 1 ] * floodVectors[ i ][ 0 ] + myUp[ 1 ] * floodVectors[ i ][ 1 ] + normal[ 1 ] * floodVectors[ i ][ 2 ];
@@ -368,7 +368,7 @@
 +		VectorMA( trace->origin, dd, direction, trace->end );
 +
 +		//VectorMA( trace->origin, 1, direction, trace->origin );
-+			
++
 +		SetupTrace( trace );
 +		/* trace */
 +	  	TraceLine( trace );
@@ -383,21 +383,21 @@
 +			VectorSubtract( trace->hit, trace->origin, displacement );
 +			d=VectorLength( displacement );
 +
-+			// d=trace->distance;            
++			// d=trace->distance;
 +			//if (d>256) gatherDirt+=1;
 +			contribution=d/dd;
-+			if (contribution>1) contribution=1.0f; 
-+             
++			if (contribution>1) contribution=1.0f;
++
 +			//gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
 +		}
-+         
++
 +		gatherLight+=contribution;
 +	}
-+   
++
 +	/* early out */
 +	if( gatherLight <= 0.0f )
 +		return 0.0f;
-+   	
++
 +	sub=vecs;
 +
 +	if (sub<1) sub=1;
@@ -406,15 +406,15 @@
 +	outLight=gatherLight;
 +	if( outLight > 1.0f )
 +		outLight = 1.0f;
-+	
++
 +	/* return to sender */
 +	return outLight;
 +}
-+
+ 
 Index: tools/quake3/q3map2/light.c
 ===================================================================
---- tools/quake3/q3map2/light.c	(revision 191)
-+++ tools/quake3/q3map2/light.c	(working copy)
+--- tools/quake3/q3map2/light.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/light.c	2008-09-06 15:32:14.000000000 +0200
 @@ -1378,6 +1378,56 @@
  			break;
  	}
@@ -429,12 +429,12 @@
 +		col[0]=col[1]=col[2]=floodlightIntensity;
 +		dir[0]=dir[1]=0;
 +		dir[2]=1;
-+      
++
 +		trace.testOcclusion = qtrue;
 +		trace.forceSunlight = qfalse;
 +		trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
-+		trace.testAll = qtrue;     
-+      
++		trace.testAll = qtrue;
++
 +		for (q=0;q<2;q++)
 +		{
 +			if (q==0) //upper hemisphere
@@ -461,7 +461,7 @@
 +			contributions[ numCon ].dir[2]=dir[2];
 +
 +			contributions[ numCon ].style = 0;
-+			numCon++;		
++			numCon++;
 +			/* push average direction around */
 +			addSize = VectorLength( col );
 +			VectorMA( gp->dir, addSize, dir, gp->dir );
@@ -493,7 +493,7 @@
  		
  		/* generate diffuse lights */
  		RadFreeLights();
-@@ -2191,6 +2256,21 @@
+@@ -2191,6 +2248,21 @@
  			cpmaHack = qtrue;
  			Sys_Printf( "Enabling Challenge Pro Mode Asstacular Vertex Lighting Mode (tm)\n" );
  		}
@@ -515,7 +515,7 @@
  		
  		/* r7: dirtmapping */
  		else if( !strcmp( argv[ i ], "-dirty" ) )
-@@ -2279,6 +2359,7 @@
+@@ -2279,6 +2351,7 @@
  	/* ydnar: set up optimization */
  	SetupBrushes();
  	SetupDirt();
@@ -525,8 +525,8 @@
  	/* initialize the surface facet tracing */
 Index: tools/quake3/q3map2/lightmaps_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/lightmaps_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/lightmaps_ydnar.c	(working copy)
+--- tools/quake3/q3map2/lightmaps_ydnar.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/lightmaps_ydnar.c	2008-09-06 15:32:14.000000000 +0200
 @@ -414,6 +414,12 @@
  		lm->superNormals = safe_malloc( size );
  	memset( lm->superNormals, 0, size );
@@ -536,15 +536,15 @@
 +	if( lm->superFloodLight == NULL )
 +		lm->superFloodLight = safe_malloc( size );
 +	memset( lm->superFloodLight, 0, size );
-+	
++
  	/* allocate cluster map storage */
  	size = lm->sw * lm->sh * sizeof( int );
  	if( lm->superClusters == NULL )
 Index: tools/quake3/q3map2/q3map2.h
 ===================================================================
---- tools/quake3/q3map2/q3map2.h	(revision 191)
-+++ tools/quake3/q3map2/q3map2.h	(working copy)
-@@ -267,6 +267,7 @@
+--- tools/quake3/q3map2/q3map2.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/q3map2.h	2008-09-06 15:32:14.000000000 +0200
+@@ -266,6 +266,7 @@
  #define SUPER_NORMAL_SIZE		4
  #define SUPER_DELUXEL_SIZE		3
  #define BSP_DELUXEL_SIZE		3
@@ -552,23 +552,23 @@
  
  #define VERTEX_LUXEL( s, v )	(vertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
  #define RAD_VERTEX_LUXEL( s, v )(radVertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
-@@ -279,6 +280,7 @@
+@@ -278,6 +279,7 @@
  #define SUPER_ORIGIN( x, y )	(lm->superOrigins + ((((y) * lm->sw) + (x)) * SUPER_ORIGIN_SIZE))
  #define SUPER_NORMAL( x, y )	(lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE))
  #define SUPER_DIRT( x, y )		(lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE) + 3)	/* stash dirtyness in normal[ 3 ] */
-+#define SUPER_FLOODLIGHT( x, y )	(lm->superFloodLight + ((((y) * lm->sw) + (x)) * SUPER_FLOODLIGHT_SIZE) )	
++#define SUPER_FLOODLIGHT( x, y )	(lm->superFloodLight + ((((y) * lm->sw) + (x)) * SUPER_FLOODLIGHT_SIZE) )
  
  
  
-@@ -1392,6 +1395,7 @@
+@@ -1400,6 +1402,7 @@
  	
  	float					*superDeluxels;	/* average light direction */
  	float					*bspDeluxels;
-+	float					*superFloodLight; 
++	float					*superFloodLight;
  }
  rawLightmap_t;
  
-@@ -1704,6 +1708,10 @@
+@@ -1712,6 +1715,10 @@
  float						DirtForSample( trace_t *trace );
  void						DirtyRawLightmap( int num );
  
@@ -579,7 +579,7 @@
  void						IlluminateRawLightmap( int num );
  void						IlluminateVertexes( int num );
  
-@@ -2098,6 +2106,13 @@
+@@ -2106,6 +2113,13 @@
  Q_EXTERN float				dirtScale Q_ASSIGN( 1.0f );
  Q_EXTERN float				dirtGain Q_ASSIGN( 1.0f );
  

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTlmexposure.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTlmexposure.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTlmexposure.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,7 +1,7 @@
 Index: tools/quake3/q3map2/game_ja.h
 ===================================================================
---- tools/quake3/q3map2/game_ja.h	(revision 191)
-+++ tools/quake3/q3map2/game_ja.h	(working copy)
+--- tools/quake3/q3map2/game_ja.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_ja.h	2008-09-06 15:32:16.000000000 +0200
 @@ -67,6 +67,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -12,8 +12,8 @@
  	1,					/* bsp file version */
 Index: tools/quake3/q3map2/game_tremulous.h
 ===================================================================
---- tools/quake3/q3map2/game_tremulous.h	(revision 191)
-+++ tools/quake3/q3map2/game_tremulous.h	(working copy)
+--- tools/quake3/q3map2/game_tremulous.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_tremulous.h	2008-09-06 15:32:16.000000000 +0200
 @@ -70,6 +70,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -24,8 +24,8 @@
  	46,					/* bsp file version */
 Index: tools/quake3/q3map2/game_wolfet.h
 ===================================================================
---- tools/quake3/q3map2/game_wolfet.h	(revision 191)
-+++ tools/quake3/q3map2/game_wolfet.h	(working copy)
+--- tools/quake3/q3map2/game_wolfet.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_wolfet.h	2008-09-06 15:32:16.000000000 +0200
 @@ -66,6 +66,7 @@
  	qtrue,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -36,8 +36,8 @@
  	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_wolf.h
 ===================================================================
---- tools/quake3/q3map2/game_wolf.h	(revision 191)
-+++ tools/quake3/q3map2/game_wolf.h	(working copy)
+--- tools/quake3/q3map2/game_wolf.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_wolf.h	2008-09-06 15:32:16.000000000 +0200
 @@ -129,6 +129,7 @@
  	qtrue,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -48,8 +48,8 @@
  	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_sof2.h
 ===================================================================
---- tools/quake3/q3map2/game_sof2.h	(revision 191)
-+++ tools/quake3/q3map2/game_sof2.h	(working copy)
+--- tools/quake3/q3map2/game_sof2.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_sof2.h	2008-09-06 15:32:16.000000000 +0200
 @@ -139,6 +139,7 @@
  	qfalse,					/* wolf lighting model? */
  	128,					/* lightmap width/height */
@@ -60,8 +60,8 @@
  	1,						/* bsp file version */
 Index: tools/quake3/q3map2/game_etut.h
 ===================================================================
---- tools/quake3/q3map2/game_etut.h	(revision 191)
-+++ tools/quake3/q3map2/game_etut.h	(working copy)
+--- tools/quake3/q3map2/game_etut.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_etut.h	2008-09-06 15:32:16.000000000 +0200
 @@ -148,6 +148,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -72,8 +72,8 @@
  	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_jk2.h
 ===================================================================
---- tools/quake3/q3map2/game_jk2.h	(revision 191)
-+++ tools/quake3/q3map2/game_jk2.h	(working copy)
+--- tools/quake3/q3map2/game_jk2.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_jk2.h	2008-09-06 15:32:16.000000000 +0200
 @@ -64,6 +64,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -84,8 +84,8 @@
  	1,					/* bsp file version */
 Index: tools/quake3/q3map2/game_qfusion.h
 ===================================================================
---- tools/quake3/q3map2/game_qfusion.h	(revision 191)
-+++ tools/quake3/q3map2/game_qfusion.h	(working copy)
+--- tools/quake3/q3map2/game_qfusion.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_qfusion.h	2008-09-06 15:32:16.000000000 +0200
 @@ -115,6 +115,7 @@
  	qfalse,				/* wolf lighting model? */
  	512,				/* lightmap width/height */
@@ -96,8 +96,8 @@
  	1,					/* bsp file version */
 Index: tools/quake3/q3map2/game_tenebrae.h
 ===================================================================
---- tools/quake3/q3map2/game_tenebrae.h	(revision 191)
-+++ tools/quake3/q3map2/game_tenebrae.h	(working copy)
+--- tools/quake3/q3map2/game_tenebrae.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_tenebrae.h	2008-09-06 15:32:16.000000000 +0200
 @@ -112,6 +112,7 @@
  	qfalse,				/* wolf lighting model? */
  	512,				/* lightmap width/height */
@@ -108,8 +108,8 @@
  	46,					/* bsp file version */
 Index: tools/quake3/q3map2/game_quake3.h
 ===================================================================
---- tools/quake3/q3map2/game_quake3.h	(revision 191)
-+++ tools/quake3/q3map2/game_quake3.h	(working copy)
+--- tools/quake3/q3map2/game_quake3.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_quake3.h	2008-09-06 15:32:16.000000000 +0200
 @@ -112,6 +112,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -117,11 +117,11 @@
 +	1.0f,				/* lightmap exposure */
  	1.0f,				/* lightmap compensate */
  	"IBSP",				/* bsp file prefix */
- 	46,					/* bsp file version */
+ 	47,					/* bsp file version */
 Index: tools/quake3/q3map2/game_ef.h
 ===================================================================
---- tools/quake3/q3map2/game_ef.h	(revision 191)
-+++ tools/quake3/q3map2/game_ef.h	(working copy)
+--- tools/quake3/q3map2/game_ef.h.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/game_ef.h	2008-09-06 15:32:16.000000000 +0200
 @@ -113,6 +113,7 @@
  	qfalse,				/* wolf lighting model? */
  	128,				/* lightmap width/height */
@@ -132,8 +132,8 @@
  	46,					/* bsp file version */
 Index: tools/quake3/q3map2/light_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/light_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/light_ydnar.c	(working copy)
+--- tools/quake3/q3map2/light_ydnar.c.orig	2008-09-06 15:32:14.000000000 +0200
++++ tools/quake3/q3map2/light_ydnar.c	2008-09-06 15:32:16.000000000 +0200
 @@ -49,6 +49,7 @@
  	int		i;
  	float	max, gamma;
@@ -142,10 +142,19 @@
  	
  	
  	/* ydnar: scaling necessary for simulating r_overbrightBits on external lightmaps */
-@@ -72,16 +73,51 @@
+@@ -72,15 +73,50 @@
  		/* gamma */
  		sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f;
  	}
+-	
+-	/* clamp with color normalization */
+-	max = sample[ 0 ];
+-	if( sample[ 1 ] > max )
+-		max = sample[ 1 ];
+-	if( sample[ 2 ] > max )
+-		max = sample[ 2 ];
+-	if( max > 255.0f )
+-		VectorScale( sample, (255.0f / max), sample );
 +
 +	if (lightmapExposure == 1)
 +	{
@@ -166,16 +175,16 @@
 +		}
 +		inv=1.f/lightmapExposure;
 +		//Exposure
-+    	
++
 +		max = sample[ 0 ];
 +		if( sample[ 1 ] > max )
 +			max = sample[ 1 ];
 +		if( sample[ 2 ] > max )
-+			max = sample[ 2 ];  
-+      
++			max = sample[ 2 ];
++
 +		dif = (1-  exp(-max * inv) )  *  255;
 +
-+		if (max >0) 
++		if (max >0)
 +		{
 +			dif = dif / max;
 +		}
@@ -191,42 +200,13 @@
 +	}
 +
  	
--	/* clamp with color normalization */
--	max = sample[ 0 ];
--	if( sample[ 1 ] > max )
--		max = sample[ 1 ];
--	if( sample[ 2 ] > max )
--		max = sample[ 2 ];
--	if( max > 255.0f )
--		VectorScale( sample, (255.0f / max), sample );
--	
  	/* compensate for ingame overbrighting/bitshifting */
  	VectorScale( sample, (1.0f / lightmapCompensate), sample );
- 	
-Index: tools/quake3/q3map2/light.c
-===================================================================
---- tools/quake3/q3map2/light.c (revision 191)
-+++ tools/quake3/q3map2/light.c (working copy)
-@@ -1836,6 +1893,14 @@
- 			i++;
- 		}
- 		
-+		else if( !strcmp( argv[ i ], "-exposure" ) )
-+		{
-+			f = atof( argv[ i + 1 ] );
-+			lightmapExposure = f;
-+			Sys_Printf( "Lighting exposure set to %f\n", lightmapExposure );
-+			i++;
-+		}
-+		
- 		else if( !strcmp( argv[ i ], "-compensate" ) )
- 		{
- 			f = atof( argv[ i + 1 ] );
 Index: tools/quake3/q3map2/q3map2.h
 ===================================================================
---- tools/quake3/q3map2/q3map2.h	(revision 191)
-+++ tools/quake3/q3map2/q3map2.h	(working copy)
-@@ -543,6 +545,7 @@
+--- tools/quake3/q3map2/q3map2.h.orig	2008-09-06 15:32:14.000000000 +0200
++++ tools/quake3/q3map2/q3map2.h	2008-09-06 15:32:16.000000000 +0200
+@@ -553,6 +553,7 @@
  	qboolean			wolfLight;						/* when true, lights work like wolf q3map  */
  	int					lightmapSize;					/* bsp lightmap width/height */
  	float				lightmapGamma;					/* default lightmap gamma */
@@ -234,7 +214,7 @@
  	float				lightmapCompensate;				/* default lightmap compensate value */
  	char				*bspIdent;						/* 4-letter bsp file prefix */
  	int					bspVersion;						/* bsp version to use */
-@@ -2117,6 +2132,7 @@
+@@ -2139,6 +2140,7 @@
  
  /* ydnar: lightmap gamma/compensation */
  Q_EXTERN float				lightmapGamma Q_ASSIGN( 1.0f );
@@ -242,3 +222,22 @@
  Q_EXTERN float				lightmapCompensate Q_ASSIGN( 1.0f );
  
  /* ydnar: for runtime tweaking of falloff tolerance */
+Index: tools/quake3/q3map2/light.c
+===================================================================
+--- tools/quake3/q3map2/light.c.orig	2008-09-06 15:32:14.000000000 +0200
++++ tools/quake3/q3map2/light.c	2008-09-06 15:32:16.000000000 +0200
+@@ -1893,6 +1893,14 @@
+ 			i++;
+ 		}
+ 		
++		else if( !strcmp( argv[ i ], "-exposure" ) )
++		{
++			f = atof( argv[ i + 1 ] );
++			lightmapExposure = f;
++			Sys_Printf( "Lighting exposure set to %f\n", lightmapExposure );
++			i++;
++		}
++
+ 		else if( !strcmp( argv[ i ], "-compensate" ) )
+ 		{
+ 			f = atof( argv[ i + 1 ] );

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTtrianglecheck.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTtrianglecheck.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-UTtrianglecheck.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,8 +1,8 @@
 Index: tools/quake3/q3map2/light_ydnar.c
 ===================================================================
---- tools/quake3/q3map2/light_ydnar.c	(revision 191)
-+++ tools/quake3/q3map2/light_ydnar.c	(working copy)
-@@ -384,7 +420,7 @@
+--- tools/quake3/q3map2/light_ydnar.c.orig	2008-09-06 15:32:16.000000000 +0200
++++ tools/quake3/q3map2/light_ydnar.c	2008-09-06 15:32:18.000000000 +0200
+@@ -420,7 +420,7 @@
  #define NUDGE			0.5f
  #define BOGUS_NUDGE		-99999.0f
  
@@ -11,7 +11,7 @@
  {
  	int				i, x, y, numClusters, *clusters, pointCluster, *cluster;
  	float			*luxel, *origin, *normal, d, lightmapSampleOffset;
-@@ -392,6 +428,12 @@
+@@ -428,6 +428,12 @@
  	vec3_t			pNormal;
  	vec3_t			vecs[ 3 ];
  	vec3_t			nudged;
@@ -24,7 +24,7 @@
  	float			*nudge;
  	static float	nudges[][ 2 ] =
  					{
-@@ -485,6 +527,51 @@
+@@ -521,6 +527,51 @@
  	/* non axial lightmap projection (explicit xyz) */
  	else
  		VectorCopy( dv->xyz, origin );
@@ -38,7 +38,7 @@
 +	{
 +		for (j=0;j<3;j++)
 +		{
-+			VectorCopy(worldverts[j],cverts[j]);    
++			VectorCopy(worldverts[j],cverts[j]);
 +		}
 +		PlaneFromPoints(hostplane,cverts[0],cverts[1],cverts[2]);
 +
@@ -53,7 +53,7 @@
 +				VectorAdd(temp,hostplane,temp);
 +				PlaneFromPoints(sideplane,cverts[i],cverts[ next ], temp);
 +
-+				//planetest sample point  
++				//planetest sample point
 +				e=DotProduct(origin,sideplane);
 +				e=e-sideplane[3];
 +				if (e>0)
@@ -66,7 +66,7 @@
 +					origin[2]-=sideplane[2]*(e+1);
 +#ifdef DEBUG_27_1
 +					VectorClear(origin);
-+#endif 
++#endif
 +				}
 +			}
 +		}
@@ -76,7 +76,7 @@
  	
  	/* planar surfaces have precalculated lightmap vectors for nudging */
  	if( lm->plane != NULL )
-@@ -516,8 +603,13 @@
+@@ -552,8 +603,13 @@
  	else
  		origin[ lm->axisNum ] += lightmapSampleOffset;
  	
@@ -84,14 +84,14 @@
 +	origintwo[0]+=vecs[2][0];
 +	origintwo[1]+=vecs[2][1];
 +	origintwo[2]+=vecs[2][2];
-+	
++
  	/* get cluster */
 -	pointCluster = ClusterForPointExtFilter( origin, LUXEL_EPSILON, numClusters, clusters );
 +	pointCluster = ClusterForPointExtFilter( origintwo, LUXEL_EPSILON, numClusters, clusters );
  	
  	/* another retarded hack, storing nudge count in luxel[ 1 ] */
  	luxel[ 1 ] = 0.0f;	
-@@ -533,14 +625,14 @@
+@@ -569,14 +625,14 @@
  			for( i = 0; i < 3; i++ )
  			{
  				/* set nudged point*/
@@ -104,12 +104,12 @@
  			pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters ); //% + 0.625 );
 -			if( pointCluster >= 0 )	
 -				VectorCopy( nudged, origin );
-+			//if( pointCluster >= 0 )	
++			//if( pointCluster >= 0 )
 +   			//	VectorCopy( nudged, origin );
  			luxel[ 1 ] += 1.0f;
  		}
  	}
-@@ -550,8 +642,8 @@
+@@ -586,8 +642,8 @@
  	{
  		VectorMA( dv->xyz, lightmapSampleOffset, dv->normal, nudged );
  		pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters );
@@ -120,7 +120,7 @@
  		luxel[ 1 ] += 1.0f;
  	}
  	
-@@ -597,7 +689,7 @@
+@@ -633,7 +689,7 @@
  than the distance between two luxels (thanks jc :)
  */
  
@@ -129,7 +129,7 @@
  {
  	bspDrawVert_t	mid, *dv2[ 3 ];
  	int				max;
-@@ -645,7 +737,7 @@
+@@ -681,7 +737,7 @@
  	
  	/* split the longest edge and map it */
  	LerpDrawVert( dv[ max ], dv[ (max + 1) % 3 ], &mid );
@@ -138,7 +138,7 @@
  	
  	/* push the point up a little bit to account for fp creep (fixme: revisit this) */
  	//%	VectorMA( mid.xyz, 2.0f, mid.normal, mid.xyz );
-@@ -653,12 +745,12 @@
+@@ -689,12 +745,12 @@
  	/* recurse to first triangle */
  	VectorCopy( dv, dv2 );
  	dv2[ max ] = &mid;
@@ -153,7 +153,7 @@
  }
  
  
-@@ -674,6 +766,7 @@
+@@ -710,6 +766,7 @@
  	int				i;
  	vec4_t			plane;
  	vec3_t			*stv, *ttv, stvStatic[ 3 ], ttvStatic[ 3 ];
@@ -161,14 +161,14 @@
  	
  	
  	/* get plane if possible */
-@@ -699,16 +792,20 @@
+@@ -735,16 +792,20 @@
  		ttv = NULL;
  	}
  	
 +	VectorCopy( dv[ 0 ]->xyz, worldverts[ 0 ] );
 +	VectorCopy( dv[ 1 ]->xyz, worldverts[ 1 ] );
 +	VectorCopy( dv[ 2 ]->xyz, worldverts[ 2 ] );
-+	
++
  	/* map the vertexes */
 -	MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv );
 -	MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv );
@@ -186,7 +186,7 @@
  		return qtrue;
  	}
  	
-@@ -730,7 +827,7 @@
+@@ -766,7 +827,7 @@
  			dv2[ 2 ] = dv[ (i + 1) % 3 ];
  			
  			/* map the degenerate triangle */
@@ -195,7 +195,7 @@
  		}
  	}
  	
-@@ -792,8 +889,8 @@
+@@ -828,8 +889,8 @@
  	LerpDrawVert( dv[ max + 2 ], dv[ (max + 3) % 4 ], &mid[ 1 ] );
  	
  	/* map the vertexes */
@@ -206,7 +206,7 @@
  	
  	/* 0 and 2 */
  	if( max == 0 )
-@@ -878,10 +975,10 @@
+@@ -914,10 +975,10 @@
  	}
  	
  	/* map the vertexes */
@@ -221,7 +221,7 @@
  	
  	/* subdivide the quad */
  	MapQuad_r( lm, info, dv, plane, stv, ttv );
-@@ -1173,7 +1270,7 @@
+@@ -1209,7 +1270,7 @@
  					continue;
  				
  				/* map the fake vert */
@@ -230,7 +230,7 @@
  			}
  		}
  	}
-@@ -1963,22 +2062,32 @@
+@@ -2001,22 +2062,32 @@
  					deluxel = SUPER_DELUXEL( x, y );
  					origin = SUPER_ORIGIN( x, y );
  					normal = SUPER_NORMAL( x, y );
@@ -261,16 +261,16 @@
 +					{
 +						/* set contribution count */
 +						lightLuxel[ 3 ] = 1.0f;
-+						
++
 +						/* setup trace */
 +						trace.cluster = *cluster;
 +						VectorCopy( origin, trace.origin );
 +						VectorCopy( normal, trace.normal );
-+						
++
 +						/* get light for this sample */
 +						LightContributionToSample( &trace );
 +						VectorCopy( trace.color, lightLuxel );
-+						
++
 +						/* add to count */
 +						if( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] )
 +							totalLighted++;

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-decomptexcoords.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-decomptexcoords.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-decomptexcoords.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,7 +1,7 @@
 Index: tools/quake3/q3map2/convert_map.c
 ===================================================================
---- tools/quake3/q3map2/convert_map.c	(revision 191)
-+++ tools/quake3/q3map2/convert_map.c	(working copy)
+--- tools/quake3/q3map2/convert_map.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ tools/quake3/q3map2/convert_map.c	2008-09-06 15:32:11.000000000 +0200
 @@ -46,6 +46,105 @@
  #define	SNAP_FLOAT_TO_INT	4
  #define	SNAP_INT_TO_FLOAT	(1.0 / SNAP_FLOAT_TO_INT)
@@ -132,7 +132,7 @@
  		
 +		/* get plane */
 +		buildPlane = &mapplanes[ buildSide->planenum ];
-+		
++
  		/* dummy check */
  		if( buildSide->shaderInfo == NULL || buildSide->winding == NULL )
  			continue;
@@ -202,7 +202,7 @@
 +			else
 +				fprintf(stderr, "degenerate triangle found when solving texMat equations for\n(%f %f %f) (%f %f %f) (%f %f %f)\n( %f %f %f )\n( %f %f %f ) -> ( %f %f )\n( %f %f %f ) -> ( %f %f )\n( %f %f %f ) -> ( %f %f )\n",
 +					buildPlane->normal[0], buildPlane->normal[1], buildPlane->normal[2],
-+					vert[0]->normal[0], vert[0]->normal[1], vert[0]->normal[2], 
++					vert[0]->normal[0], vert[0]->normal[1], vert[0]->normal[2],
 +					texX[0], texX[1], texX[2], texY[0], texY[1], texY[2],
 +					vert[0]->xyz[0], vert[0]->xyz[1], vert[0]->xyz[2], xy1I[0], xy1I[1],
 +					vert[1]->xyz[0], vert[1]->xyz[1], vert[1]->xyz[2], xy1J[0], xy1J[1],
@@ -241,8 +241,8 @@
  
 Index: tools/quake3/q3map2/main.c
 ===================================================================
---- tools/quake3/q3map2/main.c	(revision 191)
-+++ tools/quake3/q3map2/main.c	(working copy)
+--- tools/quake3/q3map2/main.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ tools/quake3/q3map2/main.c	2008-09-06 15:32:11.000000000 +0200
 @@ -541,6 +541,18 @@
  					Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
  			}

Modified: branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-snapplane.diff
===================================================================
--- branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-snapplane.diff	2008-09-06 16:14:34 UTC (rev 4380)
+++ branches/nexuiz-2.0/misc/gtkradiant/singlepatches/q3map2-snapplane.diff	2008-09-06 16:44:32 UTC (rev 4381)
@@ -1,7 +1,7 @@
 Index: tools/quake3/q3map2/model.c
 ===================================================================
---- tools/quake3/q3map2/model.c	(revision 193)
-+++ tools/quake3/q3map2/model.c	(working copy)
+--- tools/quake3/q3map2/model.c.orig	2008-09-06 15:32:05.000000000 +0200
++++ tools/quake3/q3map2/model.c	2008-09-06 15:32:12.000000000 +0200
 @@ -222,6 +222,8 @@
  	byte				*color;
  	picoIndex_t			*indexes;
@@ -198,7 +198,7 @@
 +						buildBrush->sides[ 2 ].planenum = FindFloatPlane( pb, pb[ 3 ], 2, &points[ 0 ] ); // pb contains points[0] and points[1]
 +						buildBrush->sides[ 3 ].planenum = FindFloatPlane( pc, pc[ 3 ], 2, &points[ 2 ] ); // pc contains points[2] and points[0] (copied to points[3]
 +						buildBrush->sides[ 4 ].planenum = FindFloatPlane( reverse, reverse[ 3 ], 3, backs );
- 					}
++					}
 +					else
 +					{
 +						free(buildBrush);
@@ -216,7 +216,7 @@
 +						buildBrush->next = entities[ mapEntityNum ].brushes;
 +						entities[ mapEntityNum ].brushes = buildBrush;
 +						entities[ mapEntityNum ].numBrushes++;
-+					}
+ 					}
 +					else
 +						free( buildBrush );
  				}
@@ -224,8 +224,8 @@
  		}
 Index: tools/quake3/q3map2/map.c
 ===================================================================
---- tools/quake3/q3map2/map.c	(revision 193)
-+++ tools/quake3/q3map2/map.c	(working copy)
+--- tools/quake3/q3map2/map.c.orig	2008-09-06 15:32:04.000000000 +0200
++++ tools/quake3/q3map2/map.c	2008-09-06 15:32:12.000000000 +0200
 @@ -184,7 +184,7 @@
  snaps a plane to normal/distance epsilons
  */
@@ -262,13 +262,13 @@
  	int		i, j, hash, h;
  	plane_t	*p;
  	vec_t	d;
+-	
 +	vec3_t centerofweight;
 +
 +	VectorClear(centerofweight);
 +	for(i = 0; i < numPoints; ++i)
 +		VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
  	
--	
  	/* hash the plane */
 -	SnapPlane( normal, &dist );
 +	SnapPlane( normal, &dist, centerofweight );
@@ -285,7 +285,7 @@
 +	VectorClear(centerofweight);
 +	for(i = 0; i < numPoints; ++i)
 +		VectorMA(centerofweight, 1.0 / numPoints, points[i], centerofweight);
-+	
++
 +	SnapPlane( normal, &dist, centerofweight );
  	for( i = 0, p = mapplanes; i < nummapplanes; i++, p++ )
  	{




More information about the nexuiz-commits mailing list