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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Jan 27 08:21:56 EST 2009


Author: div0
Date: 2009-01-27 08:21:55 -0500 (Tue, 27 Jan 2009)
New Revision: 5676

Modified:
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/common/constants.qh
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/scores.qc
   trunk/data/qcsrc/server/scores.qh
Log:
make TE_CSQC_INIT and TE_CSQC_SCORESINFO shared entities. Should fix their issues with savegames.


Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2009-01-27 12:56:38 UTC (rev 5675)
+++ trunk/data/qcsrc/client/Main.qc	2009-01-27 13:21:55 UTC (rev 5676)
@@ -482,6 +482,8 @@
 // CSQC_Ent_Update : Called every frame that the server has indicated an update to the SSQC / CSQC entity has occured.
 // The only parameter reflects if the entity is "new" to the client, meaning it just came into the client's PVS.
 void Ent_RadarLink();
+void Ent_Init();
+void Ent_ScoresInfo();
 void(float bIsNewEntity) CSQC_Ent_Update =
 {
 	float t;
@@ -528,6 +530,10 @@
 		Ent_DamageInfo();
 	else if(self.enttype == ENT_CLIENT_CASING)
 		Ent_Casing();
+	else if(self.enttype == ENT_CLIENT_INIT)
+		Ent_Init();
+	else if(self.enttype == ENT_CLIENT_SCORES_INFO)
+		Ent_ScoresInfo();
 	else
 		error(strcat("unknown entity type in CSQC_Ent_Update: ", ftos(self.enttype), "\n"));
 	
@@ -648,7 +654,7 @@
 }
 
 void Gamemode_Init();
-void Net_ReadScoresInfo()
+void Ent_ScoresInfo()
 {
 	float i;
 	gametype = ReadByte();
@@ -666,9 +672,11 @@
 	Gamemode_Init();
 }
 
-void Net_ReadInit()
+void Ent_Init()
 {
 	float i;
+	self.classname = "ent_client_init";
+
 	csqc_revision = ReadShort();
 	maxclients = ReadByte();
 	for(i = 0; i < 24; ++i)
@@ -677,6 +685,9 @@
 	hook_shotorigin_y = ReadCoord();
 	hook_shotorigin_z = ReadCoord();
 	CSQC_CheckRevision();
+	
+	if(!postinit)
+		PostInit();
 }
 
 string Net_ReadPicture()
@@ -832,10 +843,6 @@
 		// NOTE: Could just do return instead of break...
 	switch(nTEID)
 	{
-		case TE_CSQC_INIT:
-			Net_ReadInit();
-			bHandled = true;
-			break;
 		case TE_CSQC_MAPVOTE:
 			Net_Mapvote();
 			bHandled = true;
@@ -844,10 +851,6 @@
 			Net_Config();
 			bHandled = true;
 			break;
-		case TE_CSQC_SCORESINFO:
-			Net_ReadScoresInfo();
-			bHandled = true;
-			break;
 		case TE_CSQC_RACE:
 			Net_ReadRace();
 			bHandled = true;
@@ -889,9 +892,6 @@
 			bHandled = false;
 			break;
 	}
-	
-	if(!postinit)
-		PostInit();
 		
 	return bHandled;
 }

Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh	2009-01-27 12:56:38 UTC (rev 5675)
+++ trunk/data/qcsrc/common/constants.qh	2009-01-27 13:21:55 UTC (rev 5676)
@@ -58,6 +58,7 @@
 const float ENT_CLIENT_GIBSPLASH = 13;
 const float ENT_CLIENT_DAMAGEINFO = 14;
 const float ENT_CLIENT_CASING = 15;
+const float ENT_CLIENT_INIT = 16;
 
 const float SPRITERULE_DEFAULT = 0;
 const float SPRITERULE_TEAMPLAY = 1;
@@ -213,11 +214,9 @@
 const float ENTCS_MSG_ONS_REMOVE = 2;
 const float ENTCS_MSG_INIT = 3;
 
-const float TE_CSQC_INIT = 100; // TODO get rid of this
 const float TE_CSQC_PICTURE = 105;
 const float TE_CSQC_MAPVOTE = 106; // TODO turn into shared ent
 const float TE_CSQC_CONFIG = 107; // TODO maybe turn into shared ent
-const float TE_CSQC_SCORESINFO = 108; // TODO turn into shared ent
 const float TE_CSQC_RACE = 109;
 const float TE_CSQC_FORCESCOREBOARD = 110; // TODO turn into shared ent
 const float TE_CSQC_SPECTATING = 111; // TODO turn into shared ent

Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2009-01-27 12:56:38 UTC (rev 5675)
+++ trunk/data/qcsrc/server/cl_client.qc	2009-01-27 13:21:55 UTC (rev 5676)
@@ -823,21 +823,10 @@
 	//	ctf_playerchanged();
 }
 
-/*
-=============
-SendCSQCInfo
-
-Send whatever CSQC needs NOW and cannot wait for SendServerInfo to happen...
-=============
-*/
-void SendCSQCInfo(void)
+float ClientInit_SendEntity(entity to, float sf)
 {
 	float i;
-	if(clienttype(self) != CLIENTTYPE_REAL)
-		return;
-	msg_entity = self;
-	WriteByte(MSG_ONE, SVC_TEMPENTITY);
-	WriteByte(MSG_ONE, TE_CSQC_INIT);
+	WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
 	WriteShort(MSG_ONE, CSQC_REVISION);
 	WriteByte(MSG_ONE, maxclients);
 	for(i = 1; i <= 24; ++i)
@@ -845,8 +834,19 @@
 	WriteCoord(MSG_ONE, hook_shotorigin_x);
 	WriteCoord(MSG_ONE, hook_shotorigin_y);
 	WriteCoord(MSG_ONE, hook_shotorigin_z);
+	return TRUE;
 }
 
