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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jul 4 13:11:37 EDT 2008


Author: blub0
Date: 2008-07-04 13:11:31 -0400 (Fri, 04 Jul 2008)
New Revision: 3776

Modified:
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/common/constants.qh
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/ent_cs.qc
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/sv_main.qc
   trunk/data/qcsrc/server/teamplay.qc
Log:
Instead of wasting actual entities, I now use the TempEntity method
to broadcast the pings.
Thx to Black :)


Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2008-07-04 16:43:40 UTC (rev 3775)
+++ trunk/data/qcsrc/client/Main.qc	2008-07-04 17:11:31 UTC (rev 3776)
@@ -138,7 +138,6 @@
 		{
 			switch(msg)
 			{
-			case ENTCS_MSG_PING: ReadPings(); break;
 			case ENTCS_MSG_ONS: ReadONS(bIsNewEntity); break;
 			default:
 				error("unknown ENTCS_MSG type\n");
@@ -265,6 +264,10 @@
 		
 	switch(nTEID)
 	{
+		case TE_CSQC_PING:
+			ReadPings();
+			bHandled = true;
+			break;
 		//case TE_GUNSHOT:
 		//	Do something cool with TE_GUNSHOT!
 		//	break;

Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh	2008-07-04 16:43:40 UTC (rev 3775)
+++ trunk/data/qcsrc/common/constants.qh	2008-07-04 17:11:31 UTC (rev 3776)
@@ -154,5 +154,9 @@
 const float K_MOUSE16		=	529;
 
 const float ENTCS_MSG_END = 0;
-const float ENTCS_MSG_PING = 1;
-const float ENTCS_MSG_ONS = 2;
+const float ENTCS_MSG_ONS = 1;
+
+const float TE_CSQC_START = 100;
+const float TE_CSQC_PING = 100;
+
+const float TE_CSQC_END = 100;

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2008-07-04 16:43:40 UTC (rev 3775)
+++ trunk/data/qcsrc/server/defs.qh	2008-07-04 17:11:31 UTC (rev 3776)
@@ -434,3 +434,5 @@
 .float parm_idlesince;
 float sv_maxidle;
 float sv_maxidle_spectatorsareidle;
+
+float next_pingtime;

Modified: trunk/data/qcsrc/server/ent_cs.qc
===================================================================
--- trunk/data/qcsrc/server/ent_cs.qc	2008-07-04 16:43:40 UTC (rev 3775)
+++ trunk/data/qcsrc/server/ent_cs.qc	2008-07-04 17:11:31 UTC (rev 3776)
@@ -16,8 +16,6 @@
 .float(entity to) SendEntity;
 .float Version;
 
-.float pingtime;
-
 entity entcs_start;
 
 void entcs_init()
@@ -51,6 +49,7 @@
 
 void entcs_common_self()
 {
+	/*
 	entity pl;
 	if(self.pingtime < time)
 	{
@@ -64,6 +63,7 @@
 		}
 		WriteByte(MSG_ENTITY, 0);
 	}
+	*/
 }
 
 float entcs_send(entity to)
@@ -114,8 +114,6 @@
 	ent.model = "entcs_sender";
 	ent.modelindex = 1;
 	setsize(ent, '0 0 0', '0 0 0');
-
-	ent.pingtime = time + 5;
 		
 	ent.SendEntity = entcs_send;
 };

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2008-07-04 16:43:40 UTC (rev 3775)
+++ trunk/data/qcsrc/server/g_world.qc	2008-07-04 17:11:31 UTC (rev 3776)
@@ -357,6 +357,7 @@
 		fclose(fd);
 	}
 
+	next_pingtime = time + 5;
 	world_initialized = 1;
 }
 

Modified: trunk/data/qcsrc/server/sv_main.qc
===================================================================
--- trunk/data/qcsrc/server/sv_main.qc	2008-07-04 16:43:40 UTC (rev 3775)
+++ trunk/data/qcsrc/server/sv_main.qc	2008-07-04 17:11:31 UTC (rev 3776)
@@ -137,6 +137,19 @@
 }
 
 
+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
@@ -184,4 +197,10 @@
 		self = RandomSelection_chosen_ent;
 		SelectSpawnPoint(0);
 	}
+
+	if(next_pingtime < time)
+	{
+		BroadcastPings();
+		next_pingtime = time + 10;
+	}
 }

Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc	2008-07-04 16:43:40 UTC (rev 3775)
+++ trunk/data/qcsrc/server/teamplay.qc	2008-07-04 17:11:31 UTC (rev 3776)
@@ -326,8 +326,8 @@
 		tdm_init();
 	else if (game == GAME_KEYHUNT)//cvar("g_keyhunt"))
 		kh_init();
-	//else if (game == GAME_ONSLAUGHT)
-	entcs_init();
+	else if (game == GAME_ONSLAUGHT)
+		entcs_init();
 }
 
 string GetClientVersionMessage(float v) {




More information about the nexuiz-commits mailing list