From 622095452f3fbf5a26d6ec118733cc6b03ca6740 Mon Sep 17 00:00:00 2001 From: Serge Martin Date: Sun, 24 Sep 2006 14:02:19 +0000 Subject: [PATCH] fix the green game bug. note that game still be displaying in green as long as host don't set the new controller. empty slot won't be shown as available now. --- src/playturn.cpp | 11 +++++++++++ src/server/game.cpp | 28 +++++++++------------------- src/server/game.hpp | 2 -- src/server/server.cpp | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/playturn.cpp b/src/playturn.cpp index 9f8fb9fb34c..f57b3f68020 100644 --- a/src/playturn.cpp +++ b/src/playturn.cpp @@ -15,6 +15,7 @@ #include "game_config.hpp" #include "gettext.hpp" +#include "preferences.hpp" #include "replay.hpp" #include "show_dialog.hpp" #include "sound.hpp" @@ -213,9 +214,19 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg switch(action) { case 0: teams_[side].make_ai(); + { + config cfg; + cfg.values["side"] = lexical_cast(side+1); + network::send_data(cfg); + } return PROCESS_RESTART_TURN; case 1: teams_[side].make_human(); + { + config cfg; + cfg.values["side"] = lexical_cast(side+1); + network::send_data(cfg); + } return PROCESS_RESTART_TURN; default: if (action > 2) { diff --git a/src/server/game.cpp b/src/server/game.cpp index b3eda0503d4..b2753e1bac1 100644 --- a/src/server/game.cpp +++ b/src/server/game.cpp @@ -358,7 +358,7 @@ const std::string& game::transfer_side_control(const config& cfg) } //get the socket of the player that issued the command - bool host = false; //we need to save this information before the player is erased + bool host = false; //we need to save this information before the player is erased network::connection sock; bool foundCommandPlayer = false; std::multimap::iterator oldside; @@ -459,34 +459,24 @@ const std::string& game::transfer_side_control(const config& cfg) return success; } -size_t game::available_slots() const -{ - size_t n_sides = level_.get_children("side").size(); - size_t available_slots = 0; - for(int s = 0; s < n_sides; ++s) { - if(! sides_taken_[s]) { - available_slots++; - } - - } - - return available_slots; -} - bool game::describe_slots() { if(description() == NULL) return false; - const int val = int(available_slots()); + int available_slots = 0; char buf[50]; int num_sides = level_.get_children("side").size(); - for(config::child_list::const_iterator it = level_.get_children("side").begin(); it != level_.get_children("side").end(); ++it) { - if((**it)["allow_player"] == "no") { + int i = 0; + for(config::child_list::const_iterator it = level_.get_children("side").begin(); it != level_.get_children("side").end(); ++it, ++i) { + if((**it)["allow_player"] == "no" or (**it)["no_leader"] == "yes") { num_sides--; + } else { + if(!sides_taken_[i]) + available_slots++; } } - snprintf(buf,sizeof(buf),"%d/%d",val,num_sides); + snprintf(buf,sizeof(buf), "%d/%d", available_slots, num_sides); if(buf != (*description())["slots"]) { description()->values["slots"] = buf; diff --git a/src/server/game.hpp b/src/server/game.hpp index 2cfb86b43b0..ef7fb959e3a 100644 --- a/src/server/game.hpp +++ b/src/server/game.hpp @@ -56,8 +56,6 @@ public: const std::string& transfer_side_control(const config& cfg); - size_t available_slots() const; - //function to set the description to the number of slots //returns true if the number of slots has changed bool describe_slots(); diff --git a/src/server/server.cpp b/src/server/server.cpp index 0f4fdfda4cd..505a8bf6a36 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -980,7 +980,7 @@ void server::process_data_from_player_in_game(const network::connection sock, co //if the owner is banning someone from the game if(g->is_owner(sock) && (data.child("ban") != NULL || data.child("kick") != NULL)) { std::string name; - bool ban; + bool ban = false;; if (data.child("ban") != NULL) { const config& u = *data.child("ban"); name = u["username"];