+void ClientInit_Spawn()
+{
+	entity e;
+	e = spawn();
+	e.classname = "ent_client_init";
+	e.SendEntity = ClientInit_SendEntity;
+	setmodel(e, "null");
+	e.effects = EF_NODEPTHTEST;
+}
+
 /*
 =============
 SetNewParms
@@ -1267,14 +1267,13 @@
 	if(clienttype(self) == CLIENTTYPE_REAL)
 	{
 		sprint(self, strcat("nexuiz-csqc protocol ", ftos(CSQC_REVISION), "\n"));
-		SendCSQCInfo();
+
 		msg_entity = self;
 		if(mapvote_initialized && !cvar("g_maplist_textonly"))
 		{
 			MapVote_SendData(MSG_ONE);
 			MapVote_UpdateData(MSG_ONE);
 		}
-		ScoreInfo_Write(MSG_ONE);
 
 		if(inWarmupStage)
 		{

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2009-01-27 12:56:38 UTC (rev 5675)
+++ trunk/data/qcsrc/server/g_world.qc	2009-01-27 13:21:55 UTC (rev 5676)
@@ -301,6 +301,7 @@
 float world_already_spawned;
 void RegisterWeapons();
 void Nagger_Init();
+void ClientInit_Spawn();
 void spawnfunc_worldspawn (void)
 {
 	float fd, l, i, j, n;
@@ -555,6 +556,8 @@
 
 	records_reply = strzone(getrecords());
 
+	ClientInit_Spawn();
+
 	world_initialized = 1;
 }
 

Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc	2009-01-27 12:56:38 UTC (rev 5675)
+++ trunk/data/qcsrc/server/scores.qc	2009-01-27 13:21:55 UTC (rev 5676)
@@ -150,29 +150,38 @@
 	}
 }
 
-void ScoreInfo_Write(float targ)
+float ScoreInfo_SendEntity(entity to, float sf)
 {
 	float i;
-	if not(scores_initialized)
-		return;
-	WriteByte(targ, SVC_TEMPENTITY);
-	WriteByte(targ, TE_CSQC_SCORESINFO);
-	WriteByte(targ, game);
+	WriteByte(MSG_ENTITY, ENT_CLIENT_SCORES_INFO);
+	WriteByte(MSG_ENTITY, game);
 	for(i = 0; i < MAX_SCORE; ++i)
 	{
-		WriteString(targ, scores_label[i]);
-		WriteByte(targ, scores_flags[i]);
+		WriteString(MSG_ENTITY, scores_label[i]);
+		WriteByte(MSG_ENTITY, scores_flags[i]);
 	}
 	for(i = 0; i < MAX_TEAMSCORE; ++i)
 	{
-		WriteString(targ, teamscores_label[i]);
-		WriteByte(targ, teamscores_flags[i]);
+		WriteString(MSG_ENTITY, teamscores_label[i]);
+		WriteByte(MSG_ENTITY, teamscores_flags[i]);
 	}
+	return TRUE;
 }
 
 void ScoreInfo_Init(float teams)
 {
-	scores_initialized = 1;
+	if(scores_initialized)
+	{
+		scores_initialized.SendFlags |= 1; // force a resend
+	}
+	else
+	{
+		scores_initialized = spawn();
+		scores_initialized.classname = "ent_client_scoreinfo";
+		scores_initialized.SendEntity = ScoreInfo_SendEntity;
+		setmodel(scores_initialized, "null");
+		scores_initialized.effects = EF_NODEPTHTEST;
+	}
 	if(teams >= 1)
 		TeamScore_Spawn(COLOR_TEAM1, "Red");
 	if(teams >= 2)
@@ -181,7 +190,6 @@
 		TeamScore_Spawn(COLOR_TEAM3, "Yellow");
 	if(teams >= 4)
 		TeamScore_Spawn(COLOR_TEAM4, "Pink");
-	ScoreInfo_Write(MSG_ALL);
 }
 
 /*

Modified: trunk/data/qcsrc/server/scores.qh
===================================================================
--- trunk/data/qcsrc/server/scores.qh	2009-01-27 12:56:38 UTC (rev 5675)
+++ trunk/data/qcsrc/server/scores.qh	2009-01-27 13:21:55 UTC (rev 5676)
@@ -1,4 +1,4 @@
-float scores_initialized; // 1 when scores labels/rules have been set
+entity scores_initialized; // non-world when scores labels/rules have been set
 .float scores[MAX_SCORE];
 .float teamscores[MAX_TEAMSCORE];
 
@@ -75,12 +75,6 @@
 void ScoreInfo_Init(float teams);
 
 /**
- * Writes the scores info to the given stream. Use this in ClientConnect to
- * notify newly connecting players.
- */
-void ScoreInfo_Write(float targ);
-
-/**
  * Clear ALL scores (for ready-restart).
  */
 void Score_ClearAll();




More information about the nexuiz-commits mailing list