The Battle for Wesnoth  1.17.0-dev
pathutils.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2018 by David White <dave@whitevine.net>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include "map/location.hpp"
18 
19 class gamemap;
20 
21 class xy_pred
22 {
23 public:
24  virtual bool operator()(const map_location&) const = 0;
25 protected:
26  virtual ~xy_pred() {}
27 };
28 
29 /**
30  * Function that will add to @a result all locations exactly @a radius tiles
31  * from @a center (or nothing if @a radius is not positive). @a result must be
32  * a std::vector of locations.
33  */
34 void get_tile_ring(const map_location& center, const int radius,
35  std::vector<map_location>& result);
36 
37 /**
38  * Function that will add to @a result all locations within @a radius tiles
39  * of @a center (excluding @a center itself). @a result must be a std::vector
40  * of locations.
41  */
42 void get_tiles_in_radius(const map_location& center, const int radius,
43  std::vector<map_location>& result);
44 
45 /**
46  * Function that will add to @a result all locations within @a radius tiles
47  * of @a center (including @a center itself). @a result must be a std::set
48  * of locations.
49  */
50 void get_tiles_radius(const map_location& center, std::size_t radius,
51  std::set<map_location>& result);
52 
53 /**
54  * Function that will add to @a result all elements of @a locs, plus all
55  * on-board locations that are within @a radius tiles of an element of locs.
56  * @a result must be a std::set of locations.
57  */
58 void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
59  std::size_t radius, std::set<map_location>& result,
60  bool with_border=false);
61 
62 /**
63  * Function that will add to @a result all elements of @a locs, plus all
64  * on-board locations matching @a pred that are connected to elements of
65  * locs by a chain of at most @a radius tiles, each of which matches @a pred.
66  * @a result must be a std::set of locations.
67  */
68 void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
69  std::size_t radius, std::set<map_location>& result,
70  bool with_border, const xy_pred &pred);
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...
Definition: pathutils.cpp:69
virtual bool operator()(const map_location &) const =0
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...
Definition: pathutils.cpp:31
Encapsulates the map of the game.
Definition: map.hpp:170
virtual ~xy_pred()
Definition: pathutils.hpp:26
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...
Definition: pathutils.cpp:55
Encapsulates the map of the game.
Definition: location.hpp:37