r3911 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jul 25 11:47:40 EDT 2008


Author: div0
Date: 2008-07-25 11:47:40 -0400 (Fri, 25 Jul 2008)
New Revision: 3911

Modified:
   trunk/data/qcsrc/server/scores.qc
   trunk/data/qcsrc/server/scores.qh
   trunk/data/qcsrc/server/teamplay.qc
Log:
add generic scores for all other game modes (hope it somewhat works)


Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc	2008-07-25 15:36:02 UTC (rev 3910)
+++ trunk/data/qcsrc/server/scores.qc	2008-07-25 15:47:40 UTC (rev 3911)
@@ -10,7 +10,6 @@
 float teamscores_entities_count;
 var .float scores_primary;
 var .float teamscores_primary;
-float scores_initialized;
 
 void Net_LinkEntity(entity e)
 {
@@ -92,7 +91,11 @@
 	vector result;
 	float i;
 	for(i = 0; i < MAX_TEAMSCORE; ++i)
-		result = ScoreField_Compare(t1, t2, teamscores[i], teamscores_flags[i], result);
+	{
+		var .float f;
+		f = teamscores[i];
+		result = ScoreField_Compare(t1, t2, f, teamscores_flags[i], result);
+	}
 	return result_x;
 }
 
@@ -253,8 +256,12 @@
 
 	vector result;
 	float i;
-	for(i = 0; i < MAX_TEAMSCORE; ++i)
-		result = ScoreField_Compare(t1, t2, scores[i], scores_flags[i], result);
+	for(i = 0; i < MAX_SCORE; ++i)
+	{
+		var .float f;
+		f = scores[i];
+		result = ScoreField_Compare(t1, t2, f, scores_flags[i], result);
+	}
 	return result_x;
 }
 

Modified: trunk/data/qcsrc/server/scores.qh
===================================================================
--- trunk/data/qcsrc/server/scores.qh	2008-07-25 15:36:02 UTC (rev 3910)
+++ trunk/data/qcsrc/server/scores.qh	2008-07-25 15:47:40 UTC (rev 3911)
@@ -1,3 +1,5 @@
+float scores_initialized; // 1 when scores labels/rules have been set
+
 /**
  * Attaches a PlayerScore entity to a player. Use that in ClientConnect.
  * Remember to detach it in ClientDisconnect!

Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc	2008-07-25 15:36:02 UTC (rev 3910)
+++ trunk/data/qcsrc/server/teamplay.qc	2008-07-25 15:47:40 UTC (rev 3911)
@@ -318,6 +318,22 @@
 		kh_init();
 	else if (game == GAME_ONSLAUGHT)
 		entcs_init();
+
+	if(!scores_initialized)
+	{
+		if(teamplay)
+		{
+			CheckAllowedTeams(world);
+			ScoreInfo_Init((c1>=0) + (c2>=0) + (c3>=0) + (c4>=0)); // NOTE this assumes that if team 2 is allowed, 1 is too, and if 3 is, 2 is, and if 4 is, 3 is!
+		}
+		else
+			ScoreInfo_Init(0); // NOTE this assumes that if team 2 is allowed, 1 is too, and if 3 is, 2 is, and if 4 is, 3 is!
+		ScoreInfo_SetLabel_TeamScore  (ST_SCORE,        "score",     SFL_SORT_PRIO_PRIMARY);
+		ScoreInfo_SetLabel_PlayerScore(SP_KILLS,        "kills",     0);
+		ScoreInfo_SetLabel_PlayerScore(SP_DEATHS,       "deaths",    0);
+		ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES,     "suicides",  SFL_DECREASING);
+		ScoreInfo_SetLabel_PlayerScore(SP_SCORE,        "score",     SFL_SORT_PRIO_PRIMARY);
+	}
 }
 
 string GetClientVersionMessage(float v) {
@@ -632,22 +648,25 @@
 		head = find(head, classname, teament_name);
 	}
 
-	if(cvar("bot_vs_human") > 0)
+	if(for_whom)
 	{
-		// bots are all blue
-		if(clienttype(for_whom) == CLIENTTYPE_BOT)
-			c1 = c3 = c4 = -1;
-		else
-			c2 = -1;
+		if(cvar("bot_vs_human") > 0)
+		{
+			// bots are all blue
+			if(clienttype(for_whom) == CLIENTTYPE_BOT)
+				c1 = c3 = c4 = -1;
+			else
+				c2 = -1;
+		}
+		else if(cvar("bot_vs_human") < 0)
+		{
+			// bots are all red
+			if(clienttype(for_whom) == CLIENTTYPE_BOT)
+				c2 = c3 = c4 = -1;
+			else
+				c1 = -1;
+		}
 	}
-	else if(cvar("bot_vs_human") < 0)
-	{
-		// bots are all red
-		if(clienttype(for_whom) == CLIENTTYPE_BOT)
-			c2 = c3 = c4 = -1;
-		else
-			c1 = -1;
-	}
 }
 
 float PlayerValue(entity p)




More information about the nexuiz-commits mailing list