From c8c2f453eaf0fd235f0612a1b7872a042ad5e9f4 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Fri, 21 Feb 2014 17:42:36 -0500 Subject: [PATCH] :control now handles an idle side by reverting it to human before trying to transfer also, make :give_control dialog handle idle players correctly request_control_change is the place to do idle player switching, this handles both the :control command and the :give_control dialog. --- src/gui/dialogs/mp_change_control.cpp | 2 +- src/menu_events.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/mp_change_control.cpp b/src/gui/dialogs/mp_change_control.cpp index 9a88b7118b33..ceb2d3f43483 100644 --- a/src/gui/dialogs/mp_change_control.cpp +++ b/src/gui/dialogs/mp_change_control.cpp @@ -177,7 +177,7 @@ class side_controller for(std::vector::const_iterator it = resources::teams->begin(); it != resources::teams->end(); ++it) { - if(!it->is_ai() && !it->is_empty() && !it->current_player().empty()) + if(!it->is_ai() && !it->is_idle() && !it->is_empty() && !it->current_player().empty()) nicks.insert(it->current_player()); } diff --git a/src/menu_events.cpp b/src/menu_events.cpp index fcbd6209fdd6..ad69151e3c18 100644 --- a/src/menu_events.cpp +++ b/src/menu_events.cpp @@ -3272,6 +3272,18 @@ void menu_handler::request_control_change ( int side_num, const std::string& pla if (player == preferences::login()) return; change_side_controller(side,player); + } else if (teams_[side_num - 1].is_idle()) { //if this is our side and it is idle, make human and throw an end turn exception + LOG_NG << " *** Got an idle side with requested control change " << std::endl; + teams_[side_num - 1].make_human(); + change_controller(lexical_cast(side_num),"human"); + + if (player == preferences::login()) { + LOG_NG << " *** It's us, throwing end turn exception " << std::endl; + } else { + LOG_NG << " *** It's not us, changing sides now as usual, then throwing end_turn " << std::endl; + change_side_controller(side,player); + } + throw end_turn_exception(side_num); } else { //it is not our side, the server will decide if we can change the //controller (that is if we are host of the game)