Skip to content

Commit

Permalink
:control now handles an idle side by reverting it to human before try…
Browse files Browse the repository at this point in the history
…ing 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.
  • Loading branch information
cbeck88 committed Feb 22, 2014
1 parent 78d9b0f commit c8c2f45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/dialogs/mp_change_control.cpp
Expand Up @@ -177,7 +177,7 @@ class side_controller
for(std::vector<team>::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());
}

Expand Down
12 changes: 12 additions & 0 deletions src/menu_events.cpp
Expand Up @@ -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<std::string>(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)
Expand Down

0 comments on commit c8c2f45

Please sign in to comment.