Support [terrain_defaults]'s original subtag names
This is preparation for backporting 0ba433203e
, with the idea that both sets
of names will be supported in both branches.
No deprecation messages are added. While config::get_attribute_value() has a
config::get_old_attribute_value(), there isn't currently a similar utility for
config::child(); maybe I should add one now, but it feels too large a change
for a backport.
This commit is contained in:
parent
c1c80e3a7f
commit
3522eb2c2a
2 changed files with 18 additions and 7 deletions
|
@ -20,6 +20,7 @@
|
|||
### WML Engine
|
||||
* Standard Location Filters now support gives_income=yes|no to make it simpler to match villages regardless of owner
|
||||
### Miscellaneous and Bug Fixes
|
||||
* Added support for 1.14’s tag names in `[terrain_defaults]` (issue #5308).
|
||||
|
||||
## Version 1.15.10
|
||||
### Add-ons server
|
||||
|
|
|
@ -1122,23 +1122,33 @@ void unit_type_data::set_config(const game_config_view& cfg)
|
|||
|
||||
struct ter_defs_to_movetype
|
||||
{
|
||||
/** The data to read from is in [terrain_defaults][subtag] */
|
||||
/** The data to read from is in [terrain_defaults][subtag], and corresponds to [movetype][subtag] */
|
||||
std::string subtag;
|
||||
/** Deprecated names used in 1.14.0's [terrain_defaults]. For [defense] the name didn't change. */
|
||||
std::string alias;
|
||||
int default_val;
|
||||
};
|
||||
const std::array<ter_defs_to_movetype, 4> terrain_info_tags{
|
||||
ter_defs_to_movetype{{"movement_costs"}, movetype::UNREACHABLE},
|
||||
ter_defs_to_movetype{{"vision_costs"}, movetype::UNREACHABLE},
|
||||
ter_defs_to_movetype{{"jamming_costs"}, movetype::UNREACHABLE},
|
||||
ter_defs_to_movetype{{"defense"}, 100}
|
||||
ter_defs_to_movetype{{"movement_costs"}, {"movement"}, movetype::UNREACHABLE},
|
||||
ter_defs_to_movetype{{"vision_costs"}, {"vision"}, movetype::UNREACHABLE},
|
||||
ter_defs_to_movetype{{"jamming_costs"}, {"jamming"}, movetype::UNREACHABLE},
|
||||
ter_defs_to_movetype{{"defense"}, {"defense"}, 100}
|
||||
};
|
||||
|
||||
for(const auto& cost_type : terrain_info_tags) {
|
||||
if(!terrain.has_child(cost_type.subtag)) {
|
||||
const std::string* src_tag = nullptr;
|
||||
if(terrain.has_child(cost_type.subtag)) {
|
||||
src_tag = &cost_type.subtag;
|
||||
}
|
||||
else if(terrain.has_child(cost_type.alias)) {
|
||||
// Check for the deprecated name, no deprecation warnings are printed.
|
||||
src_tag = &cost_type.alias;
|
||||
}
|
||||
if(!src_tag) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const config& info = terrain.child(cost_type.subtag);
|
||||
const config& info = terrain.child(*src_tag);
|
||||
|
||||
for(const config::attribute& attr : info.attribute_range()) {
|
||||
const std::string& mt = attr.first;
|
||||
|
|
Loading…
Add table
Reference in a new issue