The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
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
 
struct  set_terrain_result
 

Public Types

enum class  village_state { unchanged , new_village , former_village }
 What happens to a village hex when its terrain is changed. More...
 
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.
 
int h () const
 Effective map height.
 
int border_size () const
 Size of the map border.
 
int total_width () const
 Real width of the map, including borders.
 
int total_height () const
 Real height of the map, including borders.
 
int total_area () const
 Total square area of the map, including borders.
 
bool empty () const
 Tell if the map is of 0 size.
 
bool on_board (const map_location &loc) const
 Tell if a location is on the map.
 
bool on_board_with_border (const map_location &loc) const
 
virtual set_terrain_result 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.
 
terrain_code get_terrain (const map_location &loc) const
 Looks up terrain at a particular location.
 
location_map & special_locations ()
 
const location_map & special_locations () const
 
const std::vector< map_location > starting_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.
 
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.
 
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.
 
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.
 
std::vector< map_location > 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.
 
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.
 
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.
 
static const int MAX_PLAYERS = 9
 Maximum number of players supported.
 

Protected Member Functions

 gamemap_base ()=default
 
 gamemap_base (int w, int h, const terrain_code &default_ter)
 
terrain_map & tiles ()
 
const terrain_map & tiles () 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.

Member Enumeration Documentation

◆ village_state

enum class gamemap_base::village_state
strong

What happens to a village hex when its terrain is changed.

Enumerator
unchanged 
new_village 
former_village 

Definition at line 80 of file map.hpp.

Constructor & Destructor Documentation

◆ ~gamemap_base()

gamemap_base::~gamemap_base ( )
virtual

Definition at line 106 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,
const terrain_code &  default_ter 
)
protected

Definition at line 100 of file map.cpp.

Member Function Documentation

◆ border_size()

int gamemap_base::border_size ( ) const
inline

◆ empty()

bool gamemap_base::empty ( ) const
inline

◆ 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 150 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

◆ 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(), 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(), 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(), 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::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

returns the name of the special location at position loc, null if no such location exists.

Definition at line 319 of file map.cpp.

References loc, and starting_positions_.

Referenced by is_starting_position(), editor::mouse_action::key_event(), editor::editor_action_starting_position::perform_without_undo(), editor::mouse_action_starting_position::up_left(), and editor::mouse_action_starting_position::up_right().

◆ 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 309 of file map.cpp.

References is_special_location(), and loc.

◆ 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 297 of file map.cpp.

References starting_positions_.

Referenced by editor::context_manager::map_to_scenario(), 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 347 of file map.cpp.

References h(), loc, 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(), handle_unit_move(), intf_on_board(), intf_on_border(), game_lua_kernel::intf_teleport(), 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(), REPORT_GENERATOR(), REPORT_GENERATOR(), display::scroll_to_tiles(), events::mouse_handler::select_or_action(), gamemap::set_terrain(), events::mouse_handler::show_reach_for_unit(), ai::move_result::test_route(), events::mouse_handler::touch_motion(), display_context::unit_can_move(), 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 396 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 342 of file map.cpp.

References loc, and set_special_location().

Referenced by game_state::place_sides_in_preferred_locations().

◆ set_terrain()

virtual set_terrain_result 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 gamemap, and mapgen_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 106 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 447 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 162 of file map.hpp.

References tiles_.

◆ to_string()

std::string gamemap_base::to_string ( ) const

Definition at line 442 of file map.cpp.

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

Referenced by impl_terrainmap_get().

◆ total_area()

int gamemap_base::total_area ( ) const
inline

Total square area of the map, including borders.

Definition at line 65 of file map.hpp.

References total_height(), and total_width().

Referenced by editor::editor_map::selection_mask::selection_mask().

◆ 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(), 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(), 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(), 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::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

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