about summary refs log tree commit diff
path: root/src/game/server/srv_tdm.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-11-26 19:18:49 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-11-26 19:18:49 +0000
commit2c149152a31e8921a93fea9bba2184318ac7e804 (patch)
tree02e33b7156f65e9d1b0c973f60f8aee227af99e0 /src/game/server/srv_tdm.cpp
parentfc3f17abf9a6aad17222492240b7514dd99ae039 (diff)
downloadzcatch-2c149152a31e8921a93fea9bba2184318ac7e804.tar.gz
zcatch-2c149152a31e8921a93fea9bba2184318ac7e804.zip
fixed tdm scoring
Diffstat (limited to 'src/game/server/srv_tdm.cpp')
-rw-r--r--src/game/server/srv_tdm.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/game/server/srv_tdm.cpp b/src/game/server/srv_tdm.cpp
index 84738a92..3595a129 100644
--- a/src/game/server/srv_tdm.cpp
+++ b/src/game/server/srv_tdm.cpp
@@ -8,31 +8,31 @@ gameobject_tdm::gameobject_tdm()
 	is_teamplay = true;
 }
 
+
+int gameobject_tdm::on_player_death(class player *victim, class player *killer, int weapon)
+{
+	gameobject::on_player_death(victim, killer, weapon);
+	
+	if(weapon >= 0)
+	{
+		// do team scoring
+		if(killer == victim)
+			teamscore[killer->team&1]--; // klant arschel
+		else
+			teamscore[killer->team&1]++; // good shit
+	}
+	return 0;
+}
+
 void gameobject_tdm::tick()
 {
-	if(game_over_tick == -1)
+	if(game_over_tick == -1 && !warmup)
 	{
-		// game is running
-		teamscore[0] = 0;
-		teamscore[1] = 0;
-		
-		// gather some stats
-		int topscore_count = 0;
-		for(int i = 0; i < MAX_CLIENTS; i++)
-		{
-			if(players[i].client_id != -1)
-				teamscore[players[i].team] += players[i].score;
-		}
-		if (teamscore[0] >= config.scorelimit)
-			topscore_count++;
-		if (teamscore[1] >= config.scorelimit)
-			topscore_count++;
-		
 		// check score win condition
 		if((config.scorelimit > 0 && (teamscore[0] >= config.scorelimit || teamscore[1] >= config.scorelimit)) ||
 			(config.timelimit > 0 && (server_tick()-round_start_tick) >= config.timelimit*server_tickspeed()*60))
 		{
-			if(topscore_count == 1)
+			if(teamscore[0] != teamscore[0])
 				endround();
 			else
 				sudden_death = 1;