r3215 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Jan 21 15:19:09 EST 2008


Author: div0
Date: 2008-01-21 15:19:06 -0500 (Mon, 21 Jan 2008)
New Revision: 3215

Modified:
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/g_world.qc
Log:
Better handle running out of spawns:
- when you have no more spawns, you can't spawn (but will spawn once you have one)
- when a team no longer has any spawns, it loses


Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2008-01-21 19:52:40 UTC (rev 3214)
+++ trunk/data/qcsrc/server/cl_client.qc	2008-01-21 20:19:06 UTC (rev 3215)
@@ -181,7 +181,7 @@
 		if(cvar("spawn_debug"))
 			GotoNextMap();
 		else
-			error ("PutClientInServer: no start points on level");
+			return world;
 	}
 
 	return spot;
@@ -312,6 +312,8 @@
 {
 	entity	spot;
 	spot = SelectSpawnPoint (TRUE);
+	if(!spot)
+		error("No spawnpoints for observers?!?\n");
 	RemoveGrapplingHook(self); // Wazat's Grappling Hook
 
 	if(clienttype(self) == CLIENTTYPE_REAL)
@@ -495,6 +497,11 @@
 		entity	spot;
 
 		spot = SelectSpawnPoint (FALSE);
+		if(!spot)
+		{
+			centerprint(self, "Sorry, no spawnpoints available!\nHope your team can fix it...");
+			return; // spawn failed
+		}
 
 		RemoveGrapplingHook(self); // Wazat's Grappling Hook
 
@@ -986,6 +993,7 @@
 void respawn(void)
 {
 	CopyBody(1);
+	self.effects |= EF_NODRAW; // prevent another CopyBody
 	PutClientInServer();
 }
 
@@ -1405,7 +1413,10 @@
 			else if (self.deadflag == DEAD_RESPAWNING)
 			{
 				if(time > self.death_time)
+				{
+					self.death_time = time + 1; // only retry once a second
 					respawn();
+				}
 			}
 			ShowRespawnCountdown();
 			return;

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2008-01-21 19:52:40 UTC (rev 3214)
+++ trunk/data/qcsrc/server/g_world.qc	2008-01-21 20:19:06 UTC (rev 3215)
@@ -1056,6 +1056,15 @@
 			head.winning = 1;
 }
 
+// clear frags for all players but the team given (when they ran out of spawnpoints)
+void(.float field, float value) ClearFragsForEveryoneBut =
+{
+	entity head;
+	FOR_EACH_PLAYER(head)
+		if(head.field != value)
+			head.frags = max(head.frags, 0);
+}
+
 // clear the .winning flags
 void(void) ClearWinners =
 {
@@ -1520,6 +1529,73 @@
 	cvar_set("g_maplist", result);
 }
 
+float WinningCondition_RanOutOfSpawns()
+{
+	entity head;
+
+	if(!teams_matter)
+		return WINNING_NO;
+
+	team1_score = team2_score = team3_score = team4_score = 0;
+
+	FOR_EACH_PLAYER(head) if(head.deadflag == DEAD_NO)
+	{
+		if(head.team == COLOR_TEAM1)
+			team1_score = 1;
+		else if(head.team == COLOR_TEAM2)
+			team2_score = 1;
+		else if(head.team == COLOR_TEAM3)
+			team3_score = 1;
+		else if(head.team == COLOR_TEAM4)
+			team4_score = 1;
+	}
+
+	for(head = world; (head = find(head, classname, "info_player_deathmatch")) != world; )
+	{
+		if(head.team == COLOR_TEAM1)
+			team1_score = 1;
+		else if(head.team == COLOR_TEAM2)
+			team2_score = 1;
+		else if(head.team == COLOR_TEAM3)
+			team3_score = 1;
+		else if(head.team == COLOR_TEAM4)
+			team4_score = 1;
+	}
+
+	ClearWinners();
+	if(team1_score + team2_score + team3_score + team4_score == 0)
+	{
+		checkrules_equality = TRUE;
+		return WINNING_YES;
+	}
+	else if(team1_score + team2_score + team3_score + team4_score == 1)
+	{
+		if(team1_score)
+		{
+			AddWinners(team, COLOR_TEAM1);
+			ClearFragsForEveryoneBut(team, COLOR_TEAM1);
+		}
+		if(team2_score)
+		{
+			AddWinners(team, COLOR_TEAM2);
+			ClearFragsForEveryoneBut(team, COLOR_TEAM1);
+		}
+		if(team3_score)
+		{
+			AddWinners(team, COLOR_TEAM3);
+			ClearFragsForEveryoneBut(team, COLOR_TEAM1);
+		}
+		if(team4_score)
+		{
+			AddWinners(team, COLOR_TEAM4);
+			ClearFragsForEveryoneBut(team, COLOR_TEAM1);
+		}
+		return WINNING_YES;
+	}
+	else
+		return WINNING_NO;
+}
+
 /*
 ============
 CheckRules_World
@@ -1588,9 +1664,12 @@
 		sound(world, CHAN_AUTO, "announcer/robotic/1minuteremains.wav", 1, ATTN_NONE);
 	}
 
-	status = WINNING_NO;
-	if(g_assault)
+	status = WinningCondition_RanOutOfSpawns();
+	if(status == WINNING_YES)
 	{
+	}
+	else if(g_assault)
+	{
 		status = WinningCondition_Assault();
 	}
 	else if(g_lms)




More information about the nexuiz-commits mailing list