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)
108 const int radius_i =
static_cast<int>(radius);
114 std::size_t height = radius;
117 if ( top.
x < col_begin ) {
118 const int col_shift = std::min(col_begin, loc.x) - top.
x;
123 const int end_l = std::min(loc.x, col_end);
125 collected_tiles[top.
x].insert(row_range(top.
y, ++height));
129 if ( top.
x < col_begin ) {
130 const int col_shift = col_begin - top.
x;
135 const int end_r = std::min(loc.x + radius_i + 1, col_end);
137 collected_tiles[top.
x].insert(row_range(top.
y, --height));
151 void ranges_to_tiles(std::set<map_location> & result,
152 const column_ranges & collected_tiles,
153 int row_begin,
int row_end)
159 auto insert_hint = result.begin();
161 for(
const auto& [column, range] : collected_tiles) {
167 int next_row = row_begin;
169 for(
const auto& [row_index, num_rows] : range) {
171 if(next_row < row_index) {
172 next_row = row_index;
176 const int end = std::min(row_index +
static_cast<int>(num_rows), row_end);
177 for(; next_row <
end; ++next_row) {
178 insert_hint = result.insert(++insert_hint,
map_location(column, next_row));
182 if(next_row >= row_end) {
200 std::size_t radius, std::set<map_location>& result,
207 result.insert(locs.begin(), locs.end());
209 if ( radius != 0 && !locs.empty() )
211 const int border = with_border ? map.
border_size() : 0;
212 column_ranges collected_tiles;
220 get_column_ranges(collected_tiles, locs, radius, -border, map.
w() + border);
227 ranges_to_tiles(result, collected_tiles, -border, map.
h() + border);
239 std::size_t radius, std::set<map_location> &result,
240 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.
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.
DIRECTION
Valid directions which can be moved in our hexagonal world.
map_location get_direction(DIRECTION dir, unsigned int n=1u) const
static const map_location & null_location()
static map_location::DIRECTION n