[nexuiz-commits] r7607 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Sep 3 10:17:49 EDT 2009


Author: div0
Date: 2009-09-03 10:17:49 -0400 (Thu, 03 Sep 2009)
New Revision: 7607

Modified:
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/ctf.qc
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/havocbot_ctf.qc
   trunk/data/qcsrc/server/race.qc
Log:
- do not crash on "disconnect" or "quit" in CTF
- improve base finding in CTF, make it actually work


Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2009-09-03 13:39:00 UTC (rev 7606)
+++ trunk/data/qcsrc/server/bots.qc	2009-09-03 14:17:49 UTC (rev 7607)
@@ -1161,17 +1161,11 @@
 	return cwp + cwb;
 };
 
-void waypoint_spawnforitem(entity e)
+void waypoint_spawnforitem_force(entity e, vector org)
 {
 	local entity w;
 	local vector org;
 
-	if(!bot_waypoints_for_items)
-		return;
-
-	// Center of entity
-	org = (e.absmax + e.absmin) * 0.5;
-
 	// Fix the waypoint altitude if necessary
 	traceline(org, org + '0 0 -65535', TRUE, e);
 	if(
@@ -1180,10 +1174,6 @@
 	)
 		org_z = trace_endpos_z + PL_MAX_z - PL_MIN_z;
 
-	// TODO: Cleaner solution
-	if(e.classname!="item_flag_team")
-		e.nearestwaypointtimeout = time + 1000000000;
-
 	// don't spawn an item spawnfunc_waypoint if it already exists
 	w = findchain(classname, "waypoint");
 	while (w)
@@ -1207,6 +1197,14 @@
 		w = w.chain;
 	}
 	e.nearestwaypoint = waypoint_spawn(org, org, WAYPOINTFLAG_GENERATED | WAYPOINTFLAG_ITEM);
+}
+
+void waypoint_spawnforitem(entity e)
+{
+	if(!bot_waypoints_for_items)
+		return;
+
+	waypoint_spawnforitem_force(e, e.origin);
 };
 
 void waypoint_spawnforteleporter(entity e, vector destination, float timetaken)

Modified: trunk/data/qcsrc/server/ctf.qc
===================================================================
--- trunk/data/qcsrc/server/ctf.qc	2009-09-03 13:39:00 UTC (rev 7606)
+++ trunk/data/qcsrc/server/ctf.qc	2009-09-03 14:17:49 UTC (rev 7607)
@@ -1,6 +1,7 @@
 #define FLAG_MIN (PL_MIN + '0 0 -13')
 #define FLAG_MAX (PL_MAX + '0 0 -13')
 
+.entity basewaypoint;
 .entity sprite;
 entity ctf_worldflaglist; // CTF flags in the map
 .entity ctf_worldflagnext;
@@ -822,7 +823,9 @@
 	// From Spidflisk
 	item_flag_postspawn();
 
-	waypoint_spawnforitem(self);
+	waypoint_spawnforitem_force(self, self.origin);
+	self.nearestwaypointtimeout = 0; // activate waypointing again
+	self.basewaypoint = self.nearestwaypoint;
 
 	WaypointSprite_SpawnFixed("redbase", self.origin + '0 0 37', self, sprite);
 	WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM1 - 1, FALSE));
@@ -927,7 +930,9 @@
 	// From Spidflisk
 	item_flag_postspawn();
 
-	waypoint_spawnforitem(self);
+	waypoint_spawnforitem_force(self, self.origin);
+	self.nearestwaypointtimeout = 0; // activate waypointing again
+	self.basewaypoint = self.nearestwaypoint;
 
 	WaypointSprite_SpawnFixed("bluebase", self.origin + '0 0 37', self, sprite);
 	WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_FLAG, colormapPaletteColor(COLOR_TEAM2 - 1, FALSE));

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2009-09-03 13:39:00 UTC (rev 7606)
+++ trunk/data/qcsrc/server/g_world.qc	2009-09-03 14:17:49 UTC (rev 7607)
@@ -2577,6 +2577,11 @@
 
 void SV_Shutdown()
 {
+	if(gameover > 1) // shutting down already?
+		return;
+
+	gameover = 2; // 2 = server shutting down
+
 	if(world_initialized > 0)
 	{
 		world_initialized = 0;

Modified: trunk/data/qcsrc/server/havocbot_ctf.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot_ctf.qc	2009-09-03 13:39:00 UTC (rev 7606)
+++ trunk/data/qcsrc/server/havocbot_ctf.qc	2009-09-03 14:17:49 UTC (rev 7607)
@@ -23,6 +23,7 @@
 .float havocbot_cantfindflag;
 .float havocbot_role_timeout;
 .entity ctf_worldflagnext;
+.entity basewaypoint;
 
 vector havocbot_ctf_middlepoint;
 float havocbot_ctf_middlepoint_radius;
@@ -90,12 +91,6 @@
 
 void havocbot_goalrating_ctf_ourbase(float ratingscale)
 {
-	if not(bot_waypoints_for_items)
-	{
-		havocbot_goalrating_ctf_ourflag(ratingscale);
-		return;
-	}
-
 	local entity head;
 	head = ctf_worldflaglist;
 	while (head)
@@ -107,17 +102,7 @@
 	if not(head)
 		return;
 
-	// dropped_origin is set by ctf code whenever the flag is picked up
-	head = findradius(head.dropped_origin, 100);
-	while(head)
-	{
-		if(head.classname=="waypoint")
-		{
-			navigation_routerating(head, ratingscale, 10000);
-			return;
-		}
-		head=head.chain;
-	}
+	navigation_routerating(head.basewaypoint, ratingscale, 10000);
 };
 
 void havocbot_goalrating_ctf_enemyflag(float ratingscale)
@@ -149,16 +134,7 @@
 	if not(head)
 		return;
 
-	head = findradius(head.dropped_origin, 100);
-	while(head)
-	{
-		if(head.classname=="waypoint")
-		{
-			navigation_routerating(head, ratingscale, 10000);
-			return;
-		}
-		head=head.chain;
-	}
+	navigation_routerating(head.basewaypoint, ratingscale, 10000);
 };
 
 void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)

Modified: trunk/data/qcsrc/server/race.qc
===================================================================
--- trunk/data/qcsrc/server/race.qc	2009-09-03 13:39:00 UTC (rev 7606)
+++ trunk/data/qcsrc/server/race.qc	2009-09-03 14:17:49 UTC (rev 7607)
@@ -512,8 +512,7 @@
 
 	o = (self.absmin + self.absmax) * 0.5;
 	tracebox(o, PL_MIN, PL_MAX, o - '0 0 1' * (o_z - self.absmin_z), MOVE_NORMAL, self);
-	self.nearestwaypoint = waypoint_spawn(trace_endpos, trace_endpos, WAYPOINTFLAG_GENERATED);
-	self.nearestwaypointtimeout = time + 1000000000;
+	waypoint_spawnforitem_force(self, trace_endpos);
 
 	if(!self.message)
 		self.message = "went backwards";



More information about the nexuiz-commits mailing list