From: Mircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Date: Mon, 31 Jan 2011 22:38:27 +0000 (+0200)
Subject: Add a "teamspawns" and "noteamspawns" feature to gametypefilter. I believe this is... 
X-Git-Tag: xonotic-v0.5.0~311^2~33^2
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=33aab1d52493ed5d1ec6068cec3e7dcb88a831ac;p=xonotic%2Fxonotic-data.pk3dir.git

Add a "teamspawns" and "noteamspawns" feature to gametypefilter. I believe this is useful for maps that filter entities when team spawns are used. It can avoid adding each gametype manually in entities, and updating maps if a gametype is changed or added in Xonotic. I know about the "teams" and "noteams" switch, but these ignore team games that don't use team spawns and therefore a red / blue base (like TDM or DOM).
---

diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc
index 7b90fcda3..c719985d0 100644
--- a/qcsrc/client/scoreboard.qc
+++ b/qcsrc/client/scoreboard.qc
@@ -356,7 +356,7 @@ void Cmd_HUD_SetFields(float argc)
 			pattern = substring(str, 0, slash);
 			str = substring(str, slash + 1, strlen(str) - (slash + 1));
 
-			if not(isGametypeInFilter(gametype, teamplay, pattern))
+			if not(isGametypeInFilter(gametype, teamplay, FALSE, pattern))
 				continue;
 		}
 
diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc
index 5990f1c9d..fc86c3a84 100644
--- a/qcsrc/common/util.qc
+++ b/qcsrc/common/util.qc
@@ -1367,18 +1367,22 @@ string textShortenToLength(string theText, float maxWidth, textLengthUpToLength_
 		return strcat(substring(theText, 0, textLengthUpToLength(theText, maxWidth - tw("..."), tw)), "...");
 }
 
-float isGametypeInFilter(float gt, float tp, string pattern)
+float isGametypeInFilter(float gt, float tp, float ts, string pattern)
 {
-	string subpattern, subpattern2, subpattern3;
+	string subpattern, subpattern2, subpattern3, subpattern4;
 	subpattern = strcat(",", GametypeNameFromType(gt), ",");
 	if(tp)
 		subpattern2 = ",teams,";
 	else
 		subpattern2 = ",noteams,";
+	if(ts)
+		subpattern3 = ",teamspawns,";
+	else
+		subpattern3 = ",noteamspawns,";
 	if(gt == GAME_RACE || gt == GAME_CTS)
-		subpattern3 = ",race,";
+		subpattern4 = ",race,";
 	else
-		subpattern3 = string_null;
+		subpattern4 = string_null;
 
 	if(substring(pattern, 0, 1) == "-")
 	{
@@ -1387,7 +1391,9 @@ float isGametypeInFilter(float gt, float tp, string pattern)
 			return 0;
 		if(strstrofs(strcat(",", pattern, ","), subpattern2, 0) >= 0)
 			return 0;
-		if(subpattern3 && strstrofs(strcat(",", pattern, ","), subpattern3, 0) >= 0)
+		if(strstrofs(strcat(",", pattern, ","), subpattern3, 0) >= 0)
+			return 0;
+		if(subpattern4 && strstrofs(strcat(",", pattern, ","), subpattern4, 0) >= 0)
 			return 0;
 	}
 	else
@@ -1396,7 +1402,8 @@ float isGametypeInFilter(float gt, float tp, string pattern)
 			pattern = substring(pattern, 1, strlen(pattern) - 1);
 		if(strstrofs(strcat(",", pattern, ","), subpattern, 0) < 0)
 		if(strstrofs(strcat(",", pattern, ","), subpattern2, 0) < 0)
-		if((!subpattern3) || strstrofs(strcat(",", pattern, ","), subpattern3, 0) < 0)
+		if(strstrofs(strcat(",", pattern, ","), subpattern3, 0) < 0)
+		if((!subpattern4) || strstrofs(strcat(",", pattern, ","), subpattern4, 0) < 0)
 			return 0;
 	}
 	return 1;
diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh
index 56cba34cc..a15855753 100644
--- a/qcsrc/common/util.qh
+++ b/qcsrc/common/util.qh
@@ -142,7 +142,7 @@ string getWrappedLine_remaining;
 string getWrappedLine(float w, vector size, textLengthUpToWidth_widthFunction_t tw);
 string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw);
 
-float isGametypeInFilter(float gt, float tp, string pattern);
+float isGametypeInFilter(float gt, float tp, float ts, string pattern);
 
 typedef void(float i1, float i2, entity pass) swapfunc_t; // is only ever called for i1 < i2
 typedef float(float i1, float i2, entity pass) comparefunc_t; // <0 for <, ==0 for ==, >0 for > (like strcmp)
diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc
index aebea7523..a40e8144d 100644
--- a/qcsrc/server/sv_main.qc
+++ b/qcsrc/server/sv_main.qc
@@ -235,7 +235,7 @@ void StartFrame (void)
 void SV_OnEntityPreSpawnFunction()
 {
 	if(self.gametypefilter != "")
-	if not(isGametypeInFilter(game, teams_matter, self.gametypefilter))
+	if not(isGametypeInFilter(game, teams_matter, have_team_spawns, self.gametypefilter))
 	{
 		remove(self);
 		return;