r2388 - branches/nexuiz-2.0/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Apr 25 04:53:33 EDT 2007


Author: div0
Date: 2007-04-25 04:53:33 -0400 (Wed, 25 Apr 2007)
New Revision: 2388

Modified:
   branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc
   branches/nexuiz-2.0/data/qcsrc/server/g_world.qc
   branches/nexuiz-2.0/data/qcsrc/server/sv_main.qc
Log:
improved redirection system; remove netname workaround


Modified: branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc	2007-04-25 08:52:41 UTC (rev 2387)
+++ branches/nexuiz-2.0/data/qcsrc/server/cl_client.qc	2007-04-25 08:53:33 UTC (rev 2388)
@@ -1274,10 +1274,6 @@
 .float vote_nagtime;
 void PlayerPreThink (void)
 {
-	if(strlen(self.netname) > 0)
-		if(substring(self.netname, strlen(self.netname) - 1, 1) == "^")
-			self.netname = strzone(strcat(substring(self.netname, 0, strlen(self.netname) - 1), " ")); // BROKEN COLORS can be annoying!
-
 	// version nagging
 	if(self.version_nagtime)
 		if(self.cvar_g_nexuizversion)

Modified: branches/nexuiz-2.0/data/qcsrc/server/g_world.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/g_world.qc	2007-04-25 08:52:41 UTC (rev 2387)
+++ branches/nexuiz-2.0/data/qcsrc/server/g_world.qc	2007-04-25 08:53:33 UTC (rev 2388)
@@ -1,4 +1,5 @@
 float SPAWNFLAG_NO_WAYPOINTS_FOR_ITEMS = 1;
+string redirection_target;
 
 string GetMapname();
 void GotoNextMap();
@@ -731,10 +732,7 @@
 	}
 	if(cvar_string("quit_and_redirect") != "")
 	{
-		entity head;
-		FOR_EACH_REALCLIENT(head)
-			stuffcmd(head, strcat("\nconnect ", cvar_string("quit_and_redirect"), "\n"));
-		localcmd("wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; wait; quit\n");
+		redirection_target = strzone(cvar_string("quit_and_redirect"));
 		return TRUE;
 	}
 	if (cvar("samelevel")) // if samelevel is set, stay on same level
@@ -1945,3 +1943,51 @@
 	FOR_EACH_CLIENT(self)
 		self.hitsound = FALSE;
 }
+
+
+/*
+ * RedirectionThink:
+ * returns TRUE if redirecting
+ */
+float redirection_timeout;
+float redirection_nextthink;
+float RedirectionThink()
+{
+	float clients_found;
+
+	if(redirection_target == "")
+		return FALSE;
+
+	if(!redirection_timeout)
+	{
+		cvar_set("sv_public", "-2");
+		redirection_timeout = time + 0.5; // this will only try twice... should be able to keep more clients
+		if(redirection_target == "self")
+			bprint("^3SERVER NOTICE:^7 restarting the server\n");
+		else
+			bprint("^3SERVER NOTICE:^7 redirecting everyone to ", redirection_target, "\n");
+	}
+
+	if(time < redirection_nextthink)
+		return TRUE;
+
+	redirection_nextthink = time + 1;
+
+	clients_found = 0;
+	FOR_EACH_REALCLIENT(self)
+	{
+		ServerConsoleEcho(strcat("Redirecting: sending connect command to ", self.netname), FALSE);
+		if(redirection_target == "self")
+			stuffcmd(self, "\ndisconnect; net_connecttimeout 120; reconnect\n");
+		else
+			stuffcmd(self, strcat("\ndisconnect; connect ", redirection_target, "\n"));
+		++clients_found;
+	}
+
+	ServerConsoleEcho(strcat("Redirecting: ", ftos(clients_found), " clients left."), FALSE);
+
+	if(time > redirection_timeout || clients_found == 0)
+		localcmd("\nwait; wait; wait; quit\n");
+
+	return TRUE;
+}

Modified: branches/nexuiz-2.0/data/qcsrc/server/sv_main.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/sv_main.qc	2007-04-25 08:52:41 UTC (rev 2387)
+++ branches/nexuiz-2.0/data/qcsrc/server/sv_main.qc	2007-04-25 08:53:33 UTC (rev 2388)
@@ -145,8 +145,12 @@
 =============
 */
 void RuneMatchGivePoints();
+float RedirectionThink();
 void StartFrame (void)
 {
+	if(RedirectionThink())
+		return;
+
 	sv_maxairspeed = cvar("sv_maxairspeed");
 	sv_maxspeed = cvar ("sv_maxspeed");
 	sv_friction = cvar ("sv_friction");




More information about the nexuiz-commits mailing list