33 std::vector<map_location>& result)
41 for(
int n = 0;
n != 6; ++
n) {
43 for(
int i = 0;
i != radius; ++
i) {
44 result.push_back(
loc);
57 std::vector<map_location>& result)
59 for(
int n = 1;
n <= radius; ++
n) {
71 std::set<map_location>& result)
74 std::vector<map_location> internal_result(1, center);
78 result.insert(internal_result.begin(), internal_result.end());
85 typedef std::pair<int, std::size_t> row_range;
87 typedef std::map<int, std::set<row_range>> column_ranges;
97 void get_column_ranges(column_ranges & collected_tiles,
98 const std::vector<map_location>& locs,
99 const std::size_t radius,
100 const int col_begin,
const int col_end)
102 #ifdef __cpp_using_enum
112 const int radius_i =
static_cast<int>(radius);
118 std::size_t height = radius;
121 if ( top.
x < col_begin ) {
122 const int col_shift = std::min(col_begin,
loc.
x) - top.
x;
127 const int end_l = std::min(
loc.
x, col_end);
129 collected_tiles[top.
x].insert(row_range(top.
y, ++height));
133 if ( top.
x < col_begin ) {
134 const int col_shift = col_begin - top.
x;
139 const int end_r = std::min(
loc.
x + radius_i + 1, col_end);
141 collected_tiles[top.
x].insert(row_range(top.
y, --height));
155 void ranges_to_tiles(std::set<map_location> & result,
156 const column_ranges & collected_tiles,
157 int row_begin,
int row_end)
163 auto insert_hint = result.begin();
165 for(
const auto& [column, range] : collected_tiles) {
171 int next_row = row_begin;
173 for(
const auto& [row_index, num_rows] : range) {
175 if(next_row < row_index) {
176 next_row = row_index;
180 const int end = std::min(row_index +
static_cast<int>(num_rows), row_end);
181 for(; next_row <
end; ++next_row) {
182 insert_hint = result.insert(++insert_hint,
map_location(column, next_row));
186 if(next_row >= row_end) {
204 std::size_t radius, std::set<map_location>& result,
211 result.insert(locs.begin(), locs.end());
213 if ( radius != 0 && !locs.empty() )
216 column_ranges collected_tiles;
224 get_column_ranges(collected_tiles, locs, radius, -
border, map.
w() +
border);
231 ranges_to_tiles(result, collected_tiles, -
border, map.
h() +
border);
243 std::size_t radius, std::set<map_location> &result,
244 bool with_border,
const xy_pred& pred)
int w() const
Effective map width.
int h() const
Effective map height.
bool on_board_with_border(const map_location &loc) const
int border_size() const
Size of the map border.
bool on_board(const map_location &loc) const
Tell if a location is on the map.
Encapsulates the map of the game.
@ border
The border of the map.
T end(const std::pair< T, T > &p)
std::set< map_location > location_set
void get_tiles_in_radius(const map_location ¢er, const int radius, std::vector< map_location > &result)
Function that will add to result all locations within radius tiles of center (excluding center itself...
void get_tiles_radius(const map_location ¢er, 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...
void get_tile_ring(const map_location ¢er, 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...
Encapsulates the map of the game.
map_location get_direction(direction dir, unsigned int n=1u) const
direction
Valid directions which can be moved in our hexagonal world.
static const map_location & null_location()
static map_location::direction n