Forward get_team call to a display_context derivative when necessary
This commit is contained in:
parent
f9a021eaab
commit
921bbc2d7d
3 changed files with 44 additions and 44 deletions
|
@ -132,7 +132,7 @@ void menu_handler::objectives()
|
|||
|
||||
void menu_handler::show_statistics(int side_num)
|
||||
{
|
||||
gui2::dialogs::statistics_dialog::display(teams()[side_num - 1], gui_->video());
|
||||
gui2::dialogs::statistics_dialog::display(board().get_team(side_num), gui_->video());
|
||||
}
|
||||
|
||||
void menu_handler::unit_list()
|
||||
|
@ -254,7 +254,7 @@ void menu_handler::recruit(int side_num, const map_location &last_hex)
|
|||
return;
|
||||
}
|
||||
|
||||
gui2::dialogs::unit_recruit dlg(sample_units, teams()[side_num - 1]);
|
||||
gui2::dialogs::unit_recruit dlg(sample_units, board().get_team(side_num));
|
||||
|
||||
dlg.show(gui_->video());
|
||||
|
||||
|
@ -266,7 +266,7 @@ void menu_handler::recruit(int side_num, const map_location &last_hex)
|
|||
|
||||
void menu_handler::repeat_recruit(int side_num, const map_location &last_hex)
|
||||
{
|
||||
const std::string & last_recruit = teams()[side_num - 1].last_recruit();
|
||||
const std::string & last_recruit = board().get_team(side_num).last_recruit();
|
||||
if ( last_recruit.empty() == false )
|
||||
do_recruit(last_recruit, side_num, last_hex);
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ void menu_handler::repeat_recruit(int side_num, const map_location &last_hex)
|
|||
bool menu_handler::do_recruit(const std::string &name, int side_num,
|
||||
const map_location &last_hex)
|
||||
{
|
||||
team ¤t_team = teams()[side_num - 1];
|
||||
team ¤t_team = board().get_team(side_num);
|
||||
|
||||
//search for the unit to be recruited in recruits
|
||||
if ( !utils::contains(actions::get_recruits(side_num, last_hex), name) )
|
||||
|
@ -322,7 +322,7 @@ void menu_handler::recall(int side_num, const map_location &last_hex)
|
|||
return;
|
||||
}
|
||||
|
||||
team ¤t_team = teams()[side_num - 1];
|
||||
team ¤t_team = board().get_team(side_num);
|
||||
|
||||
std::vector<unit_const_ptr> recall_list_team;
|
||||
{ wb::future_map future; // ensures recall list has planned recalls removed
|
||||
|
@ -420,7 +420,7 @@ void menu_handler::show_enemy_moves(bool ignore_units, int side_num)
|
|||
for(unit_map::iterator u = units().begin(); u != units().end(); ++u) {
|
||||
bool invisible = u->invisible(u->get_location(), gui_->get_disp_context());
|
||||
|
||||
if (teams()[side_num - 1].is_enemy(u->side()) &&
|
||||
if (board().get_team(side_num).is_enemy(u->side()) &&
|
||||
!gui_->fogged(u->get_location()) && !u->incapacitated() && !invisible)
|
||||
{
|
||||
const unit_movement_resetter move_reset(*u);
|
||||
|
@ -434,7 +434,7 @@ void menu_handler::show_enemy_moves(bool ignore_units, int side_num)
|
|||
|
||||
void menu_handler::toggle_shroud_updates(int side_num)
|
||||
{
|
||||
team ¤t_team = teams()[side_num - 1];
|
||||
team ¤t_team = board().get_team(side_num);
|
||||
bool auto_shroud = current_team.auto_shroud_updates();
|
||||
// If we're turning automatic shroud updates on, then commit all moves
|
||||
if (!auto_shroud) update_shroud_now(side_num);
|
||||
|
@ -769,7 +769,7 @@ void menu_handler::move_unit_to_loc(const unit_map::iterator &ui,
|
|||
{
|
||||
assert(ui != units().end());
|
||||
|
||||
pathfind::marked_route route = mousehandler.get_route(&*ui, target, teams()[side_num - 1]);
|
||||
pathfind::marked_route route = mousehandler.get_route(&*ui, target, board().get_team(side_num));
|
||||
|
||||
if(route.steps.empty())
|
||||
return;
|
||||
|
@ -819,7 +819,7 @@ void menu_handler::execute_gotos(mouse_handler &mousehandler, int side)
|
|||
if(fully_moved.count(current_loc))
|
||||
continue;
|
||||
|
||||
pathfind::marked_route route = mousehandler.get_route(&*ui, goto_loc, teams()[side - 1]);
|
||||
pathfind::marked_route route = mousehandler.get_route(&*ui, goto_loc, board().get_team(side));
|
||||
|
||||
if(route.steps.size() <= 1) { // invalid path
|
||||
fully_moved.insert(current_loc);
|
||||
|
@ -1341,23 +1341,23 @@ void console_handler::do_droid() {
|
|||
symbols["side"] = side_s;
|
||||
command_failed(vgettext("Can't droid invalid side: '$side'.", symbols));
|
||||
return;
|
||||
} else if (menu_handler_.teams()[side - 1].is_network()) {
|
||||
} else if (menu_handler_.board().get_team(side).is_network()) {
|
||||
utils::string_map symbols;
|
||||
symbols["side"] = std::to_string(side);
|
||||
command_failed(vgettext("Can't droid networked side: '$side'.", symbols));
|
||||
return;
|
||||
} else if (menu_handler_.teams()[side - 1].is_local_human()) {
|
||||
if (menu_handler_.teams()[side - 1].is_droid() ? action == " on" : action == " off") {
|
||||
} else if (menu_handler_.board().get_team(side).is_local_human()) {
|
||||
if (menu_handler_.board().get_team(side).is_droid() ? action == " on" : action == " off") {
|
||||
return;
|
||||
}
|
||||
menu_handler_.teams()[side - 1].toggle_droid();
|
||||
menu_handler_.board().get_team(side).toggle_droid();
|
||||
if(team_num_ == side) {
|
||||
if(playsingle_controller* psc = dynamic_cast<playsingle_controller*>(&menu_handler_.pc_)) {
|
||||
psc->set_player_type_changed();
|
||||
}
|
||||
}
|
||||
} else if (menu_handler_.teams()[side - 1].is_local_ai()) {
|
||||
// menu_handler_.teams()[side - 1].make_human();
|
||||
} else if (menu_handler_.board().get_team(side).is_local_ai()) {
|
||||
// menu_handler_.board().get_team(side).make_human();
|
||||
// menu_handler_.change_controller(std::to_string(side),"human");
|
||||
|
||||
utils::string_map symbols;
|
||||
|
@ -1380,22 +1380,22 @@ void console_handler::do_idle() {
|
|||
symbols["side"] = side_s;
|
||||
command_failed(vgettext("Can't idle invalid side: '$side'.", symbols));
|
||||
return;
|
||||
} else if (menu_handler_.teams()[side - 1].is_network()) {
|
||||
} else if (menu_handler_.board().get_team(side).is_network()) {
|
||||
utils::string_map symbols;
|
||||
symbols["side"] = std::to_string(side);
|
||||
command_failed(vgettext("Can't idle networked side: '$side'.", symbols));
|
||||
return;
|
||||
} else if (menu_handler_.teams()[side - 1].is_local_ai()) {
|
||||
} else if (menu_handler_.board().get_team(side).is_local_ai()) {
|
||||
utils::string_map symbols;
|
||||
symbols["side"] = std::to_string(side);
|
||||
command_failed(vgettext("Can't idle local ai side: '$side'.", symbols));
|
||||
return;
|
||||
} else if (menu_handler_.teams()[side - 1].is_local_human()) {
|
||||
if (menu_handler_.teams()[side - 1].is_idle() ? action == " on" : action == " off") {
|
||||
} else if (menu_handler_.board().get_team(side).is_local_human()) {
|
||||
if (menu_handler_.board().get_team(side).is_idle() ? action == " on" : action == " off") {
|
||||
return;
|
||||
}
|
||||
//toggle the proxy controller between idle / non idle
|
||||
menu_handler_.teams()[side - 1].toggle_idle();
|
||||
menu_handler_.board().get_team(side).toggle_idle();
|
||||
if(team_num_ == side) {
|
||||
if(playsingle_controller* psc = dynamic_cast<playsingle_controller*>(&menu_handler_.pc_)) {
|
||||
psc->set_player_type_changed();
|
||||
|
@ -1472,11 +1472,11 @@ void console_handler::do_controller()
|
|||
return;
|
||||
}
|
||||
|
||||
std::string report = menu_handler_.teams()[side_num - 1].controller().to_string();
|
||||
if (!menu_handler_.teams()[side_num - 1].is_proxy_human()) {
|
||||
report += " (" + menu_handler_.teams()[side_num - 1].proxy_controller().to_string() + ")";
|
||||
std::string report = menu_handler_.board().get_team(side_num).controller().to_string();
|
||||
if (!menu_handler_.board().get_team(side_num).is_proxy_human()) {
|
||||
report += " (" + menu_handler_.board().get_team(side_num).proxy_controller().to_string() + ")";
|
||||
}
|
||||
if (menu_handler_.teams()[side_num - 1].is_network()) {
|
||||
if (menu_handler_.board().get_team(side_num).is_network()) {
|
||||
report += " (networked)";
|
||||
}
|
||||
|
||||
|
@ -1806,7 +1806,7 @@ void menu_handler::user_command()
|
|||
void menu_handler::request_control_change ( int side_num, const std::string& player )
|
||||
{
|
||||
std::string side = std::to_string(side_num);
|
||||
if (teams()[side_num - 1].is_local_human() && player == preferences::login()) {
|
||||
if (board().get_team(side_num).is_local_human() && player == preferences::login()) {
|
||||
//this is already our side.
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -202,7 +202,7 @@ static config unit_side(reports::context & rc, const unit* u)
|
|||
if (!u) return config();
|
||||
|
||||
config report;
|
||||
const team &u_team = rc.teams()[u->side() - 1];
|
||||
const team &u_team = rc.dc().get_team(u->side());
|
||||
std::string flag_icon = u_team.flag_icon();
|
||||
std::string old_rgb = game_config::flag_rgb;
|
||||
std::string new_rgb = u_team.color();
|
||||
|
@ -753,7 +753,7 @@ static int attack_info(reports::context & rc, const attack_type &at, config &res
|
|||
// We want weak resistances (= good damage) first.
|
||||
std::map<int, std::set<std::string>, std::greater<int> > resistances;
|
||||
std::set<std::string> seen_types;
|
||||
const team &unit_team = rc.teams()[u.side() - 1];
|
||||
const team &unit_team = rc.dc().get_team(u.side());
|
||||
const team &viewing_team = rc.teams()[rc.screen().viewing_team()];
|
||||
for (const unit &enemy : rc.units())
|
||||
{
|
||||
|
@ -1222,7 +1222,7 @@ REPORT_GENERATOR(gold, rc)
|
|||
std::ostringstream str;
|
||||
int viewing_side = rc.screen().viewing_side();
|
||||
// Suppose the full unit map is applied.
|
||||
int fake_gold = rc.teams()[viewing_side - 1].gold();
|
||||
int fake_gold = rc.dc().get_team(viewing_side).gold();
|
||||
|
||||
if (rc.wb())
|
||||
fake_gold -= rc.wb()->get_spent_gold_for(viewing_side);
|
||||
|
@ -1244,7 +1244,7 @@ REPORT_GENERATOR(villages, rc)
|
|||
{
|
||||
std::ostringstream str;
|
||||
int viewing_side = rc.screen().viewing_side();
|
||||
const team &viewing_team = rc.teams()[viewing_side - 1];
|
||||
const team &viewing_team = rc.dc().get_team(viewing_side);
|
||||
team_data td = rc.dc().calculate_team_data(viewing_team);
|
||||
str << td.villages << '/';
|
||||
if (viewing_team.uses_shroud()) {
|
||||
|
@ -1269,7 +1269,7 @@ REPORT_GENERATOR(upkeep, rc)
|
|||
{
|
||||
std::ostringstream str;
|
||||
int viewing_side = rc.screen().viewing_side();
|
||||
const team &viewing_team = rc.teams()[viewing_side - 1];
|
||||
const team &viewing_team = rc.dc().get_team(viewing_side);
|
||||
team_data td = rc.dc().calculate_team_data(viewing_team);
|
||||
str << td.expenses << " (" << td.upkeep << ")";
|
||||
return gray_inactive(rc,str.str());
|
||||
|
@ -1278,7 +1278,7 @@ REPORT_GENERATOR(upkeep, rc)
|
|||
REPORT_GENERATOR(expenses, rc)
|
||||
{
|
||||
int viewing_side = rc.screen().viewing_side();
|
||||
const team &viewing_team = rc.teams()[viewing_side - 1];
|
||||
const team &viewing_team = rc.dc().get_team(viewing_side);
|
||||
team_data td = rc.dc().calculate_team_data(viewing_team);
|
||||
return gray_inactive(rc,std::to_string(td.expenses));
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ REPORT_GENERATOR(income, rc)
|
|||
{
|
||||
std::ostringstream str;
|
||||
int viewing_side = rc.screen().viewing_side();
|
||||
const team &viewing_team = rc.teams()[viewing_side - 1];
|
||||
const team &viewing_team = rc.dc().get_team(viewing_side);
|
||||
team_data td = rc.dc().calculate_team_data(viewing_team);
|
||||
char const *end = naps;
|
||||
if (viewing_side != rc.screen().playing_side()) {
|
||||
|
@ -1371,7 +1371,7 @@ REPORT_GENERATOR(terrain, rc)
|
|||
{
|
||||
const gamemap &map = rc.map();
|
||||
int viewing_side = rc.screen().viewing_side();
|
||||
const team &viewing_team = rc.teams()[viewing_side - 1];
|
||||
const team &viewing_team = rc.dc().get_team(viewing_side);
|
||||
map_location mouseover_hex = rc.screen().mouseover_hex();
|
||||
if (!map.on_board(mouseover_hex) || viewing_team.shrouded(mouseover_hex))
|
||||
return config();
|
||||
|
@ -1523,7 +1523,7 @@ REPORT_GENERATOR(report_clock, /*rc*/)
|
|||
REPORT_GENERATOR(report_countdown, rc)
|
||||
{
|
||||
int viewing_side = rc.screen().viewing_side();
|
||||
const team &viewing_team = rc.teams()[viewing_side - 1];
|
||||
const team &viewing_team = rc.dc().get_team(viewing_side);
|
||||
int min, sec;
|
||||
if (viewing_team.countdown_time() == 0)
|
||||
return report_report_clock(rc);
|
||||
|
|
|
@ -840,7 +840,7 @@ int game_lua_kernel::intf_shroud_op(lua_State *L, bool place_shroud)
|
|||
if(lua_isstring(L, 2)) {
|
||||
std::string data = lua_tostring(L, 2);
|
||||
// Special case - using a shroud_data string, or "all"
|
||||
team& side = teams()[side_num - 1];
|
||||
team& side = board().get_team(side_num);
|
||||
if(place_shroud) {
|
||||
side.reshroud();
|
||||
}
|
||||
|
@ -856,7 +856,7 @@ int game_lua_kernel::intf_shroud_op(lua_State *L, bool place_shroud)
|
|||
} else if(lua_istable(L, 2)) {
|
||||
std::vector<map_location> locs_v = lua_check<std::vector<map_location>>(L, 2);
|
||||
std::set<map_location> locs(locs_v.begin(), locs_v.end());
|
||||
team &t = teams()[side_num - 1];
|
||||
team &t = board().get_team(side_num);
|
||||
|
||||
for (map_location const &loc : locs)
|
||||
{
|
||||
|
@ -1119,15 +1119,15 @@ int game_lua_kernel::intf_set_village_owner(lua_State *L)
|
|||
|
||||
int old_side = board().village_owner(loc) + 1;
|
||||
|
||||
if (new_side == old_side || new_side < 0 || new_side > static_cast<int>(teams().size()) || board().team_is_defeated(teams()[new_side - 1])) {
|
||||
if (new_side == old_side || new_side < 0 || new_side > static_cast<int>(teams().size()) || board().team_is_defeated(board().get_team(new_side))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (old_side) {
|
||||
teams()[old_side - 1].lose_village(loc);
|
||||
board().get_team(old_side).lose_village(loc);
|
||||
}
|
||||
if (new_side) {
|
||||
teams()[new_side - 1].get_village(loc, old_side, (luaW_toboolean(L, 4) ? &gamedata() : nullptr) );
|
||||
board().get_team(new_side).get_village(loc, old_side, (luaW_toboolean(L, 4) ? &gamedata() : nullptr) );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -2091,7 +2091,7 @@ int game_lua_kernel::intf_erase_unit(lua_State *L)
|
|||
return luaL_argerror(L, 1, "invalid location");
|
||||
}
|
||||
} else if (int side = u.on_recall_list()) {
|
||||
team &t = teams()[side - 1];
|
||||
team &t = board().get_team(side);
|
||||
// Should it use underlying ID instead?
|
||||
t.recall_list().erase_if_matches_id(u->id());
|
||||
} else {
|
||||
|
@ -2148,7 +2148,7 @@ int game_lua_kernel::intf_put_recall_unit(lua_State *L)
|
|||
} else {
|
||||
u->set_side(side);
|
||||
}
|
||||
team &t = teams()[side - 1];
|
||||
team &t = board().get_team(side);
|
||||
// Avoid duplicates in the recall list.
|
||||
size_t uid = u->underlying_id();
|
||||
t.recall_list().erase_by_underlying_id(uid);
|
||||
|
@ -2180,7 +2180,7 @@ int game_lua_kernel::intf_extract_unit(lua_State *L)
|
|||
assert(u);
|
||||
u->anim_comp().clear_haloes();
|
||||
} else if (int side = lu->on_recall_list()) {
|
||||
team &t = teams()[side - 1];
|
||||
team &t = board().get_team(side);
|
||||
unit_ptr v = unit_ptr(new unit(*u));
|
||||
t.recall_list().erase_if_matches_id(u->id());
|
||||
u = v;
|
||||
|
@ -2984,7 +2984,7 @@ int game_lua_kernel::intf_get_sides(lua_State* L)
|
|||
lua_createtable(L, sides.size(), 0);
|
||||
unsigned index = 1;
|
||||
for(int side : sides) {
|
||||
luaW_pushteam(L, teams()[side - 1]);
|
||||
luaW_pushteam(L, board().get_team(side));
|
||||
lua_rawseti(L, -2, index);
|
||||
++index;
|
||||
}
|
||||
|
@ -3969,7 +3969,7 @@ int game_lua_kernel::intf_get_fog_or_shroud(lua_State *L, bool fog)
|
|||
return luaL_argerror(L, 1, error.c_str());
|
||||
}
|
||||
|
||||
team& t = teams()[side - 1];
|
||||
team& t = board().get_team(side);
|
||||
lua_pushboolean(L, fog ? t.fogged(loc) : t.shrouded(loc));
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue