wesnoth / wesnoth

An open source, turn-based strategy game with a high fantasy theme.
https://www.wesnoth.org/
GNU General Public License v2.0
5.51k stars 1.02k forks source link

Weapon special filters can be affected by the weapon special leading to infinite recursion #8940

Open soliton- opened 4 months ago

soliton- commented 4 months ago

Describe the desired feature

When defining a weapon special one can specify a unit filter to decide when the weapon special should be active.

Example:

[damage_type]
  id=foo
  ...
  [filter_self]
    [has_attack]
      type = pierce
    [/has_attack]
  [/filter_self]
[/damage_type]

In this example the attack filter ([has_attack]) in the unit filter ([filter_self]) will ask for the attack type to compare to "pierce" which will in turn trigger another filter matching to figure out the attack type considering the weapon special, etc.

This should be fixed by either not allowing an attack filter in a weapon special unit filter (for the basic case of one specific attack with a weapon special it doesn't really seem useful) or somehow do something sensible anyway.

newfrenchy83 commented 4 months ago

are you using alternative_type attribute in msterbranch for your test?

newfrenchy83 commented 4 months ago

have you used [filter_weapon] instead or [has_attack] before to title this issue,because infinite recusion already solved for [filter_weapon].

newfrenchy83 commented 4 months ago

@soliton- added two PR for resolve this issue

stevecotton commented 4 months ago

I'm wondering if we need to put a recursion-check into the whole filter mechanism, not just for attacks but for all filters that take one or two units or one or two weapons to detect that they're being asked a question recursively.