r2055 - in trunk/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Dec 18 03:53:29 EST 2006


Author: div0
Date: 2006-12-18 03:53:29 -0500 (Mon, 18 Dec 2006)
New Revision: 2055

Modified:
   trunk/data/default.cfg
   trunk/data/qcsrc/server/bots.qc
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/g_world.qc
Log:
new cvar: quit_when_empty - exits the server once it is empty (apart from bots)
at the end of a game. Useful for server admins who use a service manager (like
svsvinit, daemontools, svc or, if nothing else is there, cron or a shell script
with an endless loop) that automatically restarts the server when needed, that
way, they can schedule an engine update to when the server is empty.


Modified: trunk/data/default.cfg
===================================================================
--- trunk/data/default.cfg	2006-12-18 08:42:55 UTC (rev 2054)
+++ trunk/data/default.cfg	2006-12-18 08:53:29 UTC (rev 2055)
@@ -748,6 +748,7 @@
 
 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
 
 // singleplayer campaign
 set g_campaign 0

Modified: trunk/data/qcsrc/server/bots.qc
===================================================================
--- trunk/data/qcsrc/server/bots.qc	2006-12-18 08:42:55 UTC (rev 2054)
+++ trunk/data/qcsrc/server/bots.qc	2006-12-18 08:53:29 UTC (rev 2055)
@@ -1245,7 +1245,6 @@
 .float isbot; // true if this client is actually a bot
 
 float skill;
-float currentbots;
 entity bot_list;
 .entity nextbot;
 

Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2006-12-18 08:42:55 UTC (rev 2054)
+++ trunk/data/qcsrc/server/cl_client.qc	2006-12-18 08:53:29 UTC (rev 2055)
@@ -669,7 +669,11 @@
 	self.flags = self.flags | FL_CLIENT;
 	self.version_nagtime = time + 10 + random() * 10;
 
-	if(player_count<0) player_count = 0;
+	if(player_count<0)
+	{
+		dprint("BUG player count is lower than zero, this cannot happen!\n");
+		player_count = 0;
+	}
 
 	bot_clientconnect();
 

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2006-12-18 08:42:55 UTC (rev 2054)
+++ trunk/data/qcsrc/server/defs.qh	2006-12-18 08:53:29 UTC (rev 2055)
@@ -5,6 +5,7 @@
 string	string_null;
 
 float player_count;
+float currentbots;
 float lms_lowest_lives;
 float lms_next_place;
 float() LMS_NewPlayerLives;

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2006-12-18 08:42:55 UTC (rev 2054)
+++ trunk/data/qcsrc/server/g_world.qc	2006-12-18 08:53:29 UTC (rev 2055)
@@ -629,6 +629,15 @@
 		return;
 	}
 
+	if(cvar("quit_when_empty"))
+	{
+		if(player_count <= currentbots)
+		{
+			localcmd("quit\n");
+			return;
+		}
+	}
+
 	if (cvar("samelevel")) // if samelevel is set, stay on same level
 	{
 		// this does not work because it tries to exec maps/nexdm01.mapcfg (which doesn't exist, it should be trying maps/dm_nexdm01.mapcfg for example)




More information about the nexuiz-commits mailing list