The Battle for Wesnoth  1.19.5+dev
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
gamemap_base Class Referenceabstract

#include <map.hpp>

Inheritance diagram for gamemap_base:

Classes

struct  overlay_rule
 

Public Types

using terrain_code = t_translation::terrain_code
 
using terrain_map = t_translation::ter_map
 
using location_map = t_translation::starting_positions
 

Public Member Functions

virtual ~gamemap_base ()
 
std::string to_string () const
 
int w () const
 Effective map width. More...
 
int h () const
 Effective map height. More...
 
int border_size () const
 Size of the map border. More...
 
int total_width () const
 Real width of the map, including borders. More...
 
int total_height () const
 Real height of the map, including borders. More...
 
bool empty () const
 Tell if the map is of 0 size. More...
 
bool on_board (const map_location &loc) const
 Tell if a location is on the map. More...
 
bool on_board_with_border (const map_location &loc) const
 
virtual void set_terrain (const map_location &loc, const terrain_code &terrain, const terrain_type_data::merge_mode mode=terrain_type_data::BOTH, bool replace_if_failed=false)=0
 Clobbers over the terrain at location 'loc', with the given terrain. More...
 
terrain_code get_terrain (const map_location &loc) const
 Looks up terrain at a particular location. More...
 
location_mapspecial_locations ()
 
const location_mapspecial_locations () const
 
const std::vector< map_locationstarting_positions () const
 
void set_special_location (const std::string &id, const map_location &loc)
 
map_location special_location (const std::string &id) const
 
void set_starting_position (int side, const map_location &loc)
 Manipulate starting positions of the different sides. More...
 
map_location starting_position (int side) const
 
int num_valid_starting_positions () const
 Counts the number of sides that have valid starting positions on this map. More...
 
int is_starting_position (const map_location &loc) const
 returns the side number of the side starting at position loc, 0 if no such side exists. More...
 
const std::string * is_special_location (const map_location &loc) const
 returns the name of the special location at position loc, null if no such location exists. More...
 
std::vector< map_locationparse_location_range (const std::string &xvals, const std::string &yvals, bool with_border=false) const
 Parses ranges of locations into a vector of locations, using this map's dimensions as bounds. More...
 
void overlay (const gamemap_base &m, map_location loc, const std::vector< overlay_rule > &rules=std::vector< overlay_rule >(), bool is_odd=false, bool ignore_special_locations=false)
 Overlays another map onto this one at the given position. More...
 
template<typename F >
void for_each_loc (const F &f) const
 
template<typename F >
void for_each_walkable_loc (const F &f) const
 

Static Public Attributes

static const int default_border = 1
 The default border style for a map. More...
 
static const int MAX_PLAYERS = 9
 Maximum number of players supported. More...
 

Protected Member Functions

 gamemap_base ()=default
 
 gamemap_base (int w, int h, terrain_code default_ter=terrain_code())
 
terrain_maptiles ()
 
const terrain_maptiles () const
 

Private Attributes

terrain_map tiles_
 
location_map starting_positions_
 

Detailed Description

Definition at line 28 of file map.hpp.

Member Typedef Documentation

◆ location_map

Definition at line 33 of file map.hpp.

◆ terrain_code

Definition at line 31 of file map.hpp.

◆ terrain_map

Definition at line 32 of file map.hpp.

Constructor & Destructor Documentation

◆ ~gamemap_base()

gamemap_base::~gamemap_base ( )
virtual

Definition at line 129 of file map.cpp.

◆ gamemap_base() [1/2]

gamemap_base::gamemap_base ( )
protecteddefault

◆ gamemap_base() [2/2]

gamemap_base::gamemap_base ( int  w,
int  h,
terrain_code  default_ter = terrain_code() 
)
protected

Definition at line 122 of file map.cpp.

Member Function Documentation

◆ border_size()

int gamemap_base::border_size ( ) const
inline

◆ empty()

bool gamemap_base::empty ( ) const
inline

Tell if the map is of 0 size.

Definition at line 65 of file map.hpp.

References h(), and w().

Referenced by team_builder::init(), and terrain_builder::parse_mapstring().

◆ for_each_loc()

template<typename F >
void gamemap_base::for_each_loc ( const F &  f) const
inline

◆ for_each_walkable_loc()

template<typename F >
void gamemap_base::for_each_walkable_loc ( const F &  f) const
inline

