made [clear/place_shroud] include the border by default (no x,y given)
fixed bug #14493: Black border in scenario "Showdown in the Northern Swamp"
This commit is contained in:
parent
0352fa2472
commit
5b80e34dd9
3 changed files with 23 additions and 15 deletions
|
@ -582,24 +582,29 @@ namespace {
|
|||
|
||||
static void toggle_shroud(const bool remove, const vconfig& cfg)
|
||||
{
|
||||
std::string side = cfg["side"];
|
||||
const int side_num = lexical_cast_default<int>(side,1);
|
||||
const size_t index = side_num-1;
|
||||
std::string side = cfg["side"];
|
||||
const int side_num = lexical_cast_default<int>(side,1);
|
||||
const size_t index = side_num-1;
|
||||
|
||||
if (index < resources::teams->size()) {
|
||||
std::set<map_location> locs;
|
||||
terrain_filter filter(cfg, *resources::units);
|
||||
filter.restrict_size(game_config::max_loop);
|
||||
filter.get_locations(locs);
|
||||
filter.restrict_size(game_config::max_loop);
|
||||
filter.get_locations(locs, true);
|
||||
|
||||
for(std::set<map_location>::const_iterator j = locs.begin(); j != locs.end(); ++j) {
|
||||
if(remove) {
|
||||
(*resources::teams)[index].clear_shroud(*j);
|
||||
} else {
|
||||
(*resources::teams)[index].place_shroud(*j);
|
||||
}
|
||||
for(std::set<map_location>::const_iterator j = locs.begin(); j != locs.end(); ++j) {
|
||||
if (j->x + 1 < 0 || j->y + 1 < 0) {
|
||||
LOG_NG << "invalid shroud location: (" << *j
|
||||
<< ") - border_size = " << resources::game_map->border_size() << std::endl;
|
||||
continue;
|
||||
}
|
||||
if(remove) {
|
||||
(*resources::teams)[index].clear_shroud(*j);
|
||||
} else {
|
||||
(*resources::teams)[index].place_shroud(*j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resources::screen->labels().recalculate_shroud();
|
||||
resources::screen->invalidate_all();
|
||||
|
|
|
@ -323,14 +323,17 @@ bool terrain_filter::match(const map_location& loc) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void terrain_filter::get_locations(std::set<map_location>& locs) const
|
||||
void terrain_filter::get_locations(std::set<map_location>& locs, bool with_border) const
|
||||
{
|
||||
std::vector<map_location> xy_vector = parse_location_range(cfg_["x"],cfg_["y"], resources::game_map);
|
||||
std::set<map_location> xy_set(xy_vector.begin(), xy_vector.end());
|
||||
if(xy_set.empty()) {
|
||||
//consider all locations on the map
|
||||
for(int x=0; x < resources::game_map->w(); x++) {
|
||||
for(int y=0; y < resources::game_map->h(); y++) {
|
||||
int bs = resources::game_map->border_size();
|
||||
int w = with_border ? resources::game_map->w() + bs : resources::game_map->w();
|
||||
int h = with_border ? resources::game_map->h() + bs : resources::game_map->h();
|
||||
for (int x = with_border ? 0 - bs : 0; x < w; ++x) {
|
||||
for (int y = with_border ? 0 - bs : 0; y < h; ++y) {
|
||||
xy_set.insert(map_location(x,y));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
//get_locations: gets all locations on the map that match this filter
|
||||
// @param locs - out parameter containing the results
|
||||
void get_locations(std::set<map_location>& locs) const;
|
||||
void get_locations(std::set<map_location>& locs, bool with_border=false) const;
|
||||
|
||||
//restrict: limits the allowed radius size and also limits nesting
|
||||
// The purpose to limit the time spent for WML handling
|
||||
|
|
Loading…
Add table
Reference in a new issue