The Battle for Wesnoth  1.19.0-dev
Functions
pathutils.cpp File Reference

Various pathfinding functions and utilities. More...

#include "pathutils.hpp"
#include "pathutils_impl.hpp"
#include "map/map.hpp"
Include dependency graph for pathutils.cpp:

Go to the source code of this file.

Functions

void get_tile_ring (const map_location &center, const int radius, std::vector< map_location > &result)
 Function that will add to result all locations exactly radius tiles from center (or nothing if radius is not positive). More...
 
void get_tiles_in_radius (const map_location &center, const int radius, std::vector< map_location > &result)
 Function that will add to result all locations within radius tiles of center (excluding center itself). More...
 
void get_tiles_radius (const map_location &center, std::size_t radius, std::set< map_location > &result)
 Function that will add to result all locations within radius tiles of center (including center itself). More...
 
void get_tiles_radius (const gamemap &map, const std::vector< map_location > &locs, std::size_t radius, std::set< map_location > &result, bool with_border)
 Function that will add to result all elements of locs, plus all on-board locations that are within radius tiles of an element of locs. More...
 
void get_tiles_radius (const gamemap &map, const std::vector< map_location > &locs, std::size_t radius, std::set< map_location > &result, bool with_border, const xy_pred &pred)
 Function that will add to result all elements of locs, plus all on-board locations matching pred that are connected to elements of locs by a chain of at most radius tiles, each of which matches pred. More...
 

Detailed Description

Various pathfinding functions and utilities.

Definition in file pathutils.cpp.

Function Documentation

◆ get_tile_ring()

void get_tile_ring ( const map_location center,
const int  radius,
std::vector< map_location > &  result 
)

Function that will add to result all locations exactly radius tiles from center (or nothing if radius is not positive).

result must be a std::vector of locations.

Definition at line 32 of file pathutils.cpp.

References map_location::get_direction(), i, n, and map_location::SOUTH_WEST.

Referenced by get_tiles_in_radius().

◆ get_tiles_in_radius()

void get_tiles_in_radius ( const map_location center,
const int  radius,
std::vector< map_location > &  result 
)

Function that will add to result all locations within radius tiles of center (excluding center itself).

result must be a std::vector of locations.

Definition at line 56 of file pathutils.cpp.

References get_tile_ring(), and n.

Referenced by editor::brush::brush(), wfl::builtins::DEFINE_WFL_FUNCTION(), wfl::gamestate::DEFINE_WFL_FUNCTION(), get_tiles_radius(), lua_map_location::intf_get_tiles_in_radius(), ai::default_recruitment::recruitment::is_enemy_in_radius(), and ai::default_recruitment::recruitment::update_important_hexes().

◆ get_tiles_radius() [1/3]

void get_tiles_radius ( const gamemap map,
const std::vector< map_location > &  locs,
std::size_t  radius,
std::set< map_location > &  result,
bool  with_border 
)

Function that will add to result all elements of locs, plus all on-board locations that are within radius tiles of an element of locs.

result must be a std::set of locations.

Definition at line 199 of file pathutils.cpp.

References gamemap_base::border_size(), gamemap_base::h(), and gamemap_base::w().

◆ get_tiles_radius() [2/3]

void get_tiles_radius ( const gamemap map,
const std::vector< map_location > &  locs,
std::size_t  radius,
std::set< map_location > &  result,
bool  with_border,
const xy_pred pred 
)

Function that will add to result all elements of locs, plus all on-board locations matching pred that are connected to elements of locs by a chain of at most radius tiles, each of which matches pred.

result must be a std::set of locations.

Definition at line 238 of file pathutils.cpp.

References get_tiles_radius(), gamemap_base::on_board(), and gamemap_base::on_board_with_border().

◆ get_tiles_radius() [3/3]

void get_tiles_radius ( const map_location center,
std::size_t  radius,
std::set< map_location > &  result 
)

Function that will add to result all locations within radius tiles of center (including center itself).

result must be a std::set of locations.

Definition at line 70 of file pathutils.cpp.

References get_tiles_in_radius().

Referenced by terrain_filter::get_locs_impl(), get_tiles_radius(), intf_mg_get_tiles_radius(), terrain_filter::match_impl(), and place_village().