remove resources::game_map (part 2)

This the result of executing, in folder src/, the following

find . -type f -exec sed -i 's/\*resources\:\:game_map/resources\:\:gameboard->map()/g' '{}' \;

and carefully inspecting the result.

We also had to add game_board.hpp includes in various places,
and change the arguent order of unit::is_visible_to_team --
this function was taking *resources::game_map as its default
argument, and we do not want to include game_board in unit.hpp,
as it creates cyclic dependencies. This was resolved by
eliminating this as a default value -- this is an improvement,
since usually when this function was called it was in a context
where a game_map was available already locally anyways.
This commit is contained in:
Chris Beck 2014-06-10 20:53:00 -04:00
parent 4830b8ee3c
commit aab7edd88c
27 changed files with 80 additions and 78 deletions

View file

@ -267,7 +267,7 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
*/
bool can_recruit_from(const map_location& leader_loc, int side)
{
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
if( !map.is_keep(leader_loc) )
return false;
@ -294,7 +294,7 @@ bool can_recruit_from(const map_location& leader_loc, int side)
*/
bool can_recruit_on(const map_location& leader_loc, const map_location& recruit_loc, int side)
{
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
if( !map.is_castle(recruit_loc) )
return false;
@ -360,7 +360,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, false) )
else if ( find_it->is_visible_to_team(current_team, resources::gameboard->map(), false) )
{
// This hex is visibly occupied, so we cannot recruit here.
allow_local = false;
@ -459,7 +459,7 @@ const std::vector<const unit*> get_recalls(int side, const map_location &recall_
add_leader_filtered_recalls(*find_it, result);
return result;
}
else if ( find_it->is_visible_to_team((*resources::teams)[side-1], false) )
else if ( find_it->is_visible_to_team((*resources::teams)[side-1], resources::gameboard->map(), false) )
{
// This hex is visibly occupied, so we cannot recall here.
allow_local = false;
@ -852,7 +852,7 @@ namespace { // Helpers for place_recruit()
for ( unit_itor = units.begin(); unit_itor != units.end(); ++unit_itor ) {
if ((*resources::teams)[unit_itor->side()-1].is_enemy(new_unit.side()) &&
unit_itor->is_visible_to_team((*resources::teams)[new_unit.side()-1], false)) {
unit_itor->is_visible_to_team((*resources::teams)[new_unit.side()-1], resources::gameboard->map(), false)) {
int dist = distance_between(unit_itor->get_location(),recruit_loc) - unit_itor->level();
if (dist < min_dist) {
min_dist = dist;

View file

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

View file

@ -722,7 +722,7 @@ namespace { // Private helpers for move_unit()
unit_mover::route_iterator unit_mover::plot_turn(const route_iterator & start,
const route_iterator & stop)
{
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
// Handle null routes.
if ( start == stop )
@ -1311,7 +1311,7 @@ bool unit_can_move(const unit &u)
return true;
}
if (u.movement_cost((*resources::game_map)[locs[n]]) <= u.movement_left()) {
if (u.movement_cost((resources::gameboard->map())[locs[n]]) <= u.movement_left()) {
return true;
}
}

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], false) )
if ( !target.is_visible_to_team(teams[i], resources::gameboard->map(), 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], false);
needs_event[i] = needs_event[i] && target.is_visible_to_team(teams[i], resources::gameboard->map(), false);
// Cache "jamming".
std::vector< std::map<map_location, int> > jamming_cache(teams_size);

View file

@ -364,7 +364,7 @@ bool move_result::test_route(const unit &un)
}
team &my_team = get_my_team();
const pathfind::shortest_path_calculator calc(un, my_team, *resources::teams, *resources::game_map);
const pathfind::shortest_path_calculator calc(un, my_team, *resources::teams, resources::gameboard->map());
//allowed teleports
pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(un, my_team, true);///@todo 1.9: see_all -> false

View file

@ -288,7 +288,7 @@ struct protected_item {
class remove_wrong_targets {
public:
remove_wrong_targets(const readonly_context &context)
:avoid_(context.get_avoid()), map_(*resources::game_map)
:avoid_(context.get_avoid()), map_(resources::gameboard->map())
{
}
@ -532,7 +532,7 @@ ai_default_recruitment_stage::~ai_default_recruitment_stage()
void ai_default_recruitment_stage::analyze_potential_recruit_movements()
{
const unit_map &units_ = *resources::units;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
if(unit_movement_scores_.empty() == false ||
get_recruitment_ignore_bad_movement()) {

View file

@ -98,7 +98,7 @@ default_ai_context& default_ai_context_impl::get_default_ai_context(){
int default_ai_context_impl::rate_terrain(const unit& u, const map_location& loc) const
{
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
const t_translation::t_terrain terrain = map_.get_terrain(loc);
const int defense = u.defense_modifier(terrain);
int rating = 100 - defense;
@ -133,7 +133,7 @@ std::vector<target> default_ai_context_impl::find_targets(const move_map& enemy_
log_scope2(log_ai, "finding targets...");
unit_map &units_ = *resources::units;
unit_map::iterator leader = units_.find_leader(get_side());
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
std::vector<team> teams_ = *resources::teams;
const bool has_leader = leader != units_.end();

View file

@ -179,7 +179,7 @@ pathfind::plain_route formula_ai::shortest_path_calculator(const map_location &s
map_location destination = dst;
unit_map &units_ = *resources::units;
pathfind::shortest_path_calculator calc(*unit_it, current_team(), *resources::teams, *resources::game_map);
pathfind::shortest_path_calculator calc(*unit_it, current_team(), *resources::teams, resources::gameboard->map());
unit_map::const_iterator dst_un = units_.find(destination);
@ -822,7 +822,7 @@ variant formula_ai::get_value(const std::string& key) const
return get_keeps();
} else if(key == "map")
{
return variant(new gamemap_callable(*resources::game_map));
return variant(new gamemap_callable(resources::gameboard->map()));
} else if(key == "villages")
{
return villages_from_set(resources::gameboard->map().villages());

View file

@ -200,7 +200,7 @@ private:
{
const std::set<map_location>& teleports = allow_teleport ? ai_.current_team().villages() : std::set<map_location>();
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
std::vector<map_location> locs(6 + teleports.size());
std::copy(teleports.begin(), teleports.end(), locs.begin() + 6);
@ -296,7 +296,7 @@ private:
// for(unit_map::const_iterator i = resources::units->begin(); i != resources::units->end(); ++i) {
// unit_counter[i->second.side()-1]++;
// unit_adapter unit(i->second);
// find_movemap( *resources::game_map, *resources::units, unit, i->first, scores[i->second.side()-1], ai_.*resources::teams , true );
// find_movemap( resources::gameboard->map(), *resources::units, unit, i->first, scores[i->second.side()-1], ai_.*resources::teams , true );
// }
for(size_t side = 0 ; side < units_input.num_elements() ; ++side) {
@ -1145,7 +1145,7 @@ private:
pathfind::teleport_map allowed_teleports = ai_.get_allowed_teleports(unit_it);
pathfind::emergency_path_calculator em_calc(*unit_it, *resources::game_map);
pathfind::emergency_path_calculator em_calc(*unit_it, resources::gameboard->map());
pathfind::plain_route route = pathfind::a_star_search(src, dst, 1000.0, &em_calc, resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
@ -1154,7 +1154,7 @@ private:
}
for (std::vector<map_location>::const_iterator loc_iter = route.steps.begin() + 1 ; loc_iter !=route.steps.end(); ++loc_iter) {
if (unit_it->movement_cost((*resources::game_map)[*loc_iter]) < movetype::UNREACHABLE )
if (unit_it->movement_cost((resources::gameboard->map())[*loc_iter]) < movetype::UNREACHABLE )
locations.push_back( variant( new location_callable(*loc_iter) ));
else
break;
@ -1523,28 +1523,28 @@ private:
{
const unit& un = u_call->get_unit();
if( un.total_movement() < un.movement_cost( (*resources::game_map)[loc]) )
if( un.total_movement() < un.movement_cost( (resources::gameboard->map())[loc]) )
return variant();
if(!resources::gameboard->map().on_board(loc)) {
return variant();
}
return variant(100 - un.defense_modifier((*resources::game_map)[loc]));
return variant(100 - un.defense_modifier((resources::gameboard->map())[loc]));
}
if (u_type)
{
const unit_type& un = u_type->get_unit_type();
if( un.movement() < un.movement_type().movement_cost((*resources::game_map)[loc]) )
if( un.movement() < un.movement_type().movement_cost((resources::gameboard->map())[loc]) )
return variant();
if(!resources::gameboard->map().on_board(loc)) {
return variant();
}
return variant(100 - un.movement_type().defense_modifier((*resources::game_map)[loc]));
return variant(100 - un.movement_type().defense_modifier((resources::gameboard->map())[loc]));
}
return variant();
@ -1577,7 +1577,7 @@ private:
return variant();
}
return variant(un.defense_modifier((*resources::game_map)[loc]));
return variant(un.defense_modifier((resources::gameboard->map())[loc]));
}
if (u_type)
@ -1588,7 +1588,7 @@ private:
return variant();
}
return variant(un.movement_type().defense_modifier((*resources::game_map)[loc]));
return variant(un.movement_type().defense_modifier((resources::gameboard->map())[loc]));
}
return variant();
@ -1621,7 +1621,7 @@ private:
return variant();
}
return variant(un.movement_cost((*resources::game_map)[loc]));
return variant(un.movement_cost((resources::gameboard->map())[loc]));
}
if (u_type)
@ -1632,7 +1632,7 @@ private:
return variant();
}
return variant(un.movement_type().movement_cost((*resources::game_map)[loc]));
return variant(un.movement_type().movement_cost((resources::gameboard->map())[loc]));
}
return variant();

View file

@ -197,7 +197,7 @@ void recruitment::execute() {
*/
const unit_map& units = *resources::units;
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
const std::vector<unit_map::const_iterator> leaders = units.find_leaders(get_side());
// This is the central datastructure with all score_tables in it.
@ -600,7 +600,7 @@ void recruitment::compare_cost_maps_and_update_important_hexes(
const pathfind::full_cost_map& my_cost_map,
const pathfind::full_cost_map& enemy_cost_map) {
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
// First collect all hexes where the average costs are similar in important_hexes_candidates
// Then chose only those hexes where the average costs are relatively low.
@ -746,7 +746,7 @@ void recruitment::update_average_lawful_bonus() {
*/
void recruitment::update_average_local_cost() {
average_local_cost_.clear();
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
const team& team = (*resources::teams)[get_side() - 1];
for(int x = 0; x < map.w(); ++x) {
@ -780,7 +780,7 @@ void recruitment::update_important_hexes() {
own_units_in_combat_counter_ = 0;
update_average_local_cost();
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
const unit_map& units = *resources::units;
// Mark battle areas as important
@ -1442,7 +1442,7 @@ double recruitment::get_estimated_unit_gain() const {
* Guess how many villages we will gain over the next turns per turn.
*/
double recruitment::get_estimated_village_gain() const {
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
int neutral_villages = 0;
BOOST_FOREACH(const map_location& village, map.villages()) {
if (village_owner(village) == -1) {

View file

@ -21,6 +21,7 @@
#include "../manager.hpp"
#include "../../actions/attack.hpp"
#include "../../game_board.hpp"
#include "../../log.hpp"
#include "../../map.hpp"
#include "../../team.hpp"
@ -136,7 +137,7 @@ void aspect_attacks::do_attack_analysis(
//std::cerr << "ANALYSIS " << cur_analysis.movements.size() << " >= " << get_attack_depth() << "\n";
return;
}
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
unit_map &units_ = *resources::units;
std::vector<team> &teams_ = *resources::teams;
@ -359,7 +360,7 @@ void aspect_attacks::do_attack_analysis(
int aspect_attacks::rate_terrain(const unit& u, const map_location& loc)
{
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
const t_translation::t_terrain terrain = map_.get_terrain(loc);
const int defense = u.defense_modifier(terrain);
int rating = 100 - defense;

View file

@ -64,7 +64,7 @@ double goto_phase::evaluate()
// Execute goto-movements - first collect gotos in a list
std::vector<map_location> gotos;
unit_map &units_ = *resources::units;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
for(unit_map::iterator ui = units_.begin(); ui != units_.end(); ++ui) {
if (ui->get_goto() == ui->get_location()) {
@ -82,7 +82,7 @@ double goto_phase::evaluate()
}
// end of passive_leader
const pathfind::shortest_path_calculator calc(*ui, current_team(), *resources::teams, *resources::game_map);
const pathfind::shortest_path_calculator calc(*ui, current_team(), *resources::teams, resources::gameboard->map());
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*ui, current_team());
@ -223,7 +223,7 @@ void recruitment_phase::execute()
unit_movement_scores_.clear();
const unit_map &units_ = *resources::units;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
const std::vector<team> &teams_ = *resources::teams;
map_location start_pos = units_.find_leader(get_side())->get_location();
@ -688,7 +688,7 @@ double move_leader_to_goals_phase::evaluate()
}
}
pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, *resources::game_map);
pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, resources::gameboard->map());
pathfind::plain_route route = a_star_search(leader->get_location(), dst_, 1000.0, &calc,
resources::gameboard->map().w(), resources::gameboard->map().h());
if(route.steps.empty()) {
@ -803,7 +803,7 @@ double move_leader_to_keep_phase::evaluate()
continue;
}
const pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, *resources::game_map);
const pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, resources::gameboard->map());
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*leader, current_team());
@ -825,7 +825,7 @@ double move_leader_to_keep_phase::evaluate()
const unit* leader = best_leader;
const map_location keep = best_keep;
const pathfind::paths leader_paths(*leader, false, true, current_team());
const pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, *resources::game_map);
const pathfind::shortest_path_calculator calc(*leader, current_team(), *resources::teams, resources::gameboard->map());
const pathfind::teleport_map allowed_teleports = pathfind::get_teleport_locations(*leader, current_team());
if (leader_paths.destinations.contains(keep) && units_.count(keep) == 0) {
@ -1046,7 +1046,7 @@ void get_villages_phase::find_villages(
const bool passive_leader = get_passive_leader();
size_t min_distance = 100000;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
std::vector<team> &teams_ = *resources::teams;
// When a unit is dispatched we need to make sure we don't

View file

@ -88,7 +88,7 @@ private:
class remove_wrong_targets {
public:
remove_wrong_targets(const readonly_context &context)
:avoid_(context.get_avoid()), map_(*resources::game_map)
:avoid_(context.get_avoid()), map_(resources::gameboard->map())
{
}
@ -274,7 +274,7 @@ std::pair<map_location,map_location> testing_move_to_targets_phase::choose_move(
raise_user_interact();
unit_map &units_ = *resources::units;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
unit_map::iterator u;
@ -621,7 +621,7 @@ std::pair<map_location,map_location> testing_move_to_targets_phase::choose_move(
void testing_move_to_targets_phase::access_points(const move_map& srcdst, const map_location& u, const map_location& dst, std::vector<map_location>& out)
{
unit_map &units_ = *resources::units;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
const unit_map::const_iterator u_it = units_.find(u);
if(u_it == units_.end()) {
return;
@ -712,7 +712,7 @@ map_location testing_move_to_targets_phase::form_group(const std::vector<map_loc
bool testing_move_to_targets_phase::move_group(const map_location& dst, const std::vector<map_location>& route, const std::set<map_location>& units)
{
unit_map &units_ = *resources::units;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
const std::vector<map_location>::const_iterator itor = std::find(route.begin(),route.end(),dst);
if(itor == route.end()) {
@ -814,7 +814,7 @@ bool testing_move_to_targets_phase::move_group(const map_location& dst, const st
double testing_move_to_targets_phase::rate_group(const std::set<map_location>& group, const std::vector<map_location>& battlefield) const
{
unit_map &units_ = *resources::units;
const gamemap &map_ = *resources::game_map;
const gamemap &map_ = resources::gameboard->map();
double strength = 0.0;
for(std::set<map_location>::const_iterator i = group.begin(); i != group.end(); ++i) {

View file

@ -66,7 +66,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, see_all))
if (!u.valid() || !u->is_visible_to_team(current_team, map_, see_all))
return units_.end();
return u;
}
@ -75,7 +75,7 @@ bool game_board::has_visible_unit(const map_location & loc, const team& current_
{
if (!map_.on_board(loc)) return false;
unit_map::iterator u = units_.find(loc);
if (!u.valid() || !u->is_visible_to_team(current_team, see_all))
if (!u.valid() || !u->is_visible_to_team(current_team, map_, see_all))
return false;
return true;
}

View file

@ -2380,7 +2380,7 @@ WML_HANDLER_FUNCTION(terrain_mask, /*event_info*/, cfg)
{
map_location loc = cfg_to_loc(cfg, 1, 1);
gamemap mask_map(*resources::game_map);
gamemap mask_map(resources::gameboard->map());
//config level;
std::string mask = cfg["mask"];

View file

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

View file

@ -19,6 +19,7 @@
#include "movetype.hpp"
#include "game_board.hpp"
#include "log.hpp"
#include "map.hpp"
#include "resources.hpp"
@ -280,8 +281,8 @@ int movetype::terrain_info::data::calc_value(
<< " depth " << recurse_count << '\n';
return params_.default_value;
}
assert(resources::game_map);
const gamemap & map = *resources::game_map;
assert(resources::gameboard);
const gamemap & map = resources::gameboard->map();
// Get a list of underlying terrains.
const t_translation::t_list & underlying = params_.use_move ?

View file

@ -58,7 +58,7 @@ namespace pathfind {
map_location find_vacant_tile(const map_location& loc, VACANT_TILE_TYPE vacancy,
const unit* pass_check, const team* shroud_check)
{
const gamemap & map = *resources::game_map;
const gamemap & map = resources::gameboard->map();
const unit_map & units = *resources::units;
if (!map.on_board(loc)) return map_location();
@ -271,7 +271,7 @@ static void find_routes(
const std::map<map_location, int> * jamming_map=NULL,
std::vector<std::pair<int, int> > * full_cost_map=NULL)
{
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
const bool see_all = viewing_team == NULL;
// When see_all is true, the viewing team never matters, but we still
@ -650,7 +650,7 @@ marked_route mark_route(const plain_route &rt)
// move_cost of the next step is irrelevant for the last step
assert(last_step || resources::gameboard->map().on_board(*(i+1)));
const int move_cost = last_step ? 0 : u.movement_cost((*resources::game_map)[*(i+1)]);
const int move_cost = last_step ? 0 : u.movement_cost((resources::gameboard->map())[*(i+1)]);
team const& viewing_team = (*resources::teams)[resources::screen->viewing_team()];
@ -851,7 +851,7 @@ full_cost_map::full_cost_map(const unit& u, bool force_ignore_zoc,
:force_ignore_zoc_(force_ignore_zoc), allow_teleport_(allow_teleport),
viewing_team_(viewing_team), see_all_(see_all), ignore_units_(ignore_units)
{
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
cost_map = std::vector<std::pair<int, int> >(map.w() * map.h(), std::make_pair(-1, 0));
add_unit(u);
}
@ -866,7 +866,7 @@ full_cost_map::full_cost_map(bool force_ignore_zoc,
:force_ignore_zoc_(force_ignore_zoc), allow_teleport_(allow_teleport),
viewing_team_(viewing_team), see_all_(see_all), ignore_units_(ignore_units)
{
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
cost_map = std::vector<std::pair<int, int> >(map.w() * map.h(), std::make_pair(-1, 0));
}
@ -921,7 +921,7 @@ void full_cost_map::add_unit(const map_location& origin, const unit_type* const
*/
std::pair<int, int> full_cost_map::get_pair_at(int x, int y) const
{
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
assert(cost_map.size() == static_cast<unsigned>(map.w() * map.h()));
if (x < 0 || x >= map.w() || y < 0 || y >= map.h()) {

View file

@ -528,7 +528,7 @@ static config unit_defense(const unit* u, const map_location& displayed_unit_hex
}
std::ostringstream str, tooltip;
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
if(!resources::gameboard->map().on_board(displayed_unit_hex)) {
return report();
}
@ -1199,7 +1199,7 @@ static config unit_box_at(const map_location& mouseover_hex)
else if (local_tod.bonus_modified < 0) local_tod_image += "~DARKEN()";
if (preferences::flip_time()) local_tod_image += "~FL(horiz)";
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
t_translation::t_terrain terrain = map.get_terrain(mouseover_hex);
//if (terrain == t_translation::OFF_MAP_USER)
@ -1351,7 +1351,7 @@ void blit_tced_icon(config &cfg, const std::string &terrain_id, const std::strin
REPORT_GENERATOR(terrain_info)
{
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
map_location mouseover_hex = display::get_singleton()->mouseover_hex();
if (!map.on_board(mouseover_hex))
@ -1397,7 +1397,7 @@ REPORT_GENERATOR(terrain_info)
REPORT_GENERATOR(terrain)
{
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
int viewing_side = resources::screen->viewing_side();
const team &viewing_team = (*resources::teams)[viewing_side - 1];
map_location mouseover_hex = resources::screen->mouseover_hex();
@ -1446,7 +1446,7 @@ REPORT_GENERATOR(zoom_level)
REPORT_GENERATOR(position)
{
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
map_location mouseover_hex = resources::screen->mouseover_hex(),
displayed_unit_hex = resources::screen->displayed_unit_hex(),
selected_hex = resources::screen->selected_hex();

View file

@ -1449,7 +1449,7 @@ static int intf_set_village_owner(lua_State *L)
*/
static int intf_get_map_size(lua_State *L)
{
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
lua_pushinteger(L, map.w());
lua_pushinteger(L, map.h());
lua_pushinteger(L, map.border_size());
@ -1781,7 +1781,7 @@ static int intf_find_path(lua_State *L)
return luaL_argerror(L, arg - 2, "invalid location");
std::vector<team> &teams = *resources::teams;
const gamemap &map = *resources::game_map;
const gamemap &map = resources::gameboard->map();
int viewing_side = 0;
bool ignore_units = false, see_all = false, ignore_teleport = false;
double stop_at = 10000;

View file

@ -328,9 +328,9 @@ bool terrain_filter::match(const map_location& loc) const
hexes.insert(loc_vec.begin(), loc_vec.end());
else if ( cfg_.has_child("filter_radius") ) {
terrain_filter r_filter(cfg_.child("filter_radius"), *this);
get_tiles_radius(*resources::game_map, loc_vec, radius, hexes, false, r_filter);
get_tiles_radius(resources::gameboard->map(), loc_vec, radius, hexes, false, r_filter);
} else {
get_tiles_radius(*resources::game_map, loc_vec, radius, hexes);
get_tiles_radius(resources::gameboard->map(), loc_vec, radius, hexes);
}
size_t loop_count = 0;
@ -628,9 +628,9 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
std::vector<map_location> xy_vector (match_set.begin(), match_set.end());
if(cfg_.has_child("filter_radius")) {
terrain_filter r_filter(cfg_.child("filter_radius"), *this);
get_tiles_radius(*resources::game_map, xy_vector, radius, locs, with_border, r_filter);
get_tiles_radius(resources::gameboard->map(), xy_vector, radius, locs, with_border, r_filter);
} else {
get_tiles_radius(*resources::game_map, xy_vector, radius, locs, with_border);
get_tiles_radius(resources::gameboard->map(), xy_vector, radius, locs, with_border);
}
} else {
locs.insert(match_set.begin(), match_set.end());

View file

@ -194,7 +194,7 @@ const time_of_day& tod_manager::get_time_of_day(const map_location& loc, int n_t
const time_of_day tod_manager::get_illuminated_time_of_day(const map_location& loc, int for_turn) const
{
const gamemap& map = *resources::game_map;
const gamemap& map = resources::gameboard->map();
const unit_map& units = *resources::units;
// get ToD ignoring illumination

View file

@ -1889,7 +1889,7 @@ void unit::redraw_unit () const
display &disp = *display::get_singleton();
const gamemap &map = disp.get_map();
if ( hidden_ || disp.is_blindfolded() || !is_visible_to_team(disp.get_teams()[disp.viewing_team()],disp.show_everything(),map) )
if ( hidden_ || disp.is_blindfolded() || !is_visible_to_team(disp.get_teams()[disp.viewing_team()],map, disp.show_everything()) )
{
clear_haloes();
if(anim_) {
@ -2885,7 +2885,7 @@ bool unit::invisible(const map_location& loc, bool see_all) const
}
bool unit::is_visible_to_team(team const& team, bool const see_all, gamemap const& map) const
bool unit::is_visible_to_team(team const& team, gamemap const& map, bool const see_all) const
{
map_location const& loc = get_location();
if (!map.on_board(loc))

View file

@ -388,7 +388,7 @@ public:
// Only see_all=true use caching
bool invisible(const map_location& loc, bool see_all=true) const;
bool is_visible_to_team(team const& team, bool const see_all = true, gamemap const& map = *resources::game_map) const;
bool is_visible_to_team(team const& team, gamemap const & map , 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::teams)[viewer_team()], false)) {
if(!on_current_side && !u.is_visible_to_team((*resources::teams)[viewer_team()], resources::gameboard->map(), false)) {
removers_.push_back(new temporary_unit_remover(*resources::units, u.get_location()));
//Don't do anything else to the removed unit!

View file

@ -308,7 +308,7 @@ bool move::calculate_new_route(const map_location& source_hex, const map_locatio
pathfind::plain_route new_plain_route;
pathfind::shortest_path_calculator path_calc(*get_unit(),
resources::teams->at(team_index()),
*resources::teams, *resources::game_map);
*resources::teams, resources::gameboard->map());
new_plain_route = pathfind::a_star_search(source_hex,
dest_hex, 10000, &path_calc, resources::gameboard->map().w(), resources::gameboard->map().h());
if (new_plain_route.move_cost >= path_calc.getNoPathValue()) return false;

View file

@ -122,7 +122,7 @@ int path_cost(std::vector<map_location> const& path, unit const& u)
return u.total_movement();
int result = 0;
gamemap const& map = *resources::game_map;
gamemap const& map = resources::gameboard->map();
BOOST_FOREACH(map_location const& loc, std::make_pair(path.begin()+1,path.end()))
result += u.movement_cost(map[loc]);
return result;