Remove the map parameter from the unit::is_visible_to_team() function

Now when the function receives the entire display_context and can get the
map from there, passing the map separately is unnecessary.
This commit is contained in:
Jyrki Vesterinen 2016-08-28 11:48:01 +03:00
parent 7573678201
commit e82fc498ac
10 changed files with 15 additions and 15 deletions

View file

@ -86,7 +86,7 @@ const std::set<std::string> get_recruits(int side, const map_location &recruit_l
local_result.insert(find_it->recruits().begin(),
find_it->recruits().end());
}
else if ( find_it->is_visible_to_team(current_team, resources::gameboard->map(), *resources::gameboard, false) )
else if ( find_it->is_visible_to_team(current_team, *resources::gameboard, false) )
{
// This hex is visibly occupied, so we cannot recruit here.
allow_local = false;
@ -187,7 +187,7 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo
add_leader_filtered_recalls(find_it.get_shared_ptr(), result);
return result;
}
else if ( find_it->is_visible_to_team(resources::gameboard->teams()[side-1], resources::gameboard->map(), *resources::gameboard, false) )
else if ( find_it->is_visible_to_team(resources::gameboard->teams()[side-1], *resources::gameboard, false) )
{
// This hex is visibly occupied, so we cannot recall here.
allow_local = false;
@ -588,7 +588,7 @@ namespace { // Helpers for place_recruit()
for ( unit_itor = units.begin(); unit_itor != units.end(); ++unit_itor ) {
if (resources::gameboard->teams()[unit_itor->side()-1].is_enemy(new_unit.side()) &&
unit_itor->is_visible_to_team(resources::gameboard->teams()[new_unit.side()-1], *map, *resources::gameboard, false)) {
unit_itor->is_visible_to_team(resources::gameboard->teams()[new_unit.side()-1], *resources::gameboard, false)) {
int dist = distance_between(unit_itor->get_location(),recruit_loc) - unit_itor->level();
if (dist < min_dist) {
min_dist = dist;

View file

@ -351,7 +351,7 @@ void calculate_healing(int side, bool update_display)
const team & viewing_team =
resources::gameboard->teams()[resources::screen->viewing_team()];
if (!resources::controller->is_skipping_replay() && update_display &&
patient.is_visible_to_team(viewing_team, resources::gameboard->map(), *resources::gameboard, false) )
patient.is_visible_to_team(viewing_team, *resources::gameboard, false) )
{
unit_list.push_front(heal_unit(patient, healers, healing, curing == POISON_CURE));
}

View file

@ -600,7 +600,7 @@ std::vector<int> get_sides_not_seeing(const unit & target)
size_t team_size = teams.size();
for ( size_t i = 0; i != team_size; ++i)
if ( !target.is_visible_to_team(teams[i], resources::gameboard->map(), *resources::gameboard, false) )
if ( !target.is_visible_to_team(teams[i], *resources::gameboard, false) )
// not_see contains side numbers; i is a team index, so add 1.
not_seeing.push_back(i+1);
@ -646,7 +646,7 @@ bool actor_sighted(const unit & target, const std::vector<int> * cache)
needs_event[target.side()-1] = false;
// Exclude those teams that cannot see the target.
for ( size_t i = 0; i != teams_size; ++i )
needs_event[i] = needs_event[i] && target.is_visible_to_team(teams[i], resources::gameboard->map(), *resources::gameboard, false);
needs_event[i] = needs_event[i] && target.is_visible_to_team(teams[i], *resources::gameboard, false);
// Cache "jamming".
std::vector< std::map<map_location, int> > jamming_cache(teams_size);

View file

@ -58,7 +58,7 @@ const unit * display_context::get_visible_unit(const map_location & loc, const t
{
if (!map().on_board(loc)) return nullptr;
const unit_map::const_iterator u = units().find(loc);
if (!u.valid() || !u->is_visible_to_team(current_team, map(), *this, see_all)) {
if (!u.valid() || !u->is_visible_to_team(current_team, *this, see_all)) {
return nullptr;
}
return &*u;

View file

@ -175,7 +175,7 @@ unit_map::iterator game_board::find_visible_unit(const map_location &loc,
{
if (!map_->on_board(loc)) return units_.end();
unit_map::iterator u = units_.find(loc);
if (!u.valid() || !u->is_visible_to_team(current_team, *map_, *this, see_all))
if (!u.valid() || !u->is_visible_to_team(current_team, *this, see_all))
return units_.end();
return u;
}
@ -184,7 +184,7 @@ bool game_board::has_visible_unit(const map_location & loc, const team& current_
{
if (!map_->on_board(loc)) return false;
unit_map::const_iterator u = units_.find(loc);
if (!u.valid() || !u->is_visible_to_team(current_team, *map_, *this, see_all))
if (!u.valid() || !u->is_visible_to_team(current_team, *this, see_all))
return false;
return true;
}

View file

@ -1097,7 +1097,7 @@ void mouse_handler::show_attack_options(const unit_map::const_iterator &u)
// (Visible to current team, not necessarily the unit's team.)
if (!pc_.get_map_const().on_board(loc)) continue;
unit_map::const_iterator i = pc_.gamestate().board_.units().find(loc);
if ( !i || !i->is_visible_to_team(cur_team, pc_.gamestate().board_.map(), gui_->get_disp_context(), false) )
if ( !i || !i->is_visible_to_team(cur_team, gui_->get_disp_context(), false) )
continue;
const unit &target = *i;
// Can only attack non-petrified enemies.

View file

@ -76,7 +76,7 @@ void unit_drawer::redraw_unit (const unit & u) const
std::string ellipse=u.image_ellipse();
if ( hidden || is_blindfolded || !u.is_visible_to_team(viewing_team_ref, map, dc, show_everything) )
if ( hidden || is_blindfolded || !u.is_visible_to_team(viewing_team_ref, dc, show_everything) )
{
ac.clear_haloes();
if(ac.anim_) {

View file

@ -2322,10 +2322,10 @@ bool unit::invisible(const map_location& loc, const display_context& dc, bool se
}
bool unit::is_visible_to_team(team const& team, gamemap const& map, display_context const& dc, bool const see_all) const
bool unit::is_visible_to_team(team const& team, display_context const& dc, bool const see_all) const
{
map_location const& loc = get_location();
if (!map.on_board(loc))
if (!dc.map().on_board(loc))
return false;
if (see_all)
return true;

View file

@ -392,7 +392,7 @@ public:
// Only see_all=true use caching
bool invisible(const map_location& loc, const display_context& dc, bool see_all = true) const;
bool is_visible_to_team(team const& team, gamemap const& map , display_context const& dc, bool const see_all = true) const;
bool is_visible_to_team(team const& team, display_context const& dc, bool const see_all = true) const;
/** Mark this unit as clone so it can be inserted to unit_map
* @returns self (for convenience)

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()], resources::gameboard->map(), *resources::gameboard, false)) {
if(!on_current_side && !u.is_visible_to_team(resources::gameboard->teams()[viewer_team()], *resources::gameboard, false)) {
removers_.push_back(new temporary_unit_remover(*resources::units, u.get_location()));
//Don't do anything else to the removed unit!