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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Aug 1 12:21:25 EDT 2008


Author: div0
Date: 2008-08-01 12:21:23 -0400 (Fri, 01 Aug 2008)
New Revision: 3997

Modified:
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/main.qh
   trunk/data/qcsrc/client/sbar.qc
   trunk/data/qcsrc/common/constants.qh
   trunk/data/qcsrc/server/sv_main.qc
Log:
new packet loss column ("pl")


Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2008-08-01 13:14:37 UTC (rev 3996)
+++ trunk/data/qcsrc/client/Main.qc	2008-08-01 16:21:23 UTC (rev 3997)
@@ -55,6 +55,7 @@
 	menu_show = menu_show_error;
 	menu_action = menu_sub_null;
 	using_gps = false;
+	maxclients = 255; // we later get the real maxclients to speed up stuff
 	//ctf_temp_1 = "";
 	// localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used
 	//registercmd("ctf_menu");
@@ -95,7 +96,6 @@
 	remove(teams);
 	remove(players);
 	db_close(configdb);
-	buf_del(databuf);
 }
 
 .float has_team;
@@ -180,12 +180,6 @@
 	float i;
 
 	print(strcat("PostInit\n    maxclients = ", ftos(maxclients), "\n"));
-	databuf = buf_create();
-	for(i = 0; i < maxclients; ++i)
-	{
-		bufstr_set(databuf, DATABUF_PING + i, "N/A");
-	}
-	
 	localcmd(strcat("\nsbar_columns_set ", cvar_string("sbar_columns"), ";\n"));
 
 	entity playerchecker;
@@ -522,16 +516,6 @@
 	CSQC_CheckRevision();
 }
 
-void Net_ReadPings()
-{
-	float plnum, ping;
-	for(plnum = ReadByte(); plnum != 0; plnum = ReadByte())
-	{
-		ping = ReadShort();
-		bufstr_set(databuf, DATABUF_PING + plnum-1, ftos(ping));
-	}
-}
-
 string Net_ReadPicture()
 {
 	string img;
@@ -580,10 +564,6 @@
 			Net_ReadInit();
 			bHandled = true;
 			break;
-		case TE_CSQC_PING:
-			Net_ReadPings();
-			bHandled = true;
-			break;
 		case TE_CSQC_MAPVOTE:
 			Net_Mapvote();
 			bHandled = true;

Modified: trunk/data/qcsrc/client/main.qh
===================================================================
--- trunk/data/qcsrc/client/main.qh	2008-08-01 13:14:37 UTC (rev 3996)
+++ trunk/data/qcsrc/client/main.qh	2008-08-01 16:21:23 UTC (rev 3997)
@@ -73,6 +73,7 @@
 #define SP_NAME -3
 #define SP_KDRATIO -4
 #define SP_CLRATIO -5
+#define SP_PL -6
 
 #define SP_SEPARATOR -100
 

Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc	2008-08-01 13:14:37 UTC (rev 3996)
+++ trunk/data/qcsrc/client/sbar.qc	2008-08-01 16:21:23 UTC (rev 3997)
@@ -302,7 +302,7 @@
 
 string Sbar_DefaultColumnLayout()
 {
-	return "ping name | -ctf,kh/kills -ctf,kh/deaths +lms/lives +lms/rank +kh,ctf/caps +kh/pushes +kh/destroyed -lms/score";
+	return "ping pl name | -ctf,kh/kills -ctf,kh/deaths +lms/lives +lms/rank +kh,ctf/caps +kh/pushes +kh/destroyed -lms/score";
 }
 
 void Cmd_Sbar_SetFields(float argc)
@@ -384,6 +384,8 @@
 
 		if(str == "ping") {
 			sbar_field[sbar_num_fields] = SP_PING;
+		} else if(str == "pl") {
+			sbar_field[sbar_num_fields] = SP_PL;
 		} else if(str == "name" || str == "nick") {
 			sbar_field[sbar_num_fields] = SP_NAME;
 			sbar_size[sbar_num_fields] = MIN_NAMELEN; // minimum size? any use?
@@ -493,14 +495,24 @@
 	switch(field)
 	{
 		case SP_PING:
-			str = bufstr_get(databuf, DATABUF_PING + pl.sv_entnum);
+			if not(pl.gotscores)
+				return "N/A";
+			str = getplayerkey(pl.sv_entnum, "ping");
 			tmp = max(0, min(220, stof(str)-80)) / 220;
 			sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;
 			return str;
 		
+		case SP_PL:
+			if not(pl.gotscores)
+				return "N/A";
+			str = getplayerkey(pl.sv_entnum, "pl");
+			if(str == "0")
+				return "";
+			tmp = bound(0, stof(str), 20) / 20; // 20% is REALLY BAD pl
+			sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;
+			return str;
+		
 		case SP_NAME:
-			if not(pl.gotscores)
-				return strcat(getplayerkey(pl.sv_entnum, "name"), " ^7(connecting)");
 			return getplayerkey(pl.sv_entnum, "name");
 
 		case SP_KDRATIO:
@@ -692,6 +704,7 @@
 	}
 }
 
+float lastpingstime;
 void Sbar_DrawScoreboard()
 {
 	//float xmin, ymin, xmax, ymax;
@@ -700,6 +713,12 @@
 	float specs, i;
 	float center_x;
 
+	if(time > lastpingstime + 10)
+	{
+		localcmd("pings\n");
+		lastpingstime = time;
+	}
+
 	sbar_fontsize = Sbar_GetFontsize();
 	if(sbar_fontsize_x == 0)
 		sbar_fontsize = '8 8 0';

Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh	2008-08-01 13:14:37 UTC (rev 3996)
+++ trunk/data/qcsrc/common/constants.qh	2008-08-01 16:21:23 UTC (rev 3997)
@@ -5,7 +5,8 @@
 // Revision 4: CSQC config var system
 // Revision 5: mapvote time fix
 // Revision 6: more robust against packet loss/delays, also show not yet connected clients
-#define CSQC_REVISION 6
+// Revision 7: packet loss column
+#define CSQC_REVISION 7
 
 // probably put these in common/
 // so server/ and client/ can be synced better

Modified: trunk/data/qcsrc/server/sv_main.qc
===================================================================
--- trunk/data/qcsrc/server/sv_main.qc	2008-08-01 13:14:37 UTC (rev 3996)
+++ trunk/data/qcsrc/server/sv_main.qc	2008-08-01 16:21:23 UTC (rev 3997)
@@ -137,19 +137,6 @@
 }
 
 
-void BroadcastPings()
-{
-	entity pl;
-	WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
-	WriteByte(MSG_BROADCAST, TE_CSQC_PING);
-	FOR_EACH_CLIENT(pl)
-	{
-		WriteByte(MSG_BROADCAST, num_for_edict(pl));
-		WriteShort(MSG_BROADCAST, pl.ping);
-	}
-	WriteByte(MSG_BROADCAST, 0);
-}
-
 /*
 =============
 StartFrame
@@ -197,10 +184,4 @@
 		self = RandomSelection_chosen_ent;
 		SelectSpawnPoint(0);
 	}
-
-	if(next_pingtime < time)
-	{
-		BroadcastPings();
-		next_pingtime = time + 10;
-	}
 }




More information about the nexuiz-commits mailing list