Encapsulates the map of the game. More...
#include <location.hpp>
Public Types | |
enum | DIRECTION { NORTH =0, NORTH_EAST =1, SOUTH_EAST =2, SOUTH =3, SOUTH_WEST =4, NORTH_WEST =5, NDIRECTIONS =6 } |
Valid directions which can be moved in our hexagonal world. More... | |
enum | RELATIVE_DIR_MODE { DEFAULT, RADIAL_SYMMETRY } |
Public Member Functions | |
map_location () | |
map_location (int x, int y) | |
map_location (int x, int y, wml_loc) | |
map_location (const config &cfg, const variable_set *variables=nullptr) | |
void | write (config &cfg) const |
bool | valid () const |
bool | valid (const int parWidth, const int parHeight) const |
bool | valid (const int parWidth, const int parHeight, const int border) const |
bool | matches_range (const std::string &xloc, const std::string &yloc) const |
bool | operator< (const map_location &a) const |
bool | operator== (const map_location &a) const |
bool | operator!= (const map_location &a) const |
int | do_compare (const map_location &a) const |
three-way comparator More... | |
map_location | vector_negation () const |
map_location | vector_sum (const map_location &a) const |
map_location & | vector_sum_assign (const map_location &a) |
map_location & | vector_difference_assign (const map_location &a) |
map_location | get_direction (DIRECTION dir, unsigned int n=1u) const |
map_location | get_direction (DIRECTION dir, signed int n) const |
DIRECTION | get_relative_dir (const map_location &loc, map_location::RELATIVE_DIR_MODE mode) const |
DIRECTION | get_relative_dir (const map_location &loc) const |
std::pair< int, int > | get_in_basis_N_NE () const |
map_location | rotate_right_around_center (const map_location ¢er, int k) const |
int | wml_x () const |
int | wml_y () const |
void | set_wml_x (int v) |
void | set_wml_y (int v) |
void | add (int x_diff, int y_diff) |
map_location | plus (int x_diff, int y_diff) const |
Static Public Member Functions | |
static const std::vector< DIRECTION > & | default_dirs () |
Default list of directions. More... | |
static DIRECTION | rotate_right (DIRECTION d, unsigned int k=1u) |
static DIRECTION | rotate_right (DIRECTION d, signed int k) |
static DIRECTION | get_opposite_dir (DIRECTION d) |
static DIRECTION | parse_direction (const std::string &str) |
static std::vector< DIRECTION > | parse_directions (const std::string &str) |
Parse_directions takes a comma-separated list, and filters out any invalid directions. More... | |
static std::string | write_direction (DIRECTION dir) |
static std::string | write_translated_direction (DIRECTION dir) |
static const map_location & | ZERO () |
static const map_location & | null_location () |
Public Attributes | |
int | x |
int | y |
Friends | |
std::size_t | hash_value (const map_location &a) |
Encapsulates the map of the game.
Although the game is hexagonal, the map is stored as a grid. Each type of terrain is represented by a multiletter terrain code.
Represents a location on the map.
Definition at line 38 of file location.hpp.
Valid directions which can be moved in our hexagonal world.
Enumerator | |
---|---|
NORTH | |
NORTH_EAST | |
SOUTH_EAST | |
SOUTH | |
SOUTH_WEST | |
NORTH_WEST | |
NDIRECTIONS |
Definition at line 40 of file location.hpp.
Enumerator | |
---|---|
DEFAULT | |
RADIAL_SYMMETRY |
Definition at line 141 of file location.hpp.
|
inline |
Definition at line 70 of file location.hpp.
Referenced by get_direction(), read_locations_helper(), and write_location_range().
|
inline |
Definition at line 71 of file location.hpp.
|
inline |
Definition at line 72 of file location.hpp.
map_location::map_location | ( | const config & | cfg, |
const variable_set * | variables = nullptr |
||
) |
Definition at line 183 of file location.cpp.
References ERR_CF, utils::interpolate_variables_into_string(), x, and y.
|
inline |
Definition at line 159 of file location.hpp.
Referenced by editor::editor_map::resize().
|
static |
Default list of directions.
Definition at line 53 of file location.cpp.
References NORTH, NORTH_EAST, NORTH_WEST, SOUTH, SOUTH_EAST, and SOUTH_WEST.
Referenced by unit_filter::first_match_on_map(), and terrain_filter::match_internal().
|
inline |
three-way comparator
Definition at line 105 of file location.hpp.
Referenced by wfl::terrain_callable::do_compare(), wfl::attack_callable::do_compare(), wfl::move_callable::do_compare(), wfl::location_callable::do_compare(), and wfl::move_partial_callable::do_compare().
map_location map_location::get_direction | ( | map_location::DIRECTION | dir, |
unsigned int | n = 1u |
||
) | const |
Definition at line 360 of file location.cpp.
References map_location(), NDIRECTIONS, NORTH, null_location(), SOUTH, x, and y.
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), get_in_basis_N_NE(), unit_frame::get_overlaped_hex(), get_tile_ring(), get_tiles_radius(), lua_map_location::intf_get_direction(), is_shrouded(), MLFixture::MLFixture(), reality_check_get_direction_helper(), terrain_label::recalculate(), unit_drawer::redraw_unit(), editor::map_fragment::rotate_60_ccw(), editor::map_fragment::rotate_60_cw(), rotate_right_around_center(), and unit_animation_component::start_animation().
|
inline |
Definition at line 136 of file location.hpp.
std::pair< int, int > map_location::get_in_basis_N_NE | ( | ) | const |
Definition at line 288 of file location.cpp.
References get_direction(), NORTH, NORTH_EAST, SOUTH_WEST, x, and y.
Referenced by lua_map_location::intf_get_in_basis_N_NE(), and rotate_right_around_center().
Definition at line 55 of file location.hpp.
Referenced by BOOST_AUTO_TEST_CASE(), characterization_distance_direction(), battle_context::choose_defender_weapon(), actions::find_recruit_location(), mirror_walk(), and parse_direction().
map_location::DIRECTION map_location::get_relative_dir | ( | const map_location & | loc, |
map_location::RELATIVE_DIR_MODE | mode | ||
) | const |
Definition at line 227 of file location.cpp.
References DEFAULT, is_vertically_higher_than(), NDIRECTIONS, NORTH, NORTH_EAST, NORTH_WEST, rotate_right_around_center(), SOUTH, SOUTH_EAST, SOUTH_WEST, x, and y.
Referenced by game_display::attack_indicator_direction(), characterization_distance_direction(), events::mouse_handler::current_unit_attacks_from(), wfl::builtins::DEFINE_WFL_FUNCTION(), actions::find_recruit_location(), unit_frame::get_overlaped_hex(), get_relative_dir(), lua_map_location::intf_get_relative_dir(), unit_frame::redraw(), ai::formula_ai::shortest_path_calculator(), attack_type::special_active_impl(), unit_display::unit_attack(), unit_display::unit_draw_weapon(), unit_display::unit_recruited(), and game_events::WML_HANDLER_FUNCTION().
map_location::DIRECTION map_location::get_relative_dir | ( | const map_location & | loc | ) | const |
Definition at line 222 of file location.cpp.
References get_relative_dir(), and RADIAL_SYMMETRY.
bool map_location::matches_range | ( | const std::string & | xloc, |
const std::string & | yloc | ||
) | const |
Definition at line 318 of file location.cpp.
References ERR_CF, i, utils::parse_range(), utils::split(), x, and y.
Referenced by unit_filter::first_match_on_map(), and terrain_filter::match_internal().
|
inlinestatic |
Definition at line 81 of file location.hpp.
References write().
Referenced by pathfind::a_star_search(), ai::ai_recall(), ai::ai_recruit(), display::announce_options::announce_options(), battle_context_unit_stats::battle_context_unit_stats(), game_state::can_recruit_from(), actions::check_recall_location(), actions::check_recruit_location(), wb::recall::check_validity(), game_display::clear_attack_indicator(), actions::shroud_clearer::clear_unit(), display::displayed_unit_hex(), ai::recall_result::do_describe(), ai::recruit_result::do_describe(), ai::synced_command_result::do_execute(), events::menu_handler::do_recruit(), ai::ai_default_rca::move_leader_to_keep_phase::evaluate(), ai::default_recruitment::recruitment::evaluate(), wb::recall::execute(), ai::default_recruitment::recruitment::execute(), ai::default_recruitment::recruitment::execute_recall(), ai::default_recruitment::recruitment::execute_recruit(), unit_creator::find_location(), actions::find_recruit_location(), pathfind::find_routes(), ai::ai_default_rca::get_villages_phase::find_villages(), actions::shroud_clearer::fire_events(), unit_animation::get_animation_time_potential(), ai::default_recruitment::recruitment::get_appropriate_recall(), tod_manager::get_area_on_hex(), tod_manager::get_current_time(), get_direction(), ai::readonly_context_impl::get_readonly_context(), ai::readwrite_context_impl::get_readwrite_context(), actions::get_recalls(), actions::get_recruits(), events::mouse_handler_base::get_show_menu(), gamemap_base::get_terrain(), get_tiles_radius(), tod_manager::get_time_of_day(), wfl::unit_callable::get_value(), actions::get_village(), ai::ai_default_rca::get_villages_phase::get_villages(), events::mouse_handler::gui(), tod_manager::has_time_area(), game_display::highlight_another_reach(), play_controller::init_side_begin(), game_lua_kernel::intf_deselect_hex(), game_lua_kernel::intf_select_unit(), editor::editor_display::map(), events::mouse_handler::mouse_motion(), actions::move_unit_and_record(), ai::readonly_context_impl::nearest_keep(), game_display::observers(), actions::place_recruit(), events::menu_handler::recall(), ai::ai_default_rca::get_villages_phase::remove_unit(), REPORT_GENERATOR(), unit_type::resistance_against(), editor::editor_controller::save_map(), attack_type::specials_context_t::specials_context_t(), ai::readonly_context_impl::suitable_keep(), tod_manager::times(), tod_stats_at(), events::mouse_handler::touch_motion(), unit_animation_component::unit_animation_component(), unit_animator::unit_animator(), unit_display::unit_attack(), unit_display::unit_healing(), game_events::WML_HANDLER_FUNCTION(), ai::readonly_context::~readonly_context(), ai::readwrite_context::~readwrite_context(), attack_type::specials_context_t::~specials_context_t(), and tod_manager::~tod_manager().
|
inline |
Definition at line 102 of file location.hpp.
References operator==().
|
inline |
Definition at line 100 of file location.hpp.
|
inline |
Definition at line 101 of file location.hpp.
|
static |
Definition at line 66 of file location.cpp.
References get_opposite_dir(), NDIRECTIONS, NORTH, NORTH_EAST, NORTH_WEST, rotate_right(), SOUTH, SOUTH_EAST, SOUTH_WEST, editor::start(), and write_direction().
Referenced by actions::undo_list::create_action(), wfl::builtins::DEFINE_WFL_FUNCTION(), get_second(), unit::init(), lua_map_location::intf_get_direction(), parse_directions(), unit_animation::unit_animation(), and game_events::WML_HANDLER_FUNCTION().
|
static |
Parse_directions takes a comma-separated list, and filters out any invalid directions.
Definition at line 125 of file location.cpp.
References i, NDIRECTIONS, parse_direction(), and utils::split().
Referenced by unit::ability_active(), unit::ability_affects_adjacent(), unit_filter::first_match_on_map(), terrain_filter::match_internal(), and attack_type::special_active_impl().
|
inline |
Definition at line 160 of file location.hpp.
Referenced by placing_score().
Definition at line 45 of file location.hpp.
References NDIRECTIONS.
Referenced by BOOST_AUTO_TEST_CASE(), parse_direction(), and rotate_right_around_center().
Definition at line 50 of file location.hpp.
map_location map_location::rotate_right_around_center | ( | const map_location & | center, |
int | k | ||
) | const |
Definition at line 307 of file location.cpp.
References get_direction(), get_in_basis_N_NE(), NORTH, NORTH_EAST, rotate_right(), and vector_difference_assign().
Referenced by wfl::builtins::DEFINE_WFL_FUNCTION(), get_relative_dir(), lua_map_location::intf_rotate_right_around_center(), and rotate_around_centers().
|
inline |
Definition at line 156 of file location.hpp.
Referenced by unit::init(), game_lua_kernel::intf_put_unit(), and luaW_tolocation().
|
inline |
Definition at line 157 of file location.hpp.
Referenced by unit::init(), game_lua_kernel::intf_put_unit(), and luaW_tolocation().
|
inline |
Definition at line 89 of file location.hpp.
Referenced by pathfind::a_star_search(), display::add_exclusive_draw(), unit_creator::add_unit(), editor::location_palette::adjust_size(), editor::editor_controller::can_execute_command(), play_controller::hotkey_handler::can_execute_command(), game_events::wml_menu_item::can_show(), actions::check_recall_location(), actions::check_recruit_location(), wb::attack::check_validity(), ai::ai_default_rca::move_to_targets_phase::choose_move(), events::mouse_handler::current_unit_attacks_from(), game_display::display_unit_hex(), ai::recall_result::do_check_before(), ai::recruit_result::do_check_before(), events::menu_handler::do_search(), game_display::draw_movement_info(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), ai::ai_default_rca::retreat_phase::evaluate(), terrain_filterimpl::filter_special_loc(), unit_creator::find_location(), actions::find_recall_location(), game_events::wml_menu_item::fire_event(), replay_helper::get_event(), terrain_filter::get_locs_impl(), actions::get_recalls(), game_lua_kernel::impl_current_get(), playsingle_controller::init_gui(), unit_map::insert(), game_lua_kernel::intf_find_vacant_tile(), game_lua_kernel::intf_get_units(), game_lua_kernel::intf_put_unit(), editor::mouse_action::key_event(), ai::readonly_context_impl::leader_can_reach_keep(), events::mouse_handler_base::left_click(), image::load_image_sub_file(), terrain_filter::match_internal(), unit_filter_impl::unit_filter_compound::matches(), attack_type::modified_damage(), events::mouse_handler::mouse_motion(), events::mouse_handler_base::mouse_motion_default(), events::mouse_handler_base::mouse_press(), events::mouse_handler::move_action(), ai::ai_default_rca::move_to_targets_phase::move_group(), gamemap_base::on_board(), wb::manager::on_mouseover_change(), terrain_builder::parse_config(), ai::readonly_context_impl::power_projection(), gui2::dialogs::terrain_layers::pre_show(), display::recalculate_minimap(), display::remove_exclusive_draw(), REPORT_GENERATOR(), events::mouse_handler::right_click_show_menu(), terrain_builder::rule_matches(), events::menu_handler::search(), game_display::select_hex(), events::mouse_handler::select_hex(), wb::highlighter::set_mouseover_hex(), gamemap_base::set_special_location(), ai::formula_ai::shortest_path_calculator(), events::mouse_handler::show_reach_for_unit(), image::simplify_type(), ai::move_result::test_route(), tod_stats_at(), events::mouse_handler::touch_action(), and events::mouse_handler::touch_motion().
|
inline |
Definition at line 91 of file location.hpp.
|
inline |
Definition at line 94 of file location.hpp.
|
inline |
Definition at line 129 of file location.hpp.
References n, and vector_negation().
Referenced by characterization_distance_direction(), lua_map_location::intf_vector_diff(), rotate_right_around_center(), and vector_difference().
|
inline |
Definition at line 111 of file location.hpp.
Referenced by characterization_distance_direction(), lua_map_location::intf_vector_negation(), MLFixture::MLFixture(), and vector_difference_assign().
|
inline |
Definition at line 116 of file location.hpp.
References vector_sum_assign().
Referenced by characterization_distance_direction(), MLFixture::MLFixture(), and reality_check_get_direction_helper().
|
inline |
Definition at line 121 of file location.hpp.
Referenced by editor::map_fragment::center_of_mass(), lua_map_location::intf_vector_sum(), and vector_sum().
|
inline |
Definition at line 153 of file location.hpp.
Referenced by scoped_xy_unit::activate(), battle_context::choose_defender_weapon(), team::clear_fog(), team::clear_shroud(), lua_pathfind_cost_calculator::cost(), events::menu_handler::current_unit(), ai::synced_command_result::do_execute(), events::console_handler::do_terrain(), events::console_handler::do_unit(), game_events::wmi_manager::fire_item(), team::fogged(), game_events::wmi_manager::get_items(), wfl::terrain_callable::get_value(), wfl::location_callable::get_value(), wfl::unit_callable::get_value(), game_lua_kernel::impl_current_get(), impl_terrainmap_iter(), game_lua_kernel::intf_find_reach(), game_lua_kernel::intf_find_vacant_tile(), game_lua_kernel::intf_get_mouseover_tile(), game_lua_kernel::intf_get_selected_tile(), is_vertically_higher_than(), events::menu_handler::kill_unit(), luaW_pushlocation(), game_lua_kernel::mouse_over_hex_callback(), game_events::wml_event_pump::operator()(), operator<<(), gamemap_base::overlay(), team::place_shroud(), game_lua_kernel::run_filter(), game_lua_kernel::select_hex_callback(), wfl::location_callable::serialize_to_string(), team::shrouded(), wb::attack::to_config(), wb::suppose_dead::to_config(), wb::recall::to_config(), wb::recruit::to_config(), wb::move::to_config(), actions::undo_action::undo_action(), actions::undo::move_action::write(), unit::write(), and filter_impl::~filter_impl().
|
inline |
Definition at line 154 of file location.hpp.
Referenced by scoped_xy_unit::activate(), battle_context::choose_defender_weapon(), team::clear_fog(), team::clear_shroud(), lua_pathfind_cost_calculator::cost(), events::menu_handler::current_unit(), ai::synced_command_result::do_execute(), events::console_handler::do_terrain(), events::console_handler::do_unit(), game_events::wmi_manager::fire_item(), team::fogged(), game_events::wmi_manager::get_items(), wfl::terrain_callable::get_value(), wfl::location_callable::get_value(), wfl::unit_callable::get_value(), game_lua_kernel::impl_current_get(), impl_terrainmap_iter(), game_lua_kernel::intf_find_reach(), game_lua_kernel::intf_find_vacant_tile(), game_lua_kernel::intf_get_mouseover_tile(), game_lua_kernel::intf_get_selected_tile(), is_vertically_higher_than(), events::menu_handler::kill_unit(), luaW_pushlocation(), game_lua_kernel::mouse_over_hex_callback(), game_events::wml_event_pump::operator()(), operator<<(), gamemap_base::overlay(), team::place_shroud(), game_lua_kernel::run_filter(), game_lua_kernel::select_hex_callback(), wfl::location_callable::serialize_to_string(), team::shrouded(), wb::attack::to_config(), wb::suppose_dead::to_config(), wb::recall::to_config(), wb::recruit::to_config(), wb::move::to_config(), actions::undo_action::undo_action(), actions::undo::move_action::write(), unit::write(), and filter_impl::~filter_impl().
void map_location::write | ( | config & | cfg | ) | const |
Definition at line 212 of file location.cpp.
Referenced by replay::add_rename(), replay::add_unit_checksum(), fix_rename_command(), replay_helper::get_attack(), replay_helper::get_event(), replay_helper::get_recall(), replay_helper::get_recruit(), actions::undo::recall_action::write(), actions::undo::recruit_action::write(), terrain_label::write(), and display::write().
|
static |
Definition at line 141 of file location.cpp.
References NORTH, NORTH_EAST, NORTH_WEST, SOUTH, SOUTH_EAST, and SOUTH_WEST.
Referenced by game_display::attack_indicator_direction(), characterization_distance_direction(), wfl::builtins::DEFINE_WFL_FUNCTION(), wb::attack::draw_hex(), wfl::unit_callable::get_value(), lua_map_location::intf_get_relative_dir(), operator<<(), parse_direction(), editor::map_context::to_config(), arrow::update_symbols(), game_events::WML_HANDLER_FUNCTION(), actions::undo::move_action::write(), and unit::write().
|
static |
Definition at line 162 of file location.cpp.
References _(), NORTH, NORTH_EAST, NORTH_WEST, SOUTH, SOUTH_EAST, and SOUTH_WEST.
Referenced by editor::editor_controller::show_menu().
|
inlinestatic |
Definition at line 75 of file location.hpp.
Referenced by ai::default_ai_context_impl::find_targets(), MLFixture::MLFixture(), editor::map_fragment::rotate_60_ccw(), editor::map_fragment::rotate_60_cw(), halo::halo_impl::effect::set_location(), and halo::halo_impl::effect::update().
|
friend |
Definition at line 60 of file location.cpp.
int map_location::x |
Definition at line 163 of file location.hpp.
Referenced by terrain_builder::add_constraints(), editor::map_fragment::center_of_mass(), actions::shroud_clearer::clear_loc(), passage_path_calculator::cost(), default_map_generator_job::default_generate_map(), distance_between(), do_compare(), events::menu_handler::do_search(), pathfind::find_routes(), get_adjacent_tiles(), get_direction(), get_in_basis_N_NE(), display::get_location_x(), display::get_location_y(), get_noise(), pathfind::full_cost_map::get_pair_at(), get_relative_dir(), gamemap_base::get_terrain(), display::get_terrain_images(), get_tiles_radius(), display::get_variant(), hash_value(), playsingle_controller::init_gui(), legacy_negation(), legacy_sum_assign(), image::load_image_sub_file(), theme::object::location(), map_location(), editor::editor_map::mask_to(), matches_range(), display::minimap_location_on(), theme::object::modify_location(), gamemap_base::on_board(), cave_map_generator::on_board(), gamemap_base::on_board_with_border(), terrain_builder::tilemap::on_map(), std::hash< image::locator::value >::operator()(), display::rect_of_hexes::iterator::operator++(), operator<(), operator==(), gamemap::operator[](), terrain_builder::tilemap::operator[](), output_map(), gamemap_base::overlay(), terrain_builder::parse_config(), cave_map_generator::cave_map_generator_job::place_castle(), gui2::dialogs::terrain_layers::pre_show(), t_translation::read_game_map(), terrain_builder::rotate(), terrain_builder::rotate_rule(), terrain_builder::rule_matches(), mapgen_gamemap::set_terrain(), cave_map_generator::cave_map_generator_job::set_terrain(), gamemap_base::special_location(), tiles_adjacent(), halo::halo_impl::effect::update(), vector_sum_assign(), halo::halo_impl::effect::visible(), write(), t_translation::write_game_map(), write_location_range(), write_locations(), and filter_impl::~filter_impl().
int map_location::y |
Definition at line 163 of file location.hpp.
Referenced by terrain_builder::add_constraints(), editor::map_fragment::center_of_mass(), actions::shroud_clearer::clear_loc(), passage_path_calculator::cost(), default_map_generator_job::default_generate_map(), distance_between(), do_compare(), events::menu_handler::do_search(), pathfind::find_routes(), get_adjacent_tiles(), get_direction(), get_in_basis_N_NE(), display::get_location_y(), get_noise(), pathfind::full_cost_map::get_pair_at(), get_relative_dir(), gamemap_base::get_terrain(), display::get_terrain_images(), get_tiles_radius(), display::get_variant(), hash_value(), playsingle_controller::init_gui(), legacy_negation(), legacy_sum_assign(), image::load_image_sub_file(), theme::object::location(), map_location(), editor::editor_map::mask_to(), matches_range(), display::minimap_location_on(), theme::object::modify_location(), gamemap_base::on_board(), cave_map_generator::on_board(), gamemap_base::on_board_with_border(), terrain_builder::tilemap::on_map(), std::hash< image::locator::value >::operator()(), display::rect_of_hexes::iterator::operator++(), operator<(), operator==(), gamemap::operator[](), terrain_builder::tilemap::operator[](), output_map(), gamemap_base::overlay(), terrain_builder::parse_config(), cave_map_generator::cave_map_generator_job::place_castle(), gui2::dialogs::terrain_layers::pre_show(), t_translation::read_game_map(), terrain_builder::rotate(), terrain_builder::rotate_rule(), terrain_builder::rule_matches(), mapgen_gamemap::set_terrain(), cave_map_generator::cave_map_generator_job::set_terrain(), gamemap_base::special_location(), tiles_adjacent(), halo::halo_impl::effect::update(), vector_sum_assign(), halo::halo_impl::effect::visible(), write(), t_translation::write_game_map(), write_location_range(), write_locations(), and filter_impl::~filter_impl().