From a92c6d44dcb62675cf1937e1e618e50010345ac7 Mon Sep 17 00:00:00 2001 From: Alfred Eriksson Date: Sun, 7 Sep 2008 08:57:59 +0000 Subject: merge from 0.4.3: notification on auto team balance --- src/game/server/gamecontroller.cpp | 14 ++++++++++++++ src/game/server/gamecontroller.hpp | 7 ++++--- src/game/server/gameworld.cpp | 2 ++ 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(); -- cgit 1.4.1