Definition at line 146 of file map.hpp.

References f, h(), and w().

Referenced by ai::default_recruitment::recruitment::compare_cost_maps_and_update_important_hexes().

◆ get_terrain()

t_translation::terrain_code gamemap_base::get_terrain ( const map_location loc) const

Looks up terrain at a particular location.

Hexes off the map may be looked up, and their 'emulated' terrain will also be returned. This allows proper drawing of the edges of the map.

Definition at line 302 of file map.cpp.

References border_size(), t_translation::ter_map::get(), t_translation::NONE_TERRAIN, map_location::null_location(), on_board_with_border(), tiles_, map_location::x, and map_location::y.

Referenced by terrain_builder::build_terrains(), ai::ai_default_rca::move_to_targets_phase::choose_move(), editor::mouse_action_paint::click_left(), editor::mouse_action_fill::click_left(), editor::mouse_action_paint::click_right(), editor::mouse_action_fill::click_right(), wfl::gamestate::DEFINE_WFL_FUNCTION(), display::draw_hex(), editor::map_context::draw_terrain_actual(), prefs::encounter_map_terrain(), ai::ai_default_rca::get_villages_phase::find_villages(), footsteps_images(), editor::editor_map::get_contiguous_terrain_tiles(), gamemap::get_terrain_editor_string(), gamemap::get_terrain_info(), gamemap::get_terrain_string(), gamemap::gives_healing(), unit_animation_component::invalidate(), gamemap::is_castle(), gamemap::is_keep(), gamemap::is_village(), luaW_push_terrain(), editor::editor_map::mask_to(), unit_animation::matches(), ai::ai_default_rca::move_to_targets_phase::move_group(), overlay(), editor::editor_action_shuffle_area::perform_without_undo(), ai::ai_default_rca::move_to_targets_phase::rate_group(), ai::ai_default_rca::aspect_attacks_base::rate_terrain(), ai::default_ai_context_impl::rate_terrain(), unit_drawer::redraw_unit(), REPORT_GENERATOR(), gamemap::set_terrain(), mapgen_gamemap::set_terrain(), gamemap::underlying_def_terrain(), gamemap::underlying_mvt_terrain(), gamemap::underlying_union_terrain(), unit_box_at(), and gamemap::write_terrain().

◆ h()

int gamemap_base::h ( ) const
inline

Effective map height.

Definition at line 53 of file map.hpp.

References border_size(), and total_height().

Referenced by ai::ai_default_rca::move_to_targets_phase::access_points(), display::bounds_check_position(), terrain_builder::build_terrains(), game_state::can_recruit_on(), ai::ai_default_rca::move_to_targets_phase::choose_move(), actions::shroud_clearer::clear_loc(), display::draw_minimap(), display::draw_minimap_units(), empty(), ai::ai_default_rca::goto_phase::evaluate(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), editor::editor_map::expand_bottom(), editor::editor_map::expand_left(), editor::editor_map::expand_right(), editor::editor_map::expand_top(), pathfind::find_routes(), ai::default_ai_context_impl::find_targets(), for_each_walkable_loc(), pathfind::full_cost_map::full_cost_map(), mp::game_info::game_info(), ai::keeps_cache::get(), terrain_filter::get_locs_impl(), pathfind::full_cost_map::get_pair_at(), events::mouse_handler::get_route(), get_tiles_radius(), wfl::gamemap_callable::get_value(), impl_terrainmap_get(), impl_terrainmap_iter(), game_lua_kernel::intf_find_path(), editor::editor_map::invert_selection(), editor::editor_map::mask_to(), display::max_map_area(), display::minimap_location_on(), editor::context_manager::new_map_dialog(), editor::context_manager::new_scenario_dialog(), on_board(), on_board_with_border(), parse_location_range(), terrain_builder::parse_mapstring(), image::prep_minimap_for_rendering(), terrain_builder::rebuild_cache_all(), editor::editor_map::resize(), editor::context_manager::resize_map_dialog(), editor::editor_map::same_size_as(), editor::editor_map::sanity_check(), editor::map_context::set_map(), editor::editor_map::shrink_bottom(), editor::editor_map::shrink_left(), editor::editor_map::shrink_right(), editor::editor_map::shrink_top(), ai::move_result::test_route(), and ai::default_recruitment::recruitment::update_average_local_cost().

◆ is_special_location()

