r3655 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri May 23 15:25:42 EDT 2008


Author: div0
Date: 2008-05-23 15:25:41 -0400 (Fri, 23 May 2008)
New Revision: 3655

Modified:
   trunk/data/qcsrc/server/cl_client.qc
Log:
change the version nag message to one of:
"NOTE: the server is running Nexuiz 2.4svn (beta), you have Nexuiz 2.4.2"
"NOTE: Nexuiz 2.4.3 is out, and you still have Nexuiz 2.4.2 - get the update from http://www.nexuiz.com/!"
"NOTE: the server is running Nexuiz 2.3, you have Nexuiz 2.4.2"


Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2008-05-23 17:12:01 UTC (rev 3654)
+++ trunk/data/qcsrc/server/cl_client.qc	2008-05-23 19:25:41 UTC (rev 3655)
@@ -1512,6 +1512,50 @@
 	}
 }
 
+float vercmp_recursive(string v1, string v2)
+{
+	float dot1, dot2;
+	string s1, s2;
+	float r;
+
+	dot1 = strstrofs(v1, ".", 0);
+	dot2 = strstrofs(v2, ".", 0);
+	if(dot1 == -1)
+		s1 = v1;
+	else
+		s1 = substring(v1, 0, dot1);
+	if(dot2 == -1)
+		s2 = v2;
+	else
+		s2 = substring(v2, 0, dot2);
+
+	r = stof(s1) - stof(s2);
+	if(r != 0)
+		return r;
+
+	r = strcasecmp(s1, s2);
+	if(r != 0)
+		return r;
+
+	if(dot1 == -1)
+		if(dot2 == -1)
+			return 0;
+		else
+			return -1;
+	else
+		if(dot2 == -1)
+			return 1;
+		else
+			return vercmp_recursive(substring(v1, dot1 + 1, 999), substring(v2, dot2 + 1, 999));
+}
+
+float vercmp(string v1, string v2)
+{
+	if(strcasecmp(v1, v2) == 0) // early out check
+		return 0;
+	return vercmp_recursive(v1, v2);
+}
+
 /*
 =============
 PlayerPreThink
@@ -1532,11 +1576,28 @@
 			if(time > self.version_nagtime)
 			{
 				if(strstr(self.cvar_g_nexuizversion, "svn", 0) < 0)
-					if(self.cvar_g_nexuizversion != cvar_string("g_nexuizversion"))
+				{
+					if(strstr(cvar_string("g_nexuizversion"), "svn", 0) >= 0)
 					{
-						dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "\n");
-						sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "\n"));
+						dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), " (beta)^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n");
+						sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), " (beta)^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n"));
 					}
+					else
+					{
+						float r;
+						r = vercmp(self.cvar_g_nexuizversion, cvar_string("g_nexuizversion"));
+						if(r < 0)
+						{
+							dprint("^1NOTE^7 to ", self.netname, "^7 - ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7 is out, and you still have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1 - get the update from ^4http://www.nexuiz.com/^1!\n");
+							sprint(self, strcat("\{1}^1NOTE: ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7 is out, and you still have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1 - get the update from ^4http://www.nexuiz.com/^1!\n"));
+						}
+						else if(r > 0)
+						{
+							dprint("^1NOTE^7 to ", self.netname, "^7 - the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n");
+							sprint(self, strcat("\{1}^1NOTE: ^7the server is running ^3Nexuiz ", cvar_string("g_nexuizversion"), "^7, you have ^3Nexuiz ", self.cvar_g_nexuizversion, "^1\n"));
+						}
+					}
+				}
 				self.version_nagtime = 0;
 			}
 




More information about the nexuiz-commits mailing list