r4478 - in trunk/data/qcsrc: common server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Sep 21 11:25:02 EDT 2008


Author: div0
Date: 2008-09-21 11:25:00 -0400 (Sun, 21 Sep 2008)
New Revision: 4478

Modified:
   trunk/data/qcsrc/common/mapinfo.qc
   trunk/data/qcsrc/common/mapinfo.qh
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/common/util.qh
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/teamplay.qc
Log:
fix fog handling a bit


Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/common/mapinfo.qc	2008-09-21 15:25:00 UTC (rev 4478)
@@ -475,6 +475,7 @@
 	MapInfo_Map_supportedGametypes = 0;
 	MapInfo_Map_supportedFeatures = 0;
 	MapInfo_Map_clientstuff = "";
+	MapInfo_Map_fog = "";
 }
 
 void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType)
@@ -538,23 +539,6 @@
 	else                  return 0;
 }
 
-float cvar_value_issafe(string s)
-{
-	if(strstrofs(s, "\"", 0) >= 0)
-		return 0;
-	if(strstrofs(s, "\\", 0) >= 0)
-		return 0;
-	if(strstrofs(s, ";", 0) >= 0)
-		return 0;
-	if(strstrofs(s, "$", 0) >= 0)
-		return 0;
-	if(strstrofs(s, "\r", 0) >= 0)
-		return 0;
-	if(strstrofs(s, "\n", 0) >= 0)
-		return 0;
-	return 1;
-}
-
 // load info about a map by name into the MapInfo_Map_* globals
 float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametypeToSet)
 {
@@ -704,6 +688,13 @@
 				dprint("Map ", pFilename, " has a client setting for unknown game type ", t, ", ignored\n");
 			}
 		}
+		else if(t == "fog")
+		{
+			if not(cvar_value_issafe(t))
+				print("Map ", pFilename, " contains a potentially harmful fog setting, ignored\n");
+			else
+				MapInfo_Map_fog = s;
+		}
 		else if(t == "cdtrack")
 		{
 			if(pGametypeToSet)

Modified: trunk/data/qcsrc/common/mapinfo.qh
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qh	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/common/mapinfo.qh	2008-09-21 15:25:00 UTC (rev 4478)
@@ -21,6 +21,7 @@
 string MapInfo_Map_description;
 string MapInfo_Map_author;
 string MapInfo_Map_clientstuff;
+string MapInfo_Map_fog;
 float MapInfo_Map_supportedGametypes;
 float MapInfo_Map_supportedFeatures;
 

Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/common/util.qc	2008-09-21 15:25:00 UTC (rev 4478)
@@ -694,3 +694,20 @@
 	
 	return order;
 }
+
+float cvar_value_issafe(string s)
+{
+	if(strstrofs(s, "\"", 0) >= 0)
+		return 0;
+	if(strstrofs(s, "\\", 0) >= 0)
+		return 0;
+	if(strstrofs(s, ";", 0) >= 0)
+		return 0;
+	if(strstrofs(s, "$", 0) >= 0)
+		return 0;
+	if(strstrofs(s, "\r", 0) >= 0)
+		return 0;
+	if(strstrofs(s, "\n", 0) >= 0)
+		return 0;
+	return 1;
+}

Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/common/util.qh	2008-09-21 15:25:00 UTC (rev 4478)
@@ -76,3 +76,5 @@
 
 string fixPriorityList(string pl, float from, float to, float complete);
 string swapInPriorityList(string order, float i, float j);
+
+float cvar_value_issafe(string s);

Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/server/cl_client.qc	2008-09-21 15:25:00 UTC (rev 4478)
@@ -1047,6 +1047,17 @@
 	 */
 }
 
+.float fogtime;
+void SendFog()
+{
+	if(world.fog) // NOT string_null!
+	if(!self.fogtime || (sv_foginterval && time > self.fogtime))
+	{
+		stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
+		self.fogtime = time + sv_foginterval;
+	}
+}
+
 /*
 =============
 ClientConnect
@@ -1227,6 +1238,8 @@
 			self.frags = -666; // FIXME do we still need this?
 		}
 	}
+
+	SendFog();
 }
 
 /*
@@ -2028,8 +2041,12 @@
 	}
 
 	if(frametime)
+	{
 		antilag_record(self);
 
+		SendFog();
+	}
+
 	if(self.classname == "player") {
 //		if(self.netname == "Wazat")
 //			bprint(self.classname, "\n");

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/server/defs.qh	2008-09-21 15:25:00 UTC (rev 4478)
@@ -491,3 +491,5 @@
 .float weapons;
 
 .float porto_forbidden;
+
+.string fog;

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/server/g_world.qc	2008-09-21 15:25:00 UTC (rev 4478)
@@ -8,8 +8,6 @@
 void ShuffleMaplist()
 float() DoNextMapOverride;
 
-.string fog;
-
 void SetDefaultAlpha()
 {
 	if(cvar("g_running_guns"))
@@ -1078,7 +1076,6 @@
 Exit deathmatch games upon conditions
 ============
 */
-.float fogtime;
 void CheckRules_Player()
 {
 	if (gameover)	// someone else quit the game already
@@ -1087,14 +1084,6 @@
 	if(self.deadflag == DEAD_NO)
 		self.play_time += frametime;
 
-	if(sv_foginterval)
-	if(world.fog)
-	if(time > self.fogtime)
-	{
-		stuffcmd(self, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
-		self.fogtime = time + sv_foginterval;
-	}
-
 	// fixme: don't check players; instead check spawnfunc_dom_team and spawnfunc_ctf_team entities
 	//   (div0: and that in CheckRules_World please)
 };

Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc	2008-09-21 12:44:50 UTC (rev 4477)
+++ trunk/data/qcsrc/server/teamplay.qc	2008-09-21 15:25:00 UTC (rev 4478)
@@ -173,6 +173,16 @@
 	WriteGameCvars();
 
 	MapInfo_LoadMapSettings(mapname);
+	if not(cvar_value_issafe(world.fog))
+	{
+		print("The current map contains a potentially harmful fog setting, ignored\n");
+		world.fog = string_null;
+	}
+	if(MapInfo_Map_fog != "")
+		if(MapInfo_Map_fog == "none")
+			world.fog = string_null;
+		else
+			world.fog = strzone(MapInfo_Map_fog);
 	clientstuff = strzone(MapInfo_Map_clientstuff);
 	MapInfo_ClearTemps();
 




More information about the nexuiz-commits mailing list