const std::string * gamemap_base::is_special_location ( const map_location loc) const

◆ is_starting_position()

int gamemap_base::is_starting_position ( const map_location loc) const

returns the side number of the side starting at position loc, 0 if no such side exists.

Definition at line 347 of file map.cpp.

References is_special_location().

◆ num_valid_starting_positions()

int gamemap_base::num_valid_starting_positions ( ) const

Counts the number of sides that have valid starting positions on this map.

Definition at line 335 of file map.cpp.

References starting_positions_.

Referenced by game_state::place_sides_in_preferred_locations(), and starting_positions().

◆ on_board()

bool gamemap_base::on_board ( const map_location loc) const

Tell if a location is on the map.

Definition at line 385 of file map.cpp.

References h(), map_location::valid(), w(), map_location::x, and map_location::y.

Referenced by ai::ai_default_rca::move_to_targets_phase::choose_move(), actions::shroud_clearer::clear_loc(), editor::mouse_action_item::click_left(), editor::mouse_action_unit::click_left(), editor::mouse_action_item::click_right(), pathfind::shortest_path_calculator::cost(), pathfind::move_type_path_calculator::cost(), pathfind::emergency_path_calculator::cost(), events::mouse_handler::current_unit_attacks_from(), ai::ai_default_rca::aspect_attacks_base::do_attack_analysis(), editor::mouse_action_item::drag_end_left(), editor::mouse_action_map_label::drag_end_left(), editor::mouse_action_unit::drag_end_left(), display::draw_hex(), game_display::draw_hex(), ai::ai_default_rca::goto_phase::evaluate(), ai::ai_default_rca::move_to_targets_phase::execute(), unit_creator::find_location(), ai::default_ai_context_impl::find_targets(), pathfind::find_vacant_tile(), terrain_filter::get_locs_impl(), pathfind::full_cost_map::get_pair_at(), get_tiles_radius(), gamemap::gives_healing(), intf_on_board(), intf_on_border(), gamemap::is_castle(), gamemap::is_keep(), gamemap::is_village(), editor::mouse_action::key_event(), terrain_filter::match_impl(), terrain_filter::match_internal(), events::mouse_handler::mouse_button_event(), events::mouse_handler::mouse_motion(), ai::ai_default_rca::move_to_targets_phase::move_group(), ai::ai_default_rca::remove_wrong_targets::operator()(), placing_score(), ai::readonly_context_impl::power_projection(), game_board::replace_map(), REPORT_GENERATOR(), events::mouse_handler::select_or_action(), gamemap::set_terrain(), events::mouse_handler::show_attack_options(), events::mouse_handler::show_reach_for_unit(), ai::move_result::test_route(), events::mouse_handler::touch_motion(), unit_defense(), unit_status(), editor::mouse_action_starting_position::up_left(), editor::mouse_action_item::up_left(), editor::mouse_action_map_label::up_left(), editor::mouse_action_unit::up_left(), editor::mouse_action_village::up_left(), editor::mouse_action_village::up_right(), and ai::default_recruitment::recruitment::update_important_hexes().

◆ on_board_with_border()

bool gamemap_base::on_board_with_border ( const map_location loc) const

◆ overlay()

void gamemap_base::overlay ( const gamemap_base m,
map_location  loc,
const std::vector< overlay_rule > &  rules = std::vector<overlay_rule>(),
bool  is_odd = false,
bool  ignore_special_locations = false 
)

◆ parse_location_range()

std::vector< map_location > gamemap_base::parse_location_range ( const std::string &  xvals,
const std::string &  yvals,
bool  with_border = false 
) const

Parses ranges of locations into a vector of locations, using this map's dimensions as bounds.

Definition at line 424 of file map.cpp.

References border_size(), h(), i, utils::parse_range(), utils::split(), and w().

Referenced by tod_manager::add_time_area(), team::build(), and terrain_filter::get_locs_impl().

◆ set_special_location()

void gamemap_base::set_special_location ( const std::string &  id,
const map_location loc 
)

◆ set_starting_position()

void gamemap_base::set_starting_position ( int  side,
const map_location loc 
)

Manipulate starting positions of the different sides.

Definition at line 380 of file map.cpp.

References set_special_location().

Referenced by game_state::place_sides_in_preferred_locations().

◆ set_terrain()

