#include <cmath>
#include <cstdlib>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
Go to the source code of this file.
Classes | |
struct | map_location |
Encapsulates the map of the game. More... | |
Functions | |
bool | tiles_adjacent (const map_location &a, const map_location &b) |
Function which tells if two locations are adjacent. More... | |
void | get_adjacent_tiles (const map_location &a, map_location *res) |
Function which, given a location, will place all adjacent locations in res. More... | |
size_t | distance_between (const map_location &a, const map_location &b) |
Function which gives the number of hexes between two tiles (i.e. More... | |
void | write_location_range (const std::set< map_location > &locs, config &cfg) |
Write a set of locations into a config using ranges, adding keys x=x1,..,xn and y=y1a-y1b,..,yna-ynb. More... | |
void | read_locations (const config &cfg, std::vector< map_location > &locs) |
Parse x,y keys of a config into a vector of locations. More... | |
void | write_locations (const std::vector< map_location > &locs, config &cfg) |
Write a vector of locations into a config adding keys x=x1,x2,..,xn and y=y1,y2,..,yn. More... | |
std::ostream & | operator<< (std::ostream &s, map_location const &l) |
Dumps a position on a stream, for debug purposes. More... | |
std::ostream & | operator<< (std::ostream &s, std::vector< map_location > const &v) |
Dumps a vector of positions on a stream, for debug purposes. More... | |
|
inline |
Function which gives the number of hexes between two tiles (i.e.
the minimum number of hexes that have to be traversed to get from one hex to the other).
Definition at line 357 of file location.hpp.
References map_location::x, and map_location::y.
Referenced by ai::ai_default_rca::move_to_targets_phase::access_points(), actions::actor_sighted(), ai::protect_goal::add_targets(), ai::attack_analysis::attack_close(), battle_context_unit_stats::battle_context_unit_stats(), soundsource::positional_source::calculate_volume(), characterization_distance_direction(), ai::ai_default_rca::move_to_targets_phase::choose_move(), ai::ai_default_rca::goto_phase::evaluate(), ai::ai_default_rca::leader_shares_keep_phase::execute(), ai::default_ai_context_impl::find_targets(), ai::ai_default_rca::get_villages_phase::find_villages(), gamemap::get_weighted_terrain_frequencies(), lua_map_location::intf_distance_between(), ai::readonly_context_impl::nearest_keep(), rank_castle_location(), and reality_check_get_direction_helper().
|
inline |
Function which, given a location, will place all adjacent locations in res.
inline get_adjacent, and get_distance functions
res must point to an array of 6 location objects.
Definition at line 274 of file location.hpp.
References map_location::x, and map_location::y.
Referenced by pathfind::a_star_search(), unit::ability_active(), ai::attack_analysis::analyze(), ai::ai_default_rca::aspect_attacks_base::analyze_targets(), backstab_check(), cave_map_generator::cave_map_generator_job::build_chamber(), actions::shroud_clearer::clear_dest(), actions::shroud_clearer::clear_loc(), game_logic::attack_map_callable::collect_possible_attacks(), ai::default_ai_context_impl::count_free_hexes_in_castle(), events::mouse_handler::current_unit_attacks_from(), default_map_generator_job::default_generate_map(), ai::ai_default_rca::aspect_attacks_base::do_attack_analysis(), ai::ai_default_rca::move_to_targets_phase::enemies_along_path(), pathfind::enemy_zoc(), ai::ai_default_rca::retreat_phase::evaluate(), pathfind::find_routes(), ai::default_ai_context_impl::find_targets(), pathfind::find_vacant_tile(), flood_name(), default_map_generator_job::generate_river_internal(), ai::keeps_cache::get(), unit::get_abilities(), unit::get_ability_bool(), events::mouse_handler::get_adj_enemies(), editor::editor_map::get_contiguous_terrain_tiles(), display::get_fog_shroud_images(), tod_manager::get_illuminated_time_of_day(), ai::formula_ai::get_keeps(), gamemap::get_terrain(), display::get_terrain_images(), get_tiles_radius(), basic_unit_filter_impl::internal_matches_filter(), lua_map_location::intf_get_adjacent_tiles(), terrain_filter::match_internal(), editor::mouse_action_unit::move(), editor::mouse_action_item::move(), ai::ai_default_rca::move_to_targets_phase::move_group(), cave_map_generator::cave_map_generator_job::place_castle(), place_village(), ai::readonly_context_impl::power_projection(), gamemap::set_terrain(), ai::formula_ai::shortest_path_calculator(), events::mouse_handler::show_attack_options(), attack_type::special_active(), display_context::unit_can_move(), and display_context::would_be_discovered().
std::ostream& operator<< | ( | std::ostream & | s, |
map_location const & | l | ||
) |
Dumps a position on a stream, for debug purposes.
Definition at line 37 of file location.cpp.
References map_location::x, and map_location::y.
std::ostream& operator<< | ( | std::ostream & | s, |
std::vector< map_location > const & | v | ||
) |
Dumps a vector of positions on a stream, for debug purposes.
Definition at line 41 of file location.cpp.
References i.
void read_locations | ( | const config & | cfg, |
std::vector< map_location > & | locs | ||
) |
Parse x,y keys of a config into a vector of locations.
Throws bad_lexical_cast if it fails to parse.
Definition at line 413 of file location.cpp.
References read_locations_helper(), and utils::split().
Referenced by fix_rename_command(), actions::shroud_clearing_action::shroud_clearing_action(), soundsource::sourcespec::sourcespec(), and SYNCED_COMMAND_HANDLER_FUNCTION().
|
inline |
Function which tells if two locations are adjacent.
Definition at line 314 of file location.hpp.
References map_location::x, and map_location::y.
Referenced by wb::attack::attack(), ai::formula_ai::can_reach_unit(), ai::attack_result::do_check_before(), footsteps_images(), lua_map_location::intf_tiles_adjacent(), unit_display::unit_mover::proceed_to(), reality_check_get_direction_helper(), and arrow::update_symbols().
void write_location_range | ( | const std::set< map_location > & | locs, |
config & | cfg | ||
) |
Write a set of locations into a config using ranges, adding keys x=x1,..,xn and y=y1a-y1b,..,yna-ynb.
Definition at line 371 of file location.cpp.
References i.
Referenced by tod_manager::to_config(), and team::write().
void write_locations | ( | const std::vector< map_location > & | locs, |
config & | cfg | ||
) |
Write a vector of locations into a config adding keys x=x1,x2,..,xn and y=y1,y2,..,yn.
Definition at line 425 of file location.cpp.
References i.
Referenced by replay_helper::get_movement(), actions::shroud_clearing_action::write(), and soundsource::positional_source::write_config().