diff --git a/src/actions/attack.cpp b/src/actions/attack.cpp index ecf85b939f99..7c46dbebd5c6 100644 --- a/src/actions/attack.cpp +++ b/src/actions/attack.cpp @@ -1391,11 +1391,11 @@ namespace //to make mp games equal we only allow selecting advancements to the current side. //otherwise we'd give an unfair advantage to the side that hosts ai sides if units advance during ai turns. - if(!non_interactive() && (force_dialog_ || (t.is_human() && (is_current_side || !is_mp)))) + if(!non_interactive() && (force_dialog_ || (t.is_local_human() && (is_current_side || !is_mp)))) { res = dialogs::advance_unit_dialog(loc_); } - else if(t.is_ai() || t.is_network_ai() || t.is_empty() || t.is_idle()) + else if(t.is_local_ai() || t.is_network_ai() || t.is_empty() || t.is_idle()) { res = rand() % nb_options_; diff --git a/src/callable_objects.hpp b/src/callable_objects.hpp index 1ddcf4ac23d2..030c99de255a 100644 --- a/src/callable_objects.hpp +++ b/src/callable_objects.hpp @@ -194,8 +194,8 @@ CALLABLE_WRAPPER_INPUT(base_income) CALLABLE_WRAPPER_INPUT(village_gold) CALLABLE_WRAPPER_INPUT(village_support) CALLABLE_WRAPPER_INPUT(name) -CALLABLE_WRAPPER_INPUT(is_human) -CALLABLE_WRAPPER_INPUT(is_ai) +CALLABLE_WRAPPER_INPUT(is_local_human) +CALLABLE_WRAPPER_INPUT(is_local_ai) CALLABLE_WRAPPER_INPUT(is_network) CALLABLE_WRAPPER_INPUT_END CALLABLE_WRAPPER_FN(gold) @@ -206,8 +206,8 @@ CALLABLE_WRAPPER_FN(base_income) CALLABLE_WRAPPER_FN(village_gold) CALLABLE_WRAPPER_FN(village_support) CALLABLE_WRAPPER_FN(name) -CALLABLE_WRAPPER_FN(is_human) -CALLABLE_WRAPPER_FN(is_ai) +CALLABLE_WRAPPER_FN(is_local_human) +CALLABLE_WRAPPER_FN(is_local_ai) CALLABLE_WRAPPER_FN(is_network) CALLABLE_WRAPPER_END diff --git a/src/game_events/action_wml.cpp b/src/game_events/action_wml.cpp index 8ab711289fe2..4c9435b72bfb 100644 --- a/src/game_events/action_wml.cpp +++ b/src/game_events/action_wml.cpp @@ -1008,7 +1008,7 @@ WML_HANDLER_FUNCTION(message, event_info, cfg) // Make sanity check that side number is good // then check if this side is human controlled. if (side > 0 && side <= resources::teams->size() && - (*resources::teams)[side-1].is_human()) + (*resources::teams)[side-1].is_local_human()) { side_for_show = true; break; @@ -1776,7 +1776,7 @@ WML_HANDLER_FUNCTION(scroll, /*event_info*/, cfg) const std::vector side_list = get_sides_vector(cfg); bool side_match = false; BOOST_FOREACH(int side, side_list) { - if((*resources::teams)[side-1].is_human()) { + if((*resources::teams)[side-1].is_local_human()) { side_match = true; break; } diff --git a/src/game_initialization/playcampaign.cpp b/src/game_initialization/playcampaign.cpp index df60300c6a09..ee37e18b5f0d 100644 --- a/src/game_initialization/playcampaign.cpp +++ b/src/game_initialization/playcampaign.cpp @@ -108,7 +108,7 @@ static void show_carryover_message(saved_game& gamestate, playsingle_controller& BOOST_FOREACH(const team &t, teams) { - if (!t.persistent() || t.lost() || !t.is_human()) + if (!t.persistent() || t.lost() || !t.is_local_human()) { continue; } diff --git a/src/gui/dialogs/mp_change_control.cpp b/src/gui/dialogs/mp_change_control.cpp index d7b3f615005f..2fcf9bcfede2 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_network_ai() && !it->is_idle() + if(!it->is_local_ai() && !it->is_network_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 6ed1b034cc93..e902a1460718 100644 --- a/src/menu_events.cpp +++ b/src/menu_events.cpp @@ -110,7 +110,7 @@ std::string menu_handler::get_title_suffix(int side_num) { int controlled_recruiters = 0; for(size_t i = 0; i < teams_.size(); ++i) { - if(teams_[i].is_human() && !teams_[i].recruits().empty() + if(teams_[i].is_local_human() && !teams_[i].recruits().empty() && units_.find_leader(i + 1) != units_.end()) { ++controlled_recruiters; } @@ -2689,7 +2689,7 @@ void console_handler::do_droid() { symbols["side"] = lexical_cast(side); command_failed(vgettext("Can't droid networked side: '$side'.", symbols)); return; - } else if ((menu_handler_.teams_[side - 1].is_human() || menu_handler_.teams_[side - 1].is_idle()) && action != " off") { + } else if ((menu_handler_.teams_[side - 1].is_local_human() || menu_handler_.teams_[side - 1].is_idle()) && action != " off") { //this is our side, so give it to AI menu_handler_.teams_[side - 1].make_ai(); menu_handler_.change_controller(lexical_cast(side),"ai"); @@ -2698,7 +2698,7 @@ void console_handler::do_droid() { //play_controller, that we are no longer in control throw end_turn_exception(side); } - } else if (menu_handler_.teams_[side - 1].is_ai() && action != " on") { + } else if (menu_handler_.teams_[side - 1].is_local_ai() && action != " on") { menu_handler_.teams_[side - 1].make_human(); menu_handler_.change_controller(lexical_cast(side),"human"); } @@ -2723,7 +2723,7 @@ void console_handler::do_idle() { symbols["side"] = lexical_cast(side); command_failed(vgettext("Can't droid networked side: '$side'.", symbols)); return; - } else if (menu_handler_.teams_[side - 1].is_human() && action != " off") { + } else if (menu_handler_.teams_[side - 1].is_local_human() && action != " off") { //this is our side, so give it to idle menu_handler_.teams_[side - 1].make_idle(); menu_handler_.change_controller(lexical_cast(side),"idle"); @@ -2732,7 +2732,7 @@ void console_handler::do_idle() { //play_controller, that we are no longer in control throw end_turn_exception(side); } - } else if (menu_handler_.teams_[side - 1].is_ai() && action != " off") { + } else if (menu_handler_.teams_[side - 1].is_local_ai() && action != " off") { //this is our side, so give it to idle, without end turn exception. tell network it is human menu_handler_.teams_[side - 1].make_idle(); menu_handler_.change_controller(lexical_cast(side),"human"); @@ -3310,7 +3310,7 @@ void menu_handler::request_control_change ( int side_num, const std::string& pla { std::string side = str_cast(side_num); //if this is our side we are always allowed to change the controller - if (teams_[side_num - 1].is_human()) { + if (teams_[side_num - 1].is_local_human()) { if (player == preferences::login()) return; change_side_controller(side,player); diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 4e47b8a99665..62c363e248ee 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -556,7 +556,7 @@ void play_controller::do_init_side(bool is_replay, bool only_visual) { game_events::fire("side " + side_num + " turn " + turn_num); } - if(current_team().is_human() && !is_replay) { + if(current_team().is_local_human() && !is_replay) { update_gui_to_player(player_number_ - 1); } // We want to work out if units for this player should get healed, @@ -825,7 +825,7 @@ bool play_controller::can_execute_command(const hotkey::hotkey_command& cmd, int menu_handler_.current_unit().valid() && !(menu_handler_.current_unit()->unrenamable()) && menu_handler_.current_unit()->side() == gui_->viewing_side() && - gamestate_.board_.teams()[menu_handler_.current_unit()->side() - 1].is_human(); + gamestate_.board_.teams()[menu_handler_.current_unit()->side() - 1].is_local_human(); default: return false; @@ -931,13 +931,13 @@ int play_controller::find_human_team_before_current_player() const return -2; for (int i = player_number_-2; i >= 0; --i) { - if (gamestate_.board_.teams()[i].is_human()) { + if (gamestate_.board_.teams()[i].is_local_human()) { return i+1; } } for (int i = gamestate_.board_.teams().size()-1; i > player_number_-1; --i) { - if (gamestate_.board_.teams()[i].is_human()) { + if (gamestate_.board_.teams()[i].is_local_human()) { return i+1; } } @@ -1108,7 +1108,7 @@ void play_controller::show_menu(const std::vector& items_arg, int x // Remove WML commands if they would not be allowed here if(*i == "wml") { if(!context_menu || gui_->viewing_team() != gui_->playing_team() - || events::commands_disabled || !gamestate_.board_.teams()[gui_->viewing_team()].is_human() + || events::commands_disabled || !gamestate_.board_.teams()[gui_->viewing_team()].is_local_human() || (linger_ && !game_config::debug)){ i = items.erase(i); continue; @@ -1302,7 +1302,7 @@ void play_controller::check_victory() DBG_EE << "Side " << (side+1) << " and " << *m << " are not enemies." << std::endl; } - if (gamestate_.board_.teams()[side].is_human()) { + if (gamestate_.board_.teams()[side].is_local_human()) { found_player = true; } diff --git a/src/playmp_controller.cpp b/src/playmp_controller.cpp index 2d04f20645d2..b89cc0b73839 100644 --- a/src/playmp_controller.cpp +++ b/src/playmp_controller.cpp @@ -232,7 +232,7 @@ possible_end_play_signal playmp_controller::play_human_turn(){ if (new_time > 0 ){ current_team().set_countdown_time(new_time); cur_ticks = ticks; - if(current_team().is_human() && !beep_warning_time_) { + if(current_team().is_local_human() && !beep_warning_time_) { beep_warning_time_ = new_time - WARNTIME + ticks; } if(counting_down()) { diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index c4da8d426d02..fb43047f9815 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -724,7 +724,7 @@ possible_end_play_signal playsingle_controller::play_side() statistics::reset_turn_stats(gamestate_.board_.teams()[player_number_ - 1].save_id()); - if(current_team().is_human() || temporary_human) { + if(current_team().is_local_human() || temporary_human) { LOG_NG << "is human...\n"; temporary_human = false; // If a side is dead end the turn, but play at least side=1's @@ -747,7 +747,7 @@ possible_end_play_signal playsingle_controller::play_side() player_type_changed_ = true; // If new controller is not human, // reset gui to prev human one - if (!gamestate_.board_.teams()[player_number_-1].is_human()) { + if (!gamestate_.board_.teams()[player_number_-1].is_local_human()) { browse_ = true; int s = find_human_team_before_current_player(); if (s <= 0) @@ -766,7 +766,7 @@ possible_end_play_signal playsingle_controller::play_side() after_human_turn(); LOG_NG << "human finished turn...\n"; - } else if(current_team().is_ai()) { + } else if(current_team().is_local_ai()) { try { play_ai_turn(); } catch(fallback_ai_to_human_exception&) { @@ -805,7 +805,7 @@ possible_end_play_signal playsingle_controller::play_side() player_type_changed_ = true; // If new controller is not human, // reset gui to prev human one - if (!gamestate_.board_.teams()[player_number_-1].is_human()) { + if (!gamestate_.board_.teams()[player_number_-1].is_local_human()) { browse_ = true; int s = find_human_team_before_current_player(); if (s <= 0) @@ -1061,7 +1061,7 @@ bool playsingle_controller::can_execute_command(const hotkey::hotkey_command& cm case hotkey::HOTKEY_WML: //code mixed from play_controller::show_menu and code here - return (gui_->viewing_team() == gui_->playing_team()) && !events::commands_disabled && gamestate_.board_.teams()[gui_->viewing_team()].is_human() && !linger_ && !browse_; + return (gui_->viewing_team() == gui_->playing_team()) && !events::commands_disabled && gamestate_.board_.teams()[gui_->viewing_team()].is_local_human() && !linger_ && !browse_; case hotkey::HOTKEY_UNIT_HOLD_POSITION: case hotkey::HOTKEY_END_UNIT_TURN: return !browse_ && !linger_ && !events::commands_disabled; diff --git a/src/playturn.cpp b/src/playturn.cpp index 240e90f0e74a..301a6942173a 100644 --- a/src/playturn.cpp +++ b/src/playturn.cpp @@ -208,11 +208,11 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg resources::controller->on_not_observer(); } - if (resources::gameboard->is_observer() || (resources::gameboard->teams())[resources::screen->playing_team()].is_human()) { + if (resources::gameboard->is_observer() || (resources::gameboard->teams())[resources::screen->playing_team()].is_local_human()) { resources::screen->set_team(resources::screen->playing_team()); resources::screen->redraw_everything(); resources::screen->recalculate_minimap(); - } else if (tm.is_human()) { + } else if (tm.is_local_human()) { resources::screen->set_team(side - 1); resources::screen->redraw_everything(); resources::screen->recalculate_minimap(); @@ -286,7 +286,7 @@ turn_info::PROCESS_DATA_RESULT turn_info::process_network_data(const config& cfg //get all allies in as options to transfer control BOOST_FOREACH(const team &t, resources::gameboard->teams()) { - if (!t.is_enemy(side_drop) && !t.is_human() && !t.is_ai() && !t.is_network_ai() && !t.is_empty() + if (!t.is_enemy(side_drop) && !t.is_local_human() && !t.is_local_ai() && !t.is_network_ai() && !t.is_empty() && t.current_player() != tm.current_player()) { //if this is an ally of the dropping side and it is not us (choose local player diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index 9e238eeff7af..21feae5390b1 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -2292,7 +2292,7 @@ namespace { config cfg; int index = 1; if (!lua_isnoneornil(L, 2)) { - if ((*resources::teams)[side - 1].is_ai()) + if ((*resources::teams)[side - 1].is_local_ai()) index = 2; } lua_pushvalue(L, index); diff --git a/src/synced_commands.cpp b/src/synced_commands.cpp index 62cafbbdab74..29bcddf4cadc 100644 --- a/src/synced_commands.cpp +++ b/src/synced_commands.cpp @@ -291,7 +291,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(move, child, use_undo, show, error_handler) } bool show_move = show; - if ( current_team.is_ai() || current_team.is_network_ai() ) + if ( current_team.is_local_ai() || current_team.is_network_ai()) { show_move = show_move && preferences::show_ai_moves(); } diff --git a/src/team.hpp b/src/team.hpp index d8782886dc64..ba82bbf5c1af 100644 --- a/src/team.hpp +++ b/src/team.hpp @@ -242,19 +242,20 @@ class team : public savegame::savegame_config CONTROLLER controller() const { return info_.controller; } const std::string& color() const { return info_.color; } void set_color(const std::string& color) { info_.color = color; } - bool is_human() const { return info_.controller == HUMAN; } - bool is_network_human() const { return info_.controller == NETWORK; } - bool is_network_ai() const { return info_.controller == NETWORK_AI; } - bool is_ai() const { return info_.controller == AI; } + //bool is_human() const { return info_.controller == HUMAN; } + //bool is_ai() const { return info_.controller == AI; } bool is_idle() const { return info_.controller == IDLE; } bool is_empty() const { return info_.controller == EMPTY; } - bool is_local() const { return is_human() || is_ai() || is_idle(); } + bool is_local() const { return is_local_human() || is_local_ai() || is_idle(); } bool is_network() const { return is_network_human() || is_network_ai(); } + bool is_local_human() const { return info_.controller == HUMAN; } + bool is_local_ai() const { return info_.controller == AI; } + bool is_network_human() const { return info_.controller == NETWORK; } + bool is_network_ai() const { return info_.controller == NETWORK_AI; } + void make_human() { info_.controller = HUMAN; } - void make_network() { info_.controller = NETWORK; } - void make_network_ai() { info_.controller = NETWORK_AI; } void make_ai() { info_.controller = AI; } void make_idle() { info_.controller = IDLE; } void change_controller(const std::string& new_controller) { diff --git a/src/whiteboard/manager.cpp b/src/whiteboard/manager.cpp index 4db30ce5d7cd..ae9c46a52993 100644 --- a/src/whiteboard/manager.cpp +++ b/src/whiteboard/manager.cpp @@ -352,7 +352,7 @@ static void hide_all_plans() void manager::update_plan_hiding(size_t team_index) { //We don't control the "viewing" side ... we're probably an observer - if(!resources::teams->at(team_index).is_human()) + if(!resources::teams->at(team_index).is_local_human()) hide_all_plans(); else // normal circumstance { @@ -382,7 +382,7 @@ void manager::on_viewer_change(size_t team_index) void manager::on_change_controller(int side, const team& t) { wb::side_actions& sa = *t.get_side_actions(); - if(t.is_human()) // we own this side now + if(t.is_local_human()) // we own this side now { //tell everyone to clear this side's actions -- we're starting anew resources::whiteboard->queue_net_cmd(sa.team_index(),sa.make_net_cmd_clear()); @@ -390,7 +390,7 @@ void manager::on_change_controller(int side, const team& t) //refresh the hidden_ attribute of every team's side_actions update_plan_hiding(); } - else if(t.is_ai() || t.is_network_ai()) // no one owns this side anymore + else if(t.is_local_ai() || t.is_network_ai()) // no one owns this side anymore sa.clear(); // clear its plans away -- the ai doesn't plan ... yet else if(t.is_network()) // Another client is taking control of the side { @@ -402,7 +402,7 @@ void manager::on_change_controller(int side, const team& t) for(size_t i=0; iat(i); - if(local_team.is_human() && !local_team.is_enemy(side)) + if(local_team.is_local_human() && !local_team.is_enemy(side)) resources::whiteboard->queue_net_cmd(i,local_team.get_side_actions()->make_net_cmd_refresh()); } }