virtual void gamemap_base::set_terrain ( const map_location loc,
const terrain_code terrain,
const terrain_type_data::merge_mode  mode = terrain_type_data::BOTH,
bool  replace_if_failed = false 
)
pure virtual

Clobbers over the terrain at location 'loc', with the given terrain.

Uses mode and replace_if_failed like merge_terrains().

Implemented in mapgen_gamemap, and gamemap.

Referenced by impl_merge_terrain(), and overlay().

◆ special_location()

map_location gamemap_base::special_location ( const std::string &  id) const

◆ special_locations() [1/2]

location_map& gamemap_base::special_locations ( )
inline

◆ special_locations() [2/2]

const location_map& gamemap_base::special_locations ( ) const
inline

Definition at line 91 of file map.hpp.

References starting_positions_.

◆ starting_position()

map_location gamemap_base::starting_position ( int  side) const

◆ starting_positions()

const std::vector< map_location > gamemap_base::starting_positions ( ) const

Definition at line 475 of file map.cpp.

References i, n, num_valid_starting_positions(), and starting_position().

◆ tiles() [1/2]

terrain_map& gamemap_base::tiles ( )
inlineprotected

◆ tiles() [2/2]

const terrain_map& gamemap_base::tiles ( ) const
inlineprotected

Definition at line 158 of file map.hpp.

References tiles_.

◆ to_string()

std::string gamemap_base::to_string ( ) const

Definition at line 470 of file map.cpp.

References starting_positions_, tiles_, and t_translation::write_game_map().

Referenced by impl_terrainmap_get().

◆ total_height()

int gamemap_base::total_height ( ) const
inline

◆ total_width()

int gamemap_base::total_width ( ) const
inline

◆ w()

int gamemap_base::w ( ) const
inline

Effective map width.

Definition at line 50 of file map.hpp.

References border_size(), and total_width().

Referenced by ai::ai_default_rca::move_to_targets_phase::access_points(), display::bounds_check_position(), terrain_builder::build_terrains(), game_state::can_recruit_on(), ai::ai_default_rca::move_to_targets_phase::choose_move(), actions::shroud_clearer::clear_loc(), display::draw_minimap(), display::draw_minimap_units(), empty(), ai::ai_default_rca::goto_phase::evaluate(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), editor::editor_map::expand_bottom(), editor::editor_map::expand_left(), editor::editor_map::expand_right(), editor::editor_map::expand_top(), pathfind::find_routes(), ai::default_ai_context_impl::find_targets(), for_each_walkable_loc(), pathfind::full_cost_map::full_cost_map(), mp::game_info::game_info(), ai::keeps_cache::get(), terrain_filter::get_locs_impl(), pathfind::full_cost_map::get_pair_at(), events::mouse_handler::get_route(), get_tiles_radius(), wfl::gamemap_callable::get_value(), impl_terrainmap_get(), impl_terrainmap_iter(), game_lua_kernel::intf_find_path(), editor::editor_map::invert_selection(), editor::editor_map::mask_to(), display::max_map_area(), display::minimap_location_on(), editor::context_manager::new_map_dialog(), editor::context_manager::new_scenario_dialog(), on_board(), on_board_with_border(), parse_location_range(), terrain_builder::parse_mapstring(), image::prep_minimap_for_rendering(), terrain_builder::rebuild_cache_all(), editor::editor_map::resize(), editor::context_manager::resize_map_dialog(), editor::editor_map::same_size_as(), editor::editor_map::sanity_check(), editor::map_context::set_map(), editor::editor_map::shrink_bottom(), editor::editor_map::shrink_left(), editor::editor_map::shrink_right(), editor::editor_map::shrink_top(), ai::move_result::test_route(), and ai::default_recruitment::recruitment::update_average_local_cost().

Member Data Documentation

◆ default_border

const int gamemap_base::default_border = 1
static

◆ MAX_PLAYERS

const int gamemap_base::MAX_PLAYERS = 9
static

Maximum number of players supported.

Warning: when you increase this, you need to add more definitions to the team_colors.cfg file.

Definition at line 45 of file map.hpp.

Referenced by editor::mouse_action::key_event().

◆ starting_positions_

location_map gamemap_base::starting_positions_
private

◆ tiles_

terrain_map gamemap_base::tiles_
private

Definition at line 160 of file map.hpp.

Referenced by get_terrain(), on_board_with_border(), tiles(), to_string(), total_height(), and total_width().


The documentation for this class was generated from the following files: