#include <map.hpp>
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_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. 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_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. 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_map & | tiles () |
const terrain_map & | tiles () const |
Private Attributes | |
terrain_map | tiles_ |
location_map | starting_positions_ |
|
protecteddefault |
|
protected |
|
inline |
Size of the map border.
Definition at line 56 of file map.hpp.
References default_border.
Referenced by terrain_filter::get_locs_impl(), get_terrain(), get_tiles_radius(), h(), impl_terrainmap_get(), editor::editor_map::mask_to(), on_board_with_border(), gamemap::operator[](), parse_location_range(), gamemap::read(), editor::editor_map::sanity_check(), mapgen_gamemap::set_terrain(), w(), and gamemap::write().
|
inline |
Tell if the map is of 0 size.
Definition at line 65 of file map.hpp.
Referenced by team_builder::init(), and terrain_builder::parse_mapstring().
|
inline |
Definition at line 136 of file map.hpp.
References f, total_height(), and total_width().
Referenced by prefs::encounter_map_terrain(), intf_mg_get_locations(), image::prep_minimap_for_rendering(), and editor::editor_map::resize().
|
inline |
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().
|
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().
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 357 of file map.cpp.
References 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().
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().
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().
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().
bool gamemap_base::on_board_with_border | ( | const map_location & | loc | ) | const |
Definition at line 390 of file map.cpp.
References border_size(), t_translation::ter_map::data, h(), tiles_, w(), map_location::x, and map_location::y.
Referenced by editor::editor_map::add_to_selection(), editor::editor_controller::allow_mouse_wheel_scroll(), actions::shroud_clearer::clear_loc(), editor::map_context::draw_terrain_actual(), editor::editor_map::get_contiguous_terrain_tiles(), tod_manager::get_illuminated_time_of_day(), get_terrain(), get_tiles_radius(), intf_mg_get_tiles_radius(), intf_on_board(), intf_on_border(), terrain_filter::match_internal(), editor::editor_map::sanity_check(), and gamemap::set_terrain().
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 |
||
) |
Overlays another map onto this one at the given position.
Definition at line 215 of file map.cpp.
References terrain_type_data::BOTH, t_translation::FOGGED, get_terrain(), gamemap_base::overlay_rule::mode_, gamemap_base::overlay_rule::replace_if_failed_, set_terrain(), special_locations(), starting_positions_, t, gamemap_base::overlay_rule::terrain_, t_translation::terrain_matches(), total_height(), total_width(), gamemap_base::overlay_rule::use_old_, t_translation::VOID_TERRAIN, map_location::wml_x(), map_location::wml_y(), map_location::x, and map_location::y.
Referenced by intf_terrain_mask().
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().
void gamemap_base::set_special_location | ( | const std::string & | id, |
const map_location & | loc | ||
) |
Definition at line 363 of file map.cpp.
References starting_positions_, and map_location::valid().
Referenced by impl_slocs_set(), editor::editor_action_starting_position::perform_without_undo(), and 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().
|
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().
map_location gamemap_base::special_location | ( | const std::string & | id | ) | const |
Definition at line 312 of file map.cpp.
References starting_positions_, map_location::x, and map_location::y.
Referenced by editor::location_palette::adjust_size(), unit_creator::find_location(), terrain_filter::get_locs_impl(), impl_slocs_get(), terrain_filter::match_internal(), and starting_position().
|
inline |
Definition at line 90 of file map.hpp.
References starting_positions_.
Referenced by impl_slocs_next(), mapgen_gamemap::mapgen_gamemap(), overlay(), gamemap::read(), editor::editor_map::resize(), editor::editor_map::set_starting_position_labels(), game_events::WML_HANDLER_FUNCTION(), and gamemap::write().
|
inline |
Definition at line 91 of file map.hpp.
References starting_positions_.
map_location gamemap_base::starting_position | ( | int | side | ) | const |
Definition at line 324 of file map.cpp.
References n, and special_location().
Referenced by editor::mouse_action::key_event(), game_state::place_sides_in_preferred_locations(), team_builder::place_units(), SIDE_GETTER(), and 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().
|
inlineprotected |
Definition at line 157 of file map.hpp.
References tiles_.
Referenced by editor::editor_map::expand_bottom(), editor::editor_map::expand_left(), editor::editor_map::expand_right(), editor::editor_map::expand_top(), mapgen_gamemap::mapgen_gamemap(), gamemap::operator[](), gamemap::read(), editor::editor_map::sanity_check(), mapgen_gamemap::set_terrain(), editor::editor_map::shrink_bottom(), editor::editor_map::shrink_left(), editor::editor_map::shrink_right(), editor::editor_map::shrink_top(), and gamemap::write().
|
inlineprotected |
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().
|
inline |
Real height of the map, including borders.
Definition at line 62 of file map.hpp.
References t_translation::ter_map::h, and tiles_.
Referenced by editor::editor_map::everything_selected(), for_each_loc(), mapgen_gamemap::for_each_loc(), h(), impl_terrainmap_get(), impl_terrainmap_iter(), overlay(), gamemap::read(), editor::editor_map::sanity_check(), and game_events::WML_HANDLER_FUNCTION().
|
inline |
Real width of the map, including borders.
Definition at line 59 of file map.hpp.
References tiles_, and t_translation::ter_map::w.
Referenced by editor::editor_map::everything_selected(), for_each_loc(), mapgen_gamemap::for_each_loc(), impl_terrainmap_get(), impl_terrainmap_iter(), overlay(), gamemap::read(), editor::editor_map::sanity_check(), w(), and game_events::WML_HANDLER_FUNCTION().
|
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().
|
static |
The default border style for a map.
Definition at line 37 of file map.hpp.
Referenced by border_size(), passage_path_calculator::cost(), output_map(), cave_map_generator::cave_map_generator_job::place_castle(), and cave_map_generator::cave_map_generator_job::set_terrain().
|
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().
|
private |
Definition at line 161 of file map.hpp.
Referenced by is_special_location(), num_valid_starting_positions(), overlay(), set_special_location(), special_location(), special_locations(), and to_string().
|
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().