New type_tree key in SUF - matches the unit type or its advancements
This commit is contained in:
parent
679565a5fd
commit
22763798c7
2 changed files with 19 additions and 0 deletions
|
@ -60,6 +60,8 @@ Version 1.13.5+dev:
|
|||
* Fixed issues with using [endlevel] in victory/defeat events
|
||||
* The {MAGENTA_IS_THE_TEAM_COLOR} macro is no longer needed in [unit_type]
|
||||
It is now the default behaviour unless overridden with the flag_rgb key.
|
||||
* New key type_tree in unit filters - similar to type, but also matches any
|
||||
possible advancements of the specified unit types.
|
||||
* Lua API:
|
||||
* Added new functions wesnoth.fire_event_by_id and fire_event_by_name. The
|
||||
old function wesnoth.fire_event is now an alias for wesnoth.fire_event_by_name
|
||||
|
|
|
@ -320,6 +320,23 @@ bool basic_unit_filter_impl::internal_matches_filter(const unit & u, const map_l
|
|||
}
|
||||
}
|
||||
|
||||
// Shorthand for all advancements of a given type
|
||||
if (!vcfg["type_tree"].empty()) {
|
||||
std::set<std::string> types;
|
||||
for(const std::string type : utils::split(vcfg["type_tree"])) {
|
||||
if(types.count(type)) {
|
||||
continue;
|
||||
}
|
||||
if(const unit_type* ut = unit_types.find(type)) {
|
||||
const auto& tree = ut->advancement_tree();
|
||||
types.insert(tree.begin(), tree.end());
|
||||
}
|
||||
}
|
||||
if(types.find(u.type_id()) == types.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// The variation_type could be a comma separated list of types
|
||||
if (!vcfg["variation"].empty())
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue