The Battle for Wesnoth  1.15.2+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 /** @file */
16 
17 #pragma once
18 
19 #include "map/location.hpp"
20 
21 class gamemap;
22 
23 class xy_pred
24 {
25 public:
26  virtual bool operator()(const map_location&) const = 0;
27 protected:
28  virtual ~xy_pred() {}
29 };
30 
31 /**
32  * Function that will add to @a result all locations exactly @a radius tiles
33  * from @a center (or nothing if @a radius is not positive). @a result must be
34  * a std::vector of locations.
35  */
36 void get_tile_ring(const map_location& center, const int radius,
37  std::vector<map_location>& result);
38 
39 /**
40  * Function that will add to @a result all locations within @a radius tiles
41  * of @a center (excluding @a center itself). @a result must be a std::vector
42  * of locations.
43  */
44 void get_tiles_in_radius(const map_location& center, const int radius,
45  std::vector<map_location>& result);
46 
47 /**
48  * Function that will add to @a result all locations within @a radius tiles
49  * of @a center (including @a center itself). @a result must be a std::set
50  * of locations.
51  */
52 void get_tiles_radius(const map_location& center, std::size_t radius,
53  std::set<map_location>& result);
54 
55 /**
56  * Function that will add to @a result all elements of @a locs, plus all
57  * on-board locations that are within @a radius tiles of an element of locs.
58  * @a result must be a std::set of locations.
59  */
60 void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
61  std::size_t radius, std::set<map_location>& result,
62  bool with_border=false);
63 
64 /**
65  * Function that will add to @a result all elements of @a locs, plus all
66  * on-board locations matching @a pred that are connected to elements of
67  * locs by a chain of at most @a radius tiles, each of which matches @a pred.
68  * @a result must be a std::set of locations.
69  */
70 void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs,
71  std::size_t radius, std::set<map_location>& result,
72  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:36
virtual ~xy_pred()
Definition: pathutils.hpp:28
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:42