about summary refs log tree commit diff
path: root/src/game/server
diff options
context:
space:
mode:
authorAlfred Eriksson <somerunce@gmail.com>2008-09-07 08:57:59 +0000
committerAlfred Eriksson <somerunce@gmail.com>2008-09-07 08:57:59 +0000
commita92c6d44dcb62675cf1937e1e618e50010345ac7 (patch)
tree690b97b435c2eddd1640fd160bd3fbb05f92f354 /src/game/server
parent777e685a2467c7b1b3b3c6f3626048d71a41690b (diff)
downloadzcatch-a92c6d44dcb62675cf1937e1e618e50010345ac7.tar.gz
zcatch-a92c6d44dcb62675cf1937e1e618e50010345ac7.zip
merge from 0.4.3: notification on auto team balance
Diffstat (limited to 'src/game/server')
-rw-r--r--src/game/server/gamecontroller.cpp14
-rw-r--r--src/game/server/gamecontroller.hpp7
-rw-r--r--src/game/server/gameworld.cpp2
3 files changed, 20 insertions, 3 deletions
diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp
index 4c3c121b..bf4f5451 100644
--- a/src/game/server/gamecontroller.cpp
+++ b/src/game/server/gamecontroller.cpp
@@ -27,6 +27,7 @@ GAMECONTROLLER::GAMECONTROLLER()
 	teamscore[1] = 0;
 	
 	unbalanced_tick = -1;
+	force_balanced = false;
 	
 	num_spawn_points[0] = 0;
 	num_spawn_points[1] = 0;
@@ -191,6 +192,7 @@ void GAMECONTROLLER::startround()
 	teamscore[0] = 0;
 	teamscore[1] = 0;
 	unbalanced_tick = -1;
+	force_balanced = false;
 	round_count++;
 }
 
@@ -324,6 +326,17 @@ bool GAMECONTROLLER::is_friendly_fire(int cid1, int cid2)
 	return false;
 }
 
+bool GAMECONTROLLER::is_force_balanced()
+{
+	if(force_balanced)
+	{
+		force_balanced = false;
+		return true;
+	}
+	else
+		return false;
+}
+
 void GAMECONTROLLER::tick()
 {
 	// do warmup
@@ -385,6 +398,7 @@ void GAMECONTROLLER::tick()
 			p->force_balanced = true;
 		} while (--num_balance);
 		
+		force_balanced = true;
 		unbalanced_tick = -1;
 	}
 	
diff --git a/src/game/server/gamecontroller.hpp b/src/game/server/gamecontroller.hpp
index 2cffc8a8..89a8ad46 100644
--- a/src/game/server/gamecontroller.hpp
+++ b/src/game/server/gamecontroller.hpp
@@ -47,13 +47,12 @@ protected:
 	int round_count;
 	
 	int game_flags;
-	
+	int unbalanced_tick;
+	bool force_balanced;
 	
 public:
 	bool is_teamplay() const;
 	
-	int unbalanced_tick;
-	
 	GAMECONTROLLER();
 
 	void do_team_score_wincheck();
@@ -65,6 +64,8 @@ public:
 	void endround();
 	
 	bool is_friendly_fire(int cid1, int cid2);
+	
+	bool is_force_balanced();
 
 	/*
 	
diff --git a/src/game/server/gameworld.cpp b/src/game/server/gameworld.cpp
index 60b276d3..9e76f14b 100644
--- a/src/game/server/gameworld.cpp
+++ b/src/game/server/gameworld.cpp
@@ -145,6 +145,8 @@ void GAMEWORLD::tick()
 
 	if(!paused)
 	{
+		if(game.controller->is_force_balanced())
+			game.send_chat(-1, GAMECONTEXT::CHAT_ALL, "Teams have been balanced");
 		// update all objects
 		for(ENTITY *ent = first_entity; ent; ent = ent->next_entity)
 			ent->tick();