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, 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,
100 const int col_begin,
const int col_end)
108 const int radius_i =
static_cast<int>(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)
157 std::set<map_location>::const_iterator insert_hint = result.begin();
161 for (
const column_ranges::value_type &
column : collected_tiles)
168 int next_row = row_begin;
169 for (
const row_range &rows :
column.second)
172 if ( next_row < rows.first )
173 next_row = rows.first;
176 const int end = std::min(rows.first + static_cast<int>(rows.second),
178 for ( ; next_row <
end; ++next_row )
179 insert_hint = result.insert(++insert_hint,
183 if ( next_row >= row_end )
200 size_t radius, std::set<map_location>& result,
207 result.insert(locs.begin(), locs.end());
209 if ( radius != 0 && !locs.empty() )
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 size_t radius, std::set<map_location> &result,
240 bool with_border,
xy_pred const &pred)
242 typedef std::set<map_location> location_set;
244 location_set must_visit, filtered_out;
245 location_set not_visited(locs.begin(), locs.end());
247 for ( ; radius != 0 && !not_visited.empty(); --radius )
249 location_set::const_iterator it = not_visited.begin();
250 location_set::const_iterator it_end = not_visited.end();
252 result.insert(it, it_end);
253 for(; it != it_end; ++it) {
256 for(
size_t i = 0;
i != 6; ++
i) {
260 if ( !result.count(loc) && !filtered_out.count(loc) ) {
262 must_visit.insert(loc);
264 filtered_out.insert(loc);
270 not_visited.swap(must_visit);
274 result.insert(not_visited.begin(), not_visited.end());
bool on_board_with_border(const map_location &loc) const
void get_adjacent_tiles(const map_location &a, map_location *res)
Function which, given a location, will place all adjacent locations in res.
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_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...
int w() const
Effective map width.
Encapsulates the map of the game.
int border_size() const
Size of the map border.
static const map_location & null_location()
Encapsulates the map of the game.
GLenum GLenum GLvoid GLvoid * column
int h() const
Effective map height.
DIRECTION
Valid directions which can be moved in our hexagonal world.
void get_tiles_radius(const map_location ¢er, size_t radius, std::set< map_location > &result)
Function that will add to result all locations within radius tiles of center (including center itself...
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
GLint GLint GLsizei GLsizei GLsizei GLint border
bool on_board(const map_location &loc) const
Tell if a location is on the map.
map_location get_direction(DIRECTION d, unsigned int n=1u) const