r2377 - in trunk/data: . qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Apr 24 05:33:03 EDT 2007
Author: div0
Date: 2007-04-24 05:33:03 -0400 (Tue, 24 Apr 2007)
New Revision: 2377
Modified:
trunk/data/default.cfg
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/sv_main.qc
Log:
quit_and_redirect improved, can now redirect to "self" (for a seamless server restart) and retries until all players are gone
Modified: trunk/data/default.cfg
===================================================================
--- trunk/data/default.cfg 2007-04-23 22:24:06 UTC (rev 2376)
+++ trunk/data/default.cfg 2007-04-24 09:33:03 UTC (rev 2377)
@@ -611,7 +611,8 @@
set nextmap "" // override the maplist when switching to the next map
set lastlevel ""
-set quit_when_empty 0 // set to 1, then the server exits when the next level starts
+set quit_when_empty 0 // set to 1, then the server exits when the next level would start but is empty
+set quit_and_redirect "" // set to an IP to redirect all players at the end of the match to another server. Set to "self" to let all players reconnect at the end of the match (use it to make seamless engine updates)
// singleplayer campaign
set g_campaign 0
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2007-04-23 22:24:06 UTC (rev 2376)
+++ trunk/data/qcsrc/server/g_world.qc 2007-04-24 09:33:03 UTC (rev 2377)
@@ -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 + 10;
+ 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; 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("\nquit\n");
+
+ return TRUE;
+}
Modified: trunk/data/qcsrc/server/sv_main.qc
===================================================================
--- trunk/data/qcsrc/server/sv_main.qc 2007-04-23 22:24:06 UTC (rev 2376)
+++ trunk/data/qcsrc/server/sv_main.qc 2007-04-24 09:33:03 UTC (rev 2377)
@@ -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