The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
map_location Struct Reference

Encapsulates the map of the game. More...

#include <location.hpp>

Inheritance diagram for map_location:
Inheritance graph

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
 Inline vector ops. More...
 
map_location vector_sum (const map_location &a) const
 
map_locationvector_sum_assign (const map_location &a)
 
map_locationvector_difference_assign (const map_location &a)
 
map_location get_direction (DIRECTION d, unsigned int n=1u) const
 
map_location get_direction (DIRECTION d, signed int n) const
 Get Direction function. More...
 
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 &center, 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)
 Inlined bodies. More...
 
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< DIRECTIONparse_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_locationZERO ()
 Old implementation: More...
 
static const map_locationnull_location ()
 

Public Attributes

int x
 
int y
 

Friends

std::size_t hash_value (map_location const &a)
 

Detailed Description

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.

Todo:
Update for new map-format.

Represents a location on the map.

Definition at line 40 of file location.hpp.

Member Enumeration Documentation

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 42 of file location.hpp.

Enumerator
DEFAULT 
RADIAL_SYMMETRY 

Definition at line 103 of file location.hpp.

Constructor & Destructor Documentation

map_location::map_location ( )
inline

Definition at line 62 of file location.hpp.

Referenced by get_direction(), plus(), vector_negation(), and vector_sum().

map_location::map_location ( int  x,
int  y 
)
inline

Definition at line 63 of file location.hpp.

map_location::map_location ( int  x,
int  y,
wml_loc   
)
inline

Definition at line 64 of file location.hpp.

map_location::map_location ( const config cfg,
const variable_set variables = nullptr 
)

Definition at line 181 of file location.cpp.

References ERR_CF, utils::interpolate_variables_into_string(), x, and y.

Member Function Documentation

void map_location::add ( int  x_diff,
int  y_diff 
)
inline
const std::vector< map_location::DIRECTION > & map_location::default_dirs ( )
static

Default list of directions.

Definition at line 51 of file location.cpp.

References NORTH, NORTH_EAST, NORTH_WEST, SOUTH, SOUTH_EAST, and SOUTH_WEST.

Referenced by terrain_filter::match_internal().

int map_location::do_compare ( const map_location a) const
inline
map_location map_location::get_direction ( map_location::DIRECTION  dir,
unsigned int  n = 1u 
) const
inline
map_location map_location::get_direction ( map_location::DIRECTION  dir,
signed int  n 
) const
inline

Get Direction function.

Definition at line 251 of file location.hpp.

References get_direction(), and get_opposite_dir().

std::pair< int, int > map_location::get_in_basis_N_NE ( ) const
map_location::DIRECTION map_location::get_opposite_dir ( map_location::DIRECTION  d)
inlinestatic
map_location::DIRECTION map_location::get_relative_dir ( const map_location loc,
map_location::RELATIVE_DIR_MODE  mode 
) const
map_location::DIRECTION map_location::get_relative_dir ( const map_location loc) const

Definition at line 220 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 316 of file location.cpp.

References ERR_CF, gui2::event::find(), i, utf8::size(), utils::split(), x, and y.

Referenced by terrain_filter::match_internal().

const map_location & map_location::null_location ( )
inlinestatic

Definition at line 220 of file location.hpp.

Referenced by pathfind::a_star_search(), ai::ai_recall(), ai::ai_recruit(), battle_context_unit_stats::battle_context_unit_stats(), game_state::can_recruit_from(), actions::check_recall_location(), actions::check_recruit_location(), 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(), pathfind::find_routes(), ai::ai_default_rca::get_villages_phase::find_villages(), actions::shroud_clearer::fire_events(), ai::default_recruitment::recruitment::get_appropriate_recall(), tod_manager::get_current_time(), get_direction(), joystick_manager::get_next_hex(), gamemap::get_terrain(), tod_manager::get_time_of_day(), wfl::unit_callable::get_value(), ai::ai_default_rca::get_villages_phase::get_villages(), play_controller::init_side_begin(), game_lua_kernel::intf_deselect_hex(), game_lua_kernel::intf_select_unit(), events::mouse_handler::mouse_motion(), actions::move_unit_and_record(), ai::readonly_context_impl::nearest_keep(), actions::place_recruit(), controller_base::play_slice(), events::menu_handler::recall(), ai::ai_default_rca::get_villages_phase::remove_unit(), unit_type::resistance_against(), attack_type::set_specials_context(), ai::readonly_context_impl::suitable_keep(), tod_manager::times(), under_leadership(), unit_display::unit_attack(), unit_display::unit_healing(), unit_display::unit_recruited(), and game_events::WML_HANDLER_FUNCTION().

bool map_location::operator!= ( const map_location a) const
inline

Definition at line 85 of file location.hpp.

References operator==().

bool map_location::operator< ( const map_location a) const
inline

Definition at line 83 of file location.hpp.

References x, and y.

bool map_location::operator== ( const map_location a) const
inline

Definition at line 84 of file location.hpp.

References x, and y.

Referenced by operator!=().

map_location::DIRECTION map_location::parse_direction ( const std::string &  str)
static
std::vector< map_location::DIRECTION > map_location::parse_directions ( const std::string &  str)
static

Parse_directions takes a comma-separated list, and filters out any invalid directions.

Definition at line 123 of file location.cpp.

References i, NDIRECTIONS, parse_direction(), and utils::split().

