Skip to content

Commit

Permalink
rename team::is_human() -> is_local_human
Browse files Browse the repository at this point in the history
and is_ai -> is_local_ai
  • Loading branch information
gfgtdf committed Nov 12, 2014
1 parent 9fdc91e commit 54e27d2
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/actions/attack.cpp
Expand Up @@ -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_;

Expand Down
8 changes: 4 additions & 4 deletions src/callable_objects.hpp
Expand Up @@ -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)
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/game_events/action_wml.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -1776,7 +1776,7 @@ WML_HANDLER_FUNCTION(scroll, /*event_info*/, cfg)
const std::vector<int> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game_initialization/playcampaign.cpp
Expand Up @@ -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;
}
Expand Down
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_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());
}
Expand Down
12 changes: 6 additions & 6 deletions src/menu_events.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -2689,7 +2689,7 @@ void console_handler::do_droid() {
symbols["side"] = lexical_cast<std::string>(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<std::string>(side),"ai");
Expand All @@ -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<std::string>(side),"human");
}
Expand All @@ -2723,7 +2723,7 @@ void console_handler::do_idle() {
symbols["side"] = lexical_cast<std::string>(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<std::string>(side),"idle");
Expand All @@ -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<std::string>(side),"human");
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/play_controller.cpp
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -1108,7 +1108,7 @@ void play_controller::show_menu(const std::vector<std::string>& 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;
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/playmp_controller.cpp
Expand Up @@ -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()) {
Expand Down
10 changes: 5 additions & 5 deletions src/playsingle_controller.cpp
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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&) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/playturn.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/game_lua_kernel.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/synced_commands.cpp
Expand Up @@ -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();
}
Expand Down
15 changes: 8 additions & 7 deletions src/team.hpp
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/whiteboard/manager.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -382,15 +382,15 @@ 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());
sa.clear();
//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
{
Expand All @@ -402,7 +402,7 @@ void manager::on_change_controller(int side, const team& t)
for(size_t i=0; i<num_teams; ++i)
{
team& local_team = resources::teams->at(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());
}
}
Expand Down

0 comments on commit 54e27d2

Please sign in to comment.