Display: add back [viewing|playing]_team as actual team reference getters

Cleaned up redundant getters in other classes that served the same purpose.
This commit is contained in:
Charles Dang 2024-08-31 20:13:56 -04:00
parent 58472054fb
commit 0940b7451b
20 changed files with 71 additions and 79 deletions

View file

@ -319,7 +319,7 @@ void display::reinit_flags_for_team(const team& t)
texture display::get_flag(const map_location& loc)
{
for(const team& t : dc_->teams()) {
if(t.owns_village(loc) && (!fogged(loc) || !dc_->get_team(viewing_side()).is_enemy(t.side()))) {
if(t.owns_village(loc) && (!fogged(loc) || !viewing_team().is_enemy(t.side()))) {
auto& flag = flags_[t.side() - 1];
flag.update_last_draw_time();
@ -334,6 +334,16 @@ texture display::get_flag(const map_location& loc)
return texture();
}
const team& display::playing_team() const
{
return dc_->teams()[playing_team_index()];
}
const team& display::viewing_team() const
{
return dc_->teams()[viewing_team_index()];
}
void display::set_team(std::size_t teamindex, bool show_everything)
{
assert(teamindex < dc_->teams().size());
@ -2821,7 +2831,7 @@ void display::draw_overlays_at(const map_location& loc)
if(dont_show_all_ && !ov.team_name.empty()) {
// dont_show_all_ imples that viewing_team() is a valid index to get_teams()
const std::string& current_team_name = get_teams()[viewing_team_index()].team_name();
const std::string& current_team_name = viewing_team().team_name();
const std::vector<std::string>& current_team_names = utils::split(current_team_name);
const std::vector<std::string>& team_names = utils::split(ov.team_name);

View file

@ -121,6 +121,9 @@ public:
*/
std::size_t viewing_team_index() const { return currentTeam_; }
const team& playing_team() const;
const team& viewing_team() const;
/**
* The 1-based equivalent of the 0-based viewing_team_index() function. This is the side-number that
* WML uses.

View file

@ -118,12 +118,12 @@ void game_display::highlight_hex(map_location hex)
{
wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
const unit *u = dc_->get_visible_unit(hex, dc_->teams()[viewing_team_index()], !dont_show_all_);
const unit *u = dc_->get_visible_unit(hex, viewing_team(), !dont_show_all_);
if (u) {
displayedUnitHex_ = hex;
invalidate_unit();
} else {
u = dc_->get_visible_unit(mouseoverHex_, dc_->teams()[viewing_team_index()], !dont_show_all_);
u = dc_->get_visible_unit(mouseoverHex_, viewing_team(), !dont_show_all_);
if (u) {
// mouse moved from unit hex to non-unit hex
if (dc_->units().count(selectedHex_)) {
@ -145,7 +145,7 @@ void game_display::display_unit_hex(map_location hex)
wb::future_map_if future(!synced_context::is_synced()); /**< Lasts for whole method. */
const unit *u = dc_->get_visible_unit(hex, dc_->teams()[viewing_team_index()], !dont_show_all_);
const unit *u = dc_->get_visible_unit(hex, viewing_team(), !dont_show_all_);
if (u) {
displayedUnitHex_ = hex;
invalidate_unit();
@ -240,7 +240,7 @@ void game_display::draw_hex(const map_location& loc)
if(on_map && loc == mouseoverHex_ && !map_screenshot_) {
drawing_layer hex_top_layer = drawing_layer::mouseover_bottom;
const unit* u = dc_->get_visible_unit(loc, dc_->teams()[viewing_team_index()]);
const unit* u = dc_->get_visible_unit(loc, viewing_team());
if(u != nullptr) {
hex_top_layer = drawing_layer::mouseover_top;
}

View file

@ -72,7 +72,6 @@ const game_state & play_controller::hotkey_handler::gamestate() const {
bool play_controller::hotkey_handler::browse() const { return play_controller_.is_browsing(); }
bool play_controller::hotkey_handler::linger() const { return play_controller_.is_linger_mode(); }
const team & play_controller::hotkey_handler::viewing_team() const { return play_controller_.get_teams()[gui()->viewing_team_index()]; }
bool play_controller::hotkey_handler::viewing_team_is_playing() const { return gui()->viewing_team_index() == gui()->playing_team_index(); }
void play_controller::hotkey_handler::objectives(){
@ -556,7 +555,7 @@ hotkey::ACTION_STATE play_controller::hotkey_handler::get_action_state(const hot
case hotkey::HOTKEY_ZOOM_DEFAULT:
return (gui()->get_zoom_factor() == 1.0) ? hotkey::ACTION_ON : hotkey::ACTION_OFF;
case hotkey::HOTKEY_DELAY_SHROUD:
return viewing_team().auto_shroud_updates() ? hotkey::ACTION_OFF : hotkey::ACTION_ON;
return gui()->viewing_team().auto_shroud_updates() ? hotkey::ACTION_OFF : hotkey::ACTION_ON;
default:
return hotkey::ACTION_STATELESS;
}

View file

@ -70,7 +70,6 @@ protected:
bool browse() const;
bool linger() const;
const team & viewing_team() const;
bool viewing_team_is_playing() const;
public:

View file

@ -237,16 +237,16 @@ bool playsingle_controller::hotkey_handler::can_execute_command(const hotkey::ui
case hotkey::HOTKEY_DELAY_SHROUD:
return !linger()
&& (viewing_team().uses_fog() || viewing_team().uses_shroud())
&& (gui()->viewing_team().uses_fog() || gui()->viewing_team().uses_shroud())
&& viewing_team_is_playing()
&& viewing_team().is_local_human()
&& gui()->viewing_team().is_local_human()
&& !events::commands_disabled;
case hotkey::HOTKEY_UPDATE_SHROUD:
return !linger()
&& viewing_team_is_playing()
&& viewing_team().is_local_human()
&& gui()->viewing_team().is_local_human()
&& !events::commands_disabled
&& viewing_team().auto_shroud_updates() == false;
&& gui()->viewing_team().auto_shroud_updates() == false;
// Commands we can only do if in debug mode
case hotkey::HOTKEY_CREATE_UNIT:

View file

@ -223,7 +223,7 @@ bool menu_handler::has_friends() const
}
for(std::size_t n = 0; n != pc_.get_teams().size(); ++n) {
if(n != gui_->viewing_team_index() && pc_.get_teams()[gui_->viewing_team_index()].team_name() == pc_.get_teams()[n].team_name()
if(n != gui_->viewing_team_index() && gui_->viewing_team().team_name() == pc_.get_teams()[n].team_name()
&& pc_.get_teams()[n].is_network()) {
return true;
}
@ -471,7 +471,7 @@ void menu_handler::show_enemy_moves(bool ignore_units, int side_num)
&& !invisible) {
const unit_movement_resetter move_reset(u);
const pathfind::paths& path
= pathfind::paths(u, false, true, pc_.get_teams()[gui_->viewing_team_index()], 0, false, ignore_units);
= pathfind::paths(u, false, true, gui_->viewing_team(), 0, false, ignore_units);
gui_->highlight_another_reach(path, hex_under_mouse);
}
@ -669,12 +669,12 @@ unit_map::iterator menu_handler::current_unit()
const mouse_handler& mousehandler = pc_.get_mouse_handler_base();
const bool see_all = gui_->show_everything() || (pc_.is_replay() && pc_.get_replay_controller()->see_all());
unit_map::iterator res = board().find_visible_unit(mousehandler.get_last_hex(), pc_.get_teams()[gui_->viewing_team_index()], see_all);
unit_map::iterator res = board().find_visible_unit(mousehandler.get_last_hex(), gui_->viewing_team(), see_all);
if(res != pc_.get_units().end()) {
return res;
}
return board().find_visible_unit(mousehandler.get_selected_hex(), pc_.get_teams()[gui_->viewing_team_index()], see_all);
return board().find_visible_unit(mousehandler.get_selected_hex(), gui_->viewing_team(), see_all);
}
// Helpers for create_unit()
@ -1340,7 +1340,7 @@ void menu_handler::send_chat_message(const std::string& message, bool allies_onl
if(board().is_observer()) {
cfg["to_sides"] = game_config::observer_team_name;
} else {
cfg["to_sides"] = pc_.get_teams()[gui_->viewing_team_index()].allied_human_teams();
cfg["to_sides"] = gui_->viewing_team().allied_human_teams();
}
}
@ -1403,7 +1403,7 @@ void menu_handler::do_search(const std::string& new_search)
if(std::search(
name.begin(), name.end(), last_search_.begin(), last_search_.end(), utils::chars_equal_insensitive)
!= name.end()) {
if(!pc_.get_teams()[gui_->viewing_team_index()].is_enemy(ui->side())
if(!gui_->viewing_team().is_enemy(ui->side())
|| !ui->invisible(ui->get_location())) {
found = true;
}

View file

@ -306,7 +306,7 @@ void mouse_handler::touch_motion(int x, int y, const bool browse, bool update, m
{
if (selected_unit && !selected_unit->incapacitated()) {
// Show the route from selected unit to mouseover hex
current_route_ = get_route(&*selected_unit, dest, viewing_team());
current_route_ = get_route(&*selected_unit, dest, gui().viewing_team());
pc_.get_whiteboard()->create_temp_move();
@ -321,7 +321,7 @@ void mouse_handler::touch_motion(int x, int y, const bool browse, bool update, m
&& mouseover_unit.valid()
&& mouseover_unit) {
// Show the route from selected hex to mouseover unit
current_route_ = get_route(&*mouseover_unit, selected_hex_, viewing_team());
current_route_ = get_route(&*mouseover_unit, selected_hex_, gui().viewing_team());
pc_.get_whiteboard()->create_temp_move();
@ -351,7 +351,7 @@ void mouse_handler::show_reach_for_unit(const unit_ptr& un)
//
// Exception: allied AI sides' moves are still hidden, on the assumption that
// campaign authors won't want to leak goto_x,goto_y tricks to the player.
if(!viewing_team().is_enemy(un->side()) && !pc_.get_teams()[un->side() - 1].is_ai()) {
if(!gui().viewing_team().is_enemy(un->side()) && !pc_.get_teams()[un->side() - 1].is_ai()) {
//unit is on our team or an allied team, show path if the unit has one
const map_location go_to = un->get_goto();
if(pc_.get_map().on_board(go_to)) {
@ -379,7 +379,7 @@ void mouse_handler::show_reach_for_unit(const unit_ptr& un)
// state includes changes to units' movement.
wb::future_map_if_active raii;
current_paths_ = pathfind::paths(*un, false, true, viewing_team(), path_turns_);
current_paths_ = pathfind::paths(*un, false, true, gui().viewing_team(), path_turns_);
}
unselected_paths_ = true;
@ -551,7 +551,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update, m
} else if(!current_paths_.destinations.empty() && pc_.get_map().on_board(selected_hex_) && pc_.get_map().on_board(new_hex)) {
if(selected_unit && !selected_unit->incapacitated()) {
// Show the route from selected unit to mouseover hex
current_route_ = get_route(&*selected_unit, dest, viewing_team());
current_route_ = get_route(&*selected_unit, dest, gui().viewing_team());
pc_.get_whiteboard()->create_temp_move();
@ -563,7 +563,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse, bool update, m
if(pc_.get_map().on_board(selected_hex_) && !selected_unit && mouseover_unit.valid() && mouseover_unit) {
// Show the route from selected hex to mouseover unit
current_route_ = get_route(&*mouseover_unit, selected_hex_, viewing_team());
current_route_ = get_route(&*mouseover_unit, selected_hex_, gui().viewing_team());
pc_.get_whiteboard()->create_temp_move();
@ -648,7 +648,7 @@ unit_map::iterator mouse_handler::selected_unit()
unit_map::iterator mouse_handler::find_unit(const map_location& hex)
{
unit_map::iterator it = pc_.gamestate().board_.find_visible_unit(hex, viewing_team());
unit_map::iterator it = pc_.gamestate().board_.find_visible_unit(hex, gui().viewing_team());
if(it.valid()) {
return it;
}
@ -658,18 +658,18 @@ unit_map::iterator mouse_handler::find_unit(const map_location& hex)
unit_map::const_iterator mouse_handler::find_unit(const map_location& hex) const
{
return pc_.gamestate().board_.find_visible_unit(hex, viewing_team());
return pc_.gamestate().board_.find_visible_unit(hex, gui().viewing_team());
}
unit* mouse_handler::find_unit_nonowning(const map_location& hex)
{
unit_map::iterator it = pc_.gamestate().board_.find_visible_unit(hex, viewing_team());
unit_map::iterator it = pc_.gamestate().board_.find_visible_unit(hex, gui().viewing_team());
return it.valid() ? &*it : nullptr;
}
const unit* mouse_handler::find_unit_nonowning(const map_location& hex) const
{
unit_map::const_iterator it = pc_.gamestate().board_.find_visible_unit(hex, viewing_team());
unit_map::const_iterator it = pc_.gamestate().board_.find_visible_unit(hex, gui().viewing_team());
return it.valid() ? &*it : nullptr;
}
@ -729,7 +729,7 @@ map_location mouse_handler::current_unit_attacks_from(const map_location& loc) c
// Check the unit TARGET of the attack
const team& viewer = viewing_team();
const team& viewer = gui().viewing_team();
// Check that there's a unit at the target location
const unit_map::const_iterator target_unit = find_unit(loc);
@ -795,14 +795,14 @@ map_location mouse_handler::current_unit_attacks_from(const map_location& loc) c
return res;
}
pathfind::marked_route mouse_handler::get_route(const unit* un, map_location go_to, team& team) const
pathfind::marked_route mouse_handler::get_route(const unit* un, map_location go_to, const team& team) const
{
game_board& board = pc_.gamestate().board_;
// The pathfinder will check unit visibility (fogged/stealthy).
const pathfind::shortest_path_calculator calc(*un, team, board.teams(), board.map());
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*un, viewing_team());
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*un, gui().viewing_team());
pathfind::plain_route route;
@ -1114,7 +1114,7 @@ void mouse_handler::select_hex(const map_location& hex, const bool browse, const
next_unit_ = unit->get_location();
{
current_paths_ = pathfind::paths(*unit, false, true, viewing_team(), path_turns_);
current_paths_ = pathfind::paths(*unit, false, true, gui().viewing_team(), path_turns_);
}
if(highlight) {
@ -1162,7 +1162,7 @@ void mouse_handler::select_hex(const map_location& hex, const bool browse, const
if(!gui_->fogged(u->get_location()) && !u->incapacitated() && !invisible) {
const pathfind::paths& path =
pathfind::paths(*u, false, true, viewing_team(), path_turns_, false, false);
pathfind::paths(*u, false, true, gui().viewing_team(), path_turns_, false, false);
if(path.destinations.find(hex) != path.destinations.end()) {
reaching_unit_locations.destinations.insert(u->get_location());
@ -1580,16 +1580,6 @@ void mouse_handler::set_current_paths(const pathfind::paths& new_paths)
pc_.get_whiteboard()->erase_temp_move();
}
team& mouse_handler::viewing_team()
{
return pc_.get_teams()[gui().viewing_team_index()];
}
const team& mouse_handler::viewing_team() const
{
return pc_.get_teams()[gui().viewing_team_index()];
}
team& mouse_handler::current_team()
{
return pc_.get_teams()[side_num_ - 1];

View file

@ -62,7 +62,7 @@ public:
unit_map::iterator selected_unit();
pathfind::marked_route get_route(const unit* un, map_location go_to, team &team) const;
pathfind::marked_route get_route(const unit* un, map_location go_to, const team &team) const;
const pathfind::marked_route& get_current_route() const { return current_route_; }
@ -158,8 +158,6 @@ protected:
const unit* find_unit_nonowning(const map_location& hex) const;
bool unit_in_cycle(unit_map::const_iterator it);
private:
team& viewing_team();
const team& viewing_team() const;
team &current_team();
// Some common code from mouse_motion and touch_motion.

View file

@ -681,7 +681,7 @@ marked_route mark_route(const plain_route &rt, bool update_move_cost)
assert(last_step || resources::gameboard->map().on_board(*(i+1)));
const int move_cost = last_step ? 0 : u.movement_cost(static_cast<const game_board*>(resources::gameboard)->map()[*(i+1)]);
const team& viewing_team = resources::gameboard->teams()[display::get_singleton()->viewing_team_index()];
const team& viewing_team = display::get_singleton()->viewing_team();
if (last_step || zoc || move_cost > movement) {
// check if we stop an a village and so maybe capture it

View file

@ -699,7 +699,7 @@ void play_controller::tab()
case gui::TEXTBOX_SEARCH: {
for(const unit& u : get_units()) {
const map_location& loc = u.get_location();
if(!gui_->fogged(loc) && !(get_teams()[gui_->viewing_team_index()].is_enemy(u.side()) && u.invisible(loc)))
if(!gui_->fogged(loc) && !(gui_->viewing_team().is_enemy(u.side()) && u.invisible(loc)))
dictionary.insert(u.name());
}
// TODO List map labels
@ -836,7 +836,7 @@ void play_controller::process_keyup_event(const SDL_Event& event)
unit_movement_resetter move_reset(*u, u->side() != current_side());
mouse_handler_.set_current_paths(pathfind::paths(
*u, false, true, get_teams()[gui_->viewing_team_index()], mouse_handler_.get_path_turns()));
*u, false, true, gui_->viewing_team(), mouse_handler_.get_path_turns()));
gui_->highlight_reach(mouse_handler_.current_paths());
} else {
@ -1237,7 +1237,7 @@ void play_controller::check_next_scenario_is_known() {
bool play_controller::can_use_synced_wml_menu() const
{
const team& viewing_team = get_teams()[gui_->viewing_team_index()];
const team& viewing_team = gui_->viewing_team();
return gui_->viewing_team_index() == gui_->playing_team_index() && !events::commands_disabled && viewing_team.is_local_human()
&& !is_browsing();
}
@ -1300,7 +1300,7 @@ play_controller::scoped_savegame_snapshot::~scoped_savegame_snapshot()
void play_controller::show_objectives() const
{
const team& t = get_teams()[gui_->viewing_team_index()];
const team& t = gui_->viewing_team();
static const std::string no_objectives(_("No objectives available"));
std::string objectives = utils::interpolate_variables_into_string(t.objectives(), *gamestate_->get_game_data());
gui2::show_transient_message(get_scenario_name(), (objectives.empty() ? no_objectives : objectives), "", true);

View file

@ -747,7 +747,7 @@ void playsingle_controller::require_end_turn()
void playsingle_controller::check_objectives()
{
if(!get_teams().empty()) {
const team& t = get_teams()[gui_->viewing_team_index()];
const team& t = gui_->viewing_team();
if(!is_regular_game_end() && !is_browsing() && t.objectives_changed()) {
show_objectives();

View file

@ -95,7 +95,7 @@ static std::string flush(std::ostringstream &s)
static const time_of_day get_visible_time_of_day_at(const reports::context& rc, const map_location & hex)
{
const team &viewing_team = rc.teams()[rc.screen().viewing_team_index()];
const team &viewing_team = rc.screen().viewing_team();
if (viewing_team.shrouded(hex)) {
// Don't show time on shrouded tiles.
return rc.tod().get_time_of_day();
@ -128,21 +128,21 @@ static char const *naps = "</span>";
static const unit *get_visible_unit(const reports::context& rc)
{
return rc.dc().get_visible_unit(rc.screen().displayed_unit_hex(),
rc.teams()[rc.screen().viewing_team_index()],
rc.screen().viewing_team(),
rc.screen().show_everything());
}
static const unit *get_selected_unit(const reports::context& rc)
{
return rc.dc().get_visible_unit(rc.screen().selected_hex(),
rc.teams()[rc.screen().viewing_team_index()],
rc.screen().viewing_team(),
rc.screen().show_everything());
}
static unit_const_ptr get_selected_unit_ptr(const reports::context& rc)
{
return rc.dc().get_visible_unit_shared_ptr(rc.screen().selected_hex(),
rc.teams()[rc.screen().viewing_team_index()],
rc.screen().viewing_team(),
rc.screen().show_everything());
}
@ -448,7 +448,7 @@ static config unit_abilities(const unit* u, const map_location& loc)
REPORT_GENERATOR(unit_abilities, rc)
{
const unit *u = get_visible_unit(rc);
const team &viewing_team = rc.teams()[rc.screen().viewing_team_index()];
const team &viewing_team = rc.screen().viewing_team();
const map_location& mouseover_hex = rc.screen().mouseover_hex();
const map_location& displayed_unit_hex = rc.screen().displayed_unit_hex();
const map_location& hex = (mouseover_hex.valid() && !viewing_team.shrouded(mouseover_hex)) ? mouseover_hex : displayed_unit_hex;
@ -461,7 +461,7 @@ REPORT_GENERATOR(selected_unit_abilities, rc)
const map_location& mouseover_hex = rc.screen().mouseover_hex();
const unit *visible_unit = get_visible_unit(rc);
const team &viewing_team = rc.teams()[rc.screen().viewing_team_index()];
const team &viewing_team = rc.screen().viewing_team();
if (visible_unit && u && visible_unit->id() != u->id() && mouseover_hex.valid() && !viewing_team.shrouded(mouseover_hex))
return unit_abilities(u, mouseover_hex);
@ -615,7 +615,7 @@ static config unit_defense(const reports::context& rc, const unit* u, const map_
REPORT_GENERATOR(unit_defense,rc)
{
const unit *u = get_visible_unit(rc);
const team &viewing_team = rc.teams()[rc.screen().viewing_team_index()];
const team &viewing_team = rc.screen().viewing_team();
const map_location& mouseover_hex = rc.screen().mouseover_hex();
const map_location& displayed_unit_hex = rc.screen().displayed_unit_hex();
const map_location& hex = (mouseover_hex.valid() && !viewing_team.shrouded(mouseover_hex)) ? mouseover_hex : displayed_unit_hex;
@ -908,7 +908,7 @@ static int attack_info(const reports::context& rc, const attack_type &at, config
std::map<int, std::set<std::string>, std::greater<int>> resistances;
std::set<std::string> seen_types;
const team &unit_team = rc.dc().get_team(u.side());
const team &viewing_team = rc.teams()[rc.screen().viewing_team_index()];
const team &viewing_team = rc.screen().viewing_team();
for (const unit &enemy : rc.units())
{
if (enemy.incapacitated()) //we can't attack statues so don't display them in this tooltip
@ -1696,7 +1696,7 @@ REPORT_GENERATOR(position, rc)
str << mouseover_hex;
const unit *u = get_visible_unit(rc);
const team &viewing_team = rc.teams()[rc.screen().viewing_team_index()];
const team &viewing_team = rc.screen().viewing_team();
if (!u ||
(displayed_unit_hex != mouseover_hex &&
displayed_unit_hex != rc.screen().selected_hex()) ||
@ -1717,7 +1717,7 @@ REPORT_GENERATOR(position, rc)
REPORT_GENERATOR(side_playing, rc)
{
const team &active_team = rc.teams()[rc.screen().playing_team_index()];
const team &active_team = rc.screen().playing_team();
std::string flag_icon = active_team.flag_icon();
std::string old_rgb = game_config::flag_rgb;
std::string new_rgb = team::get_side_color_id(rc.screen().playing_side());

View file

@ -476,7 +476,7 @@ int game_lua_kernel::intf_get_displayed_unit(lua_State *L)
unit_map::const_iterator ui = board().find_visible_unit(
game_display_->displayed_unit_hex(),
teams()[game_display_->viewing_team_index()],
game_display_->viewing_team(),
game_display_->show_everything());
if (!ui.valid()) return 0;

View file

@ -386,8 +386,11 @@ void manager::update_plan_hiding(std::size_t team_index)
}
validate_viewer_actions();
}
void manager::update_plan_hiding()
{update_plan_hiding(viewer_team());}
{
update_plan_hiding(display::get_singleton()->viewing_team_index());
}
void manager::on_viewer_change(std::size_t team_index)
{

View file

@ -198,7 +198,7 @@ private:
void validate_actions_if_needed();
/** Called by all of the save_***() methods after they have added their action to the queue */
void update_plan_hiding(std::size_t viewing_team);
void update_plan_hiding(); //same as above, but uses wb::viewer_team() as default argument
void update_plan_hiding(); //same as above, but uses display::viewer_team_index() as default argument
/** Tracks whether the whiteboard is active. */
bool active_;

View file

@ -68,7 +68,7 @@ void mapbuilder::pre_build()
//Remove any unit the current side cannot see to avoid their detection by planning
//Units will be restored to the unit map by destruction of removers_
if(!on_current_side && !u.is_visible_to_team(resources::gameboard->teams()[viewer_team()], false)) {
if(!on_current_side && !u.is_visible_to_team(display::get_singleton()->viewing_team(), false)) {
removers_.emplace_back(new temporary_unit_remover(resources::gameboard->units(), u.get_location()));
//Don't do anything else to the removed unit!

View file

@ -478,7 +478,7 @@ action::error move::check_validity() const
}
//If the path has at least two hexes (it can have less with the attack subclass), ensure destination hex is free
if(get_route().steps.size() >= 2 && resources::gameboard->get_visible_unit(get_dest_hex(),resources::gameboard->teams().at(viewer_team())) != nullptr) {
if(get_route().steps.size() >= 2 && resources::gameboard->get_visible_unit(get_dest_hex(), display::get_singleton()->viewing_team()) != nullptr) {
return LOCATION_OCCUPIED;
}

View file

@ -34,12 +34,6 @@
#include "utils/iterable_pair.hpp"
namespace wb {
std::size_t viewer_team()
{
return display::get_singleton()->viewing_team_index();
}
int viewer_side()
{
return display::get_singleton()->viewing_side();
@ -47,8 +41,7 @@ int viewer_side()
side_actions_ptr viewer_actions()
{
side_actions_ptr side_actions =
resources::gameboard->teams()[display::get_singleton()->viewing_team_index()].get_side_actions();
side_actions_ptr side_actions = display::get_singleton()->viewing_team().get_side_actions();
return side_actions;
}

View file

@ -31,9 +31,6 @@ class team;
namespace wb {
/** @return The current viewing team's index */
std::size_t viewer_team();
/** @return The current viewing side's number (i.e. team index + 1) */
int viewer_side();