Honor special locations in terrain mask

A [terrain_mask] is simply a map. It can be smaller than the map, and can be offset. As a map, it can give special locations which can be used to position units, and queried by WML. With this change the names are properly applied to the underlying map, offset relative to the [terrain_mask]. A name given in the [terrain_mask] replaces that name in the underlying map, regardless of the original location. A map file can define only one name per location. A name can have only one location; but a location can have any number of names. To define additional names for a location, stack [terrain_mask] maps giving each. Once placed on the map, a name cannot be removed.
This commit is contained in:
Gregory A Lundberg 2016-09-15 00:12:13 -05:00
parent dc89612dc4
commit 8be428e946
2 changed files with 15 additions and 6 deletions

View file

@ -44,6 +44,14 @@ Version 1.13.5+dev:
* Fix issue with the title screen not redrawing when the window size or
fullscreen setting changes with a dialog open over it.
* WML Engine:
* Added ignore_special_locations=yes|no, default no, to [terrain_mask] to
ignore the special locations given in the mask, leaving all those on the
underlying map unchanged.
* [terrain_mask] starting locations and special locations are relative to
the mask. Existing names replace any in the underlying map regardless of
their location. Each name as a unique location; but a location may have
any number of names. While a map/mask can give only one name per location;
stacking masks allows multiple names. Names cannot be removed.
* Added {HAS_NO_TURN_LIMIT} macro for objectives
* New attributes for [message] with [option]
* Added variable= to [message]: if specified, gives variable name to

View file

@ -325,15 +325,16 @@ void gamemap::overlay(const gamemap& m, const config& rules_cfg, int xpos, int y
}
else {
set_terrain(map_location(x2,y2), t);
if (false /*TODO: add overwrite special locs paramter*/) {
starting_positions_.right.erase(t_translation::coordinate(x2, y2));
for (auto& pair : m.starting_positions_.right.equal_range(t_translation::coordinate(x1, y1))) {
starting_positions_.insert(tstarting_positions::value_type(pair.second, t_translation::coordinate(x2, y2)));
}
}
}
}
}
if (!rules_cfg["ignore_special_locations"].to_bool(false)) {
for(auto& pair : m.starting_positions_.left) {
starting_positions_.left.erase(pair.first);
starting_positions_.insert(tstarting_positions::value_type(pair.first, t_translation::coordinate(pair.second.x + xpos, pair.second.y + ypos+ ((xpos & 1) && (pair.second.x & 1) ? 1 : 0))));
}
}
}
t_translation::t_terrain gamemap::get_terrain(const map_location& loc) const