Terrain filters respect "with_border" for their radius...
...(as well as for everything else).
This commit is contained in:
parent
9428d7fbd9
commit
560b5cb2fd
3 changed files with 14 additions and 11 deletions
|
@ -75,7 +75,8 @@ void get_tiles_radius(const map_location& a, size_t radius,
|
|||
}
|
||||
|
||||
void get_tiles_radius(gamemap const &map, std::vector<map_location> const &locs,
|
||||
size_t radius, std::set<map_location> &res, xy_pred *pred)
|
||||
size_t radius, std::set<map_location> &res, bool with_border,
|
||||
xy_pred *pred)
|
||||
{
|
||||
typedef std::set<map_location> location_set;
|
||||
location_set not_visited(locs.begin(), locs.end()), must_visit, filtered_out;
|
||||
|
@ -89,11 +90,13 @@ void get_tiles_radius(gamemap const &map, std::vector<map_location> const &locs,
|
|||
get_adjacent_tiles(*it, adj);
|
||||
for(size_t i = 0; i != 6; ++i) {
|
||||
map_location const &loc = adj[i];
|
||||
if(map.on_board(loc) && !res.count(loc) && !filtered_out.count(loc)) {
|
||||
if(!pred || (*pred)(loc)) {
|
||||
must_visit.insert(loc);
|
||||
} else {
|
||||
filtered_out.insert(loc);
|
||||
if ( with_border ? map.on_board_with_border(loc) :
|
||||
map.on_board(loc) ) {
|
||||
if ( !res.count(loc) && !filtered_out.count(loc) ) {
|
||||
if ( !pred || (*pred)(loc) )
|
||||
must_visit.insert(loc);
|
||||
else
|
||||
filtered_out.insert(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void get_tiles_radius(const map_location& a, size_t radius,
|
|||
|
||||
/** Function which, given a set of locations, will find all tiles within 'radius' of those tiles */
|
||||
void get_tiles_radius(const gamemap& map, const std::vector<map_location>& locs, size_t radius,
|
||||
std::set<map_location>& res, xy_pred *pred=NULL);
|
||||
std::set<map_location>& res, bool with_border=false, xy_pred *pred=NULL);
|
||||
|
||||
/**
|
||||
* Function which, given a location, will place all locations in the radius of r in res
|
||||
|
|
|
@ -321,7 +321,7 @@ bool terrain_filter::match(const map_location& loc) const
|
|||
}
|
||||
if(cfg_.has_child("filter_radius")) {
|
||||
terrain_filter r_filter(cfg_.child("filter_radius"), *this);
|
||||
get_tiles_radius(*resources::game_map, loc_vec, radius, hexes, &r_filter);
|
||||
get_tiles_radius(*resources::game_map, loc_vec, radius, hexes, false, &r_filter);
|
||||
} else {
|
||||
get_tiles_radius(*resources::game_map, loc_vec, radius, hexes);
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
const vconfig::child_list& adj_cfgs = cfg_.get_children("filter_adjacent_location");
|
||||
for (unsigned i = 0; i < adj_cfgs.size(); ++i) {
|
||||
std::set<map_location> adj_set;
|
||||
/* GCC-3.3 doesn't like operator[] so use at which has the same result */
|
||||
/* GCC-3.3 doesn't like operator[] so use at(), which has the same result */
|
||||
terrain_filter(adj_cfgs.at(i), *this).get_locations(adj_set, with_border);
|
||||
cache_.adjacent_matches->push_back(adj_set);
|
||||
if(i >= max_loop_ && i+1 < adj_cfgs.size()) {
|
||||
|
@ -504,9 +504,9 @@ void terrain_filter::get_locations(std::set<map_location>& locs, bool with_borde
|
|||
std::copy(xy_set.begin(),xy_set.end(),std::inserter(xy_vector,xy_vector.end()));
|
||||
if(cfg_.has_child("filter_radius")) {
|
||||
terrain_filter r_filter(cfg_.child("filter_radius"), *this);
|
||||
get_tiles_radius(*resources::game_map, xy_vector, radius, locs, &r_filter);
|
||||
get_tiles_radius(*resources::game_map, xy_vector, radius, locs, with_border, &r_filter);
|
||||
} else {
|
||||
get_tiles_radius(*resources::game_map, xy_vector, radius, locs);
|
||||
get_tiles_radius(*resources::game_map, xy_vector, radius, locs, with_border);
|
||||
}
|
||||
} else {
|
||||
std::copy(xy_set.begin(),xy_set.end(),std::inserter(locs,locs.end()));
|
||||
|
|
Loading…
Add table
Reference in a new issue