Referenced by unit::ability_active(), unit::ability_affects_adjacent(), terrain_filter::match_internal(), and attack_type::special_active().

map_location map_location::plus ( int  x_diff,
int  y_diff 
) const
inline

Definition at line 122 of file location.hpp.

References map_location(), x, and y.

Referenced by placing_score().

map_location::DIRECTION map_location::rotate_right ( map_location::DIRECTION  d,
unsigned int  k = 1u 
)
inlinestatic

Inlined bodies.

Inline direction manipulators

Definition at line 180 of file location.hpp.

References NDIRECTIONS.

Referenced by BOOST_AUTO_TEST_CASE(), get_opposite_dir(), parse_direction(), rotate_right(), and rotate_right_around_center().

map_location::DIRECTION map_location::rotate_right ( map_location::DIRECTION  d,
signed int  k 
)
inlinestatic

Definition at line 184 of file location.hpp.

References rotate_right().

map_location map_location::rotate_right_around_center ( const map_location center,
int  k 
) const
void map_location::set_wml_x ( int  v)
inline
void map_location::set_wml_y ( int  v)
inline
bool map_location::valid ( ) const
inline

Definition at line 72 of file location.hpp.

References x, and y.

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(), display::draw_minimap(), game_display::draw_movement_info(), ai::ai_default_rca::move_leader_to_goals_phase::evaluate(), ai::ai_default_rca::retreat_phase::evaluate(), unit_creator::find_location(), game_events::wml_menu_item::fire_event(), replay_helper::get_event(), terrain_filter::get_locs_impl(), unit::has_goto(), game_lua_kernel::impl_current_get(), playsingle_controller::init_gui(), play_controller::init_side_end(), unit_map::insert(), intf_find_cost_map_helper(), 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(), 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::on_board(), wb::manager::on_mouseover_change(), terrain_builder::parse_config(), ai::readonly_context_impl::power_projection(), gui2::dialogs::terrain_layers::pre_show(), gui2::dialogs::editor_set_starting_position::pre_show(), 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::set_special_location(), ai::formula_ai::shortest_path_calculator(), image::simplify_type(), and ai::move_result::test_route().

bool map_location::valid ( const int  parWidth,
const int  parHeight 
) const
inline

Definition at line 74 of file location.hpp.

References x, and y.

bool map_location::valid ( const int  parWidth,
const int  parHeight,
const int  border 
) const
inline

Definition at line 77 of file location.hpp.

References x, and y.

map_location & map_location::vector_difference_assign ( const map_location a)
inline
map_location map_location::vector_negation ( ) const
inline
map_location map_location::vector_sum ( const map_location a) const
inline
map_location & map_location::vector_sum_assign ( const map_location a)
inline
int map_location::wml_x ( ) const
inline
int map_location::wml_y ( ) const
inline
void map_location::write ( config cfg) const
std::string map_location::write_direction ( map_location::DIRECTION  dir)
static
std::string map_location::write_translated_direction ( map_location::DIRECTION  dir)
static

Definition at line 160 of file location.cpp.

References _(), NORTH, NORTH_EAST, NORTH_WEST, SOUTH, SOUTH_EAST, and SOUTH_WEST.

Referenced by editor::editor_controller::show_menu().

const map_location & map_location::ZERO ( )
inlinestatic

Friends And Related Function Documentation

std::size_t hash_value ( map_location const &  a)
friend

Definition at line 58 of file location.cpp.

Member Data Documentation

int map_location::x

Definition at line 125 of file location.hpp.

Referenced by add(), 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(), unit_drawer::draw_bar(), pathfind::find_routes(), flood_name(), get_adjacent_tiles(), get_direction(), get_in_basis_N_NE(), display::get_location_x(), display::get_location_y(), get_noise(), get_relative_dir(), display::get_variant(), hash_value(), 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(), unit::move_interrupted(), cave_map_generator::on_board(), gamemap::on_board(), gamemap::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::overlay(), terrain_builder::parse_config(), cave_map_generator::cave_map_generator_job::place_castle(), place_village(), plus(), gui2::dialogs::terrain_layers::pre_show(), t_translation::read_game_map(), halo::halo_impl::effect::render(), terrain_builder::rotate(), terrain_builder::rotate_rule(), terrain_builder::rule_matches(), cave_map_generator::cave_map_generator_job::set_terrain(), set_wml_x(), gamemap::special_location(), tiles_adjacent(), halo::halo_impl::effect::unrender(), valid(), vector_negation(), vector_sum_assign(), wml_x(), write(), and t_translation::write_game_map().

int map_location::y

Definition at line 125 of file location.hpp.

Referenced by add(), 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(), get_relative_dir(), display::get_variant(), hash_value(), 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(), unit::move_interrupted(), cave_map_generator::on_board(), gamemap::on_board(), gamemap::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::overlay(), terrain_builder::parse_config(), cave_map_generator::cave_map_generator_job::place_castle(), place_village(), plus(), gui2::dialogs::terrain_layers::pre_show(), t_translation::read_game_map(), unit_drawer::redraw_unit(), halo::halo_impl::effect::render(), terrain_builder::rotate(), terrain_builder::rotate_rule(), terrain_builder::rule_matches(), cave_map_generator::cave_map_generator_job::set_terrain(), set_wml_y(), gamemap::special_location(), tiles_adjacent(), halo::halo_impl::effect::unrender(), valid(), vector_negation(), vector_sum_assign(), wml_y(), write(), and t_translation::write_game_map().


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