about summary refs log tree commit diff
path: root/src/game/server/srv_dm.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-09-25 23:03:15 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-09-25 23:03:15 +0000
commitfb87d00c8dfde266a46d5479838f06bce0b375fd (patch)
tree01fa66bbc4db4a54bc1c7dd55bc2f087dd0b5ed7 /src/game/server/srv_dm.cpp
parent31861cf222939ca26578010d5bbda61c8e2cd238 (diff)
downloadzcatch-fb87d00c8dfde266a46d5479838f06bce0b375fd.tar.gz
zcatch-fb87d00c8dfde266a46d5479838f06bce0b375fd.zip
moved out dm, tdm and ctf rules to separate files
Diffstat (limited to 'src/game/server/srv_dm.cpp')
-rw-r--r--src/game/server/srv_dm.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/game/server/srv_dm.cpp b/src/game/server/srv_dm.cpp
new file mode 100644
index 00000000..01817262
--- /dev/null
+++ b/src/game/server/srv_dm.cpp
@@ -0,0 +1,45 @@
+#include <engine/config.h>
+#include "srv_common.h"
+#include "srv_dm.h"
+
+void gameobject_dm::tick()
+{
+	if(game_over_tick == -1)
+	{
+		// game is running
+		
+		// gather some stats
+		int topscore = 0;
+		int topscore_count = 0;
+		for(int i = 0; i < MAX_CLIENTS; i++)
+		{
+			if(players[i].client_id != -1)
+			{
+				if(players[i].score > topscore)
+				{
+					topscore = players[i].score;
+					topscore_count = 1;
+				}
+				else if(players[i].score == topscore)
+					topscore_count++;
+			}
+		}
+		
+		// check score win condition
+		if((config.scorelimit > 0 && topscore >= config.scorelimit) ||
+			(config.timelimit > 0 && (server_tick()-round_start_tick) >= config.timelimit*server_tickspeed()*60))
+		{
+			if(topscore_count == 1)
+				endround();
+			else
+				sudden_death = 1;
+		}
+	}
+	else
+	{
+		// game over.. wait for restart
+		if(server_tick() > game_over_tick+server_tickspeed()*10)
+			startround();
+	}
+}
+