NAMED_LOYAL_UNIT has the loyal trait built in, so this results in an
extra copy of it being granted to the unit.
(cherry picked from commit c64777433ae35af2895adaddd1677eccd6f4541d)
These functions are not used anywhere, and they have other issues besides the one fixed in this commit – they're implied to return all moves, but they only return one move for each possibly destination hex. However, this will make them at least be minimally usable.
Since the detection happens after loading the config tree, it is necessary to expose the links and subtypes of the types alias and composite, respectively.
This implementation builds a graph of all links to detect cycles, ignoring all other types.
To handle links in elements of lists, all subtypes of composite types are visited, keeping the type name of the parent composite type.
Signed-off-by: Rafael Fillipe Silva <rfsc.mori@gmail.com>
This pattern presents the same infinite loop issue as the find_key and find_tag calls on wml_tag. The solution is the same, to use a helper to keep track of the already seen tags and stop when a cycle is detected.
Note that this is only detected if the tag referencing the missing super is used in a .cfg file. The super element itself doesn't need to be used for the detection to work.
The schema self validator should already catch this, but it deserves a warning of its own as the schema self validator can be disabled.
Note that if the .cfg file does not use the tags that causes a cycle, those won't be detected.
This change exposes the super_refs_ so the schema validator does not need to reinvent wml_tag::expand when detecting super cycles.
The super dependency graph is built during the validation of each tag, finishing and reporting cycles at the end of the root tag.
Adds a test with a schema example containing a super cycle and a .cfg file containing an unknown key to this schema. Previously, this would cause an infinite loop or crash. Now an exception for invalid key should be thrown.
A super cycle may be found during the validation, leading to an infinite loop. For example, calling find_key on an unknown key defined in the .cfg file may trigger this behavior if a cycle exists.
To handle this, a new version of these functions was introduced, keeping the original in the class' private scope. During the search there is a bookkeeping helper that will cause the routine to return nullptr if the search goes back to the initial tag context.
Add test for the already existing validation where a tag shouldn't set itself as its own super.
Add test for the new cycle detection when validating a schema.
The super tag dependency forms a directed graph. Boost Graph's depth first search implementation was used with a back edge detector to find the cycles.
This is a preparation for enumerating all keys that a tag can use, including the keys from the super tags. If cycles aren't handled, it is impossible to validate mandatory keys without entering an infinite loop.
Just some debris embellishments to suggest that the towers at the
end of the bridges were hit with siege weapons. The defense stats
are still the same and there's no dialogue change to go with this.