r3906 - in trunk/data/qcsrc: client common server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jul 25 07:59:42 EDT 2008


Author: div0
Date: 2008-07-25 07:59:41 -0400 (Fri, 25 Jul 2008)
New Revision: 3906

Modified:
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/View.qc
   trunk/data/qcsrc/client/sbar.qc
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/common/util.qh
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/scores.qc
Log:
allow specifying sbar fields as +ctf,kh/score -ctf,kh/kills


Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2008-07-25 07:02:49 UTC (rev 3905)
+++ trunk/data/qcsrc/client/Main.qc	2008-07-25 11:59:41 UTC (rev 3906)
@@ -125,7 +125,8 @@
 {
 	float argc;
 	// Tokenize String
-	argc = tokenize(strMessage);
+	//argc = tokenize(strMessage);
+	argc = tokenizebyseparator(strMessage, " ");
 	
 	// Acquire Command
 	local string strCmd;
@@ -229,9 +230,11 @@
 	}
 }
 
+void Gamemode_Init();
 void Ent_ReadScoresInfo()
 {
 	float i;
+	gametype = ReadByte();
 	for(i = 0; i < MAX_SCORE; ++i)
 	{
 		scores_label[i] = strzone(ReadString());
@@ -243,6 +246,7 @@
 		teamscores_flags[i] = ReadByte();
 	}
 	Sbar_InitScores();
+	Gamemode_Init();
 }
 
 void Ent_ReadPlayerScore(float isNew)
@@ -369,7 +373,6 @@
 	local float file;
 	local vector mi_min, mi_max;
 
-	gametype = cvar("gametype");
 	if(gametype == GAME_ONSLAUGHT) {
 		if(!strcasecmp(substring(mapname, 0, 5), "maps/"))
 			minimapname = substring(mapname, 5, 999);

Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc	2008-07-25 07:02:49 UTC (rev 3905)
+++ trunk/data/qcsrc/client/View.qc	2008-07-25 11:59:41 UTC (rev 3906)
@@ -10,9 +10,6 @@
 	// watch for gametype changes here...
 	// in ParseStuffCMD the cmd isn't executed yet :/
 	// might even be better to add the gametype to TE_CSQC_INIT...?
-	if(gametype != cvar("gametype"))
-		Gamemode_Init();
-	
 	if(!postinit)
 		PostInit();
 	

Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc	2008-07-25 07:02:49 UTC (rev 3905)
+++ trunk/data/qcsrc/client/sbar.qc	2008-07-25 11:59:41 UTC (rev 3906)
@@ -304,6 +304,8 @@
 
 string Sbar_DefaultColumnLayout()
 {
+	return "ping name | +kh,ctf/caps -ctf,kh/kills -ctf,kh/deaths score";
+	/*
 	switch(gametype)
 	{
 		case GAME_CTF: return "ping name | caps score";
@@ -311,20 +313,21 @@
 		default: return "ping name | score";
 			// TODO: add other gametypes
 	}
+	*/
 }
 
 void Cmd_Sbar_SetFields(float argc)
 {
-	float i, j;
-	string str;
+	float i, j, slash;
+	string str, pattern, subpattern;
 	float digit;
 
 	// TODO: re enable with gametype dependant cvars?
 	if(argc < 2) // no arguments provided
-		argc = tokenize(strcat("x ", cvar_string("sbar_columns")));
+		argc = tokenizebyseparator(strcat("x ", cvar_string("sbar_columns")), " ");
 
-	if(argc == 2 && argv(1) == "default")
-		argc = tokenize(strcat("x ", Sbar_DefaultColumnLayout()));
+	if(argc < 2 || (argc == 2 && argv(1) == "default"))
+		argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
 	
 	argc = min(MAX_SBAR_FIELDS, argc);
 	sbar_num_fields = 0;
@@ -332,17 +335,39 @@
 	drawfont = sbar_font;
 	digit = stringwidth("0123456789", FALSE) / 10;
 
+	subpattern = strcat(",", GametypeNameFromType(gametype), ",");
+
 	argc = min(argc-1, MAX_SBAR_FIELDS-1);
 	for(i = 0; i < argc; ++i)
 	{
 		str = argv(i+1);
+
+		slash = strstrofs(str, "/", 0);
+		if(slash >= 0)
+		{
+			pattern = substring(str, 0, slash);
+			str = substring(str, slash + 1, strlen(str) - (slash + 1));
+
+			if(substring(pattern, 0, 1) == "-")
+			{
+				pattern = substring(pattern, 1, strlen(pattern) - 1);
+				if(strstrofs(strcat(",", pattern, ","), subpattern, 0) >= 0)
+					continue;
+			}
+			else
+			{
+				if(substring(pattern, 0, 1) == "+")
+					pattern = substring(pattern, 1, strlen(pattern) - 1);
+				if(strstrofs(strcat(",", pattern, ","), subpattern, 0) < 0)
+					continue;
+			}
+		}
+
 		strunzone(sbar_title[sbar_num_fields]);
 		sbar_title[sbar_num_fields] = strzone(str);
 		sbar_size[sbar_num_fields] = stringwidth(str, FALSE);
 		str = strtolower(str);
 
-		
-
 		if(str == "ping") {
 			sbar_field[sbar_num_fields] = SP_PING;
 		} else if(str == "name" || str == "nick") {

Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2008-07-25 07:02:49 UTC (rev 3905)
+++ trunk/data/qcsrc/common/util.qc	2008-07-25 11:59:41 UTC (rev 3906)
@@ -409,3 +409,18 @@
 		fputs(fh, strcat(bufstr_get(buf, i), "\n"));
 	fclose(fh);
 }
+
+string GametypeNameFromType(float g)
+{
+	if      (g == GAME_DEATHMATCH) return "dm";
+	else if (g == GAME_TEAM_DEATHMATCH) return "tdm";
+	else if (g == GAME_DOMINATION) return "dom";
+	else if (g == GAME_CTF) return "ctf";
+	else if (g == GAME_RUNEMATCH) return "rune";
+	else if (g == GAME_LMS) return "lms";
+	else if (g == GAME_KEYHUNT) return "kh";
+	else if (g == GAME_ONSLAUGHT) return "ons";
+	else if (g == GAME_ASSAULT) return "as";
+	return "dm";
+}
+

Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh	2008-07-25 07:02:49 UTC (rev 3905)
+++ trunk/data/qcsrc/common/util.qh	2008-07-25 11:59:41 UTC (rev 3906)
@@ -55,3 +55,5 @@
 #ifndef MENUQC
 float mod(float a, float b) { return a - (floor(a / b) * b); }   
 #endif
+
+string GametypeNameFromType(float g);

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2008-07-25 07:02:49 UTC (rev 3905)
+++ trunk/data/qcsrc/server/g_world.qc	2008-07-25 11:59:41 UTC (rev 3906)
@@ -382,25 +382,7 @@
 
 string GetGametype()
 {
-	if (game == GAME_DEATHMATCH)
-		return "dm";
-	else if (game == GAME_TEAM_DEATHMATCH)
-		return "tdm";
-	else if (game == GAME_DOMINATION)
-		return "dom";
-	else if (game == GAME_CTF)
-		return "ctf";
-	else if (game == GAME_RUNEMATCH)
-		return "rune";
-	else if (game == GAME_LMS)
-		return "lms";
-	else if (game == GAME_KEYHUNT)
-		return "kh";
-	else if (game == GAME_ONSLAUGHT)
-		return "ons";
-	else if (game == GAME_ASSAULT)
-		return "as";
-	return "dm";
+	return GametypeNameFromType(game);
 }
 
 float IsSameGametype(string mapcfgname)

Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc	2008-07-25 07:02:49 UTC (rev 3905)
+++ trunk/data/qcsrc/server/scores.qc	2008-07-25 11:59:41 UTC (rev 3906)
@@ -114,6 +114,7 @@
 {
 	WriteByte(MSG_ENTITY, ENT_CLIENT_SCORES_INFO);
 	float i;
+	WriteByte(MSG_ENTITY, game);
 	for(i = 0; i < MAX_SCORE; ++i)
 	{
 		WriteString(MSG_ENTITY, scores_label[i]);




More information about the nexuiz-commits mailing list