Robertdebrus / ANLEra

ANLEra add-on for Battle for Wesnoth
GNU General Public License v2.0
2 stars 2 forks source link

errors at gamestart logged in stderr #18

Closed sevu closed 6 years ago

sevu commented 6 years ago

This line is listed very often at gamestart in stderr.

20171014 23:57:20 error engine: failed to auto-store $unit at (-999,-999)
20171014 23:57:20 error engine: failed to auto-store $unit at (-999,-999)
20171014 23:57:20 error engine: failed to auto-store $unit at (-999,-999)
...

Other than that, this also appears in stderr, but not at game start.

20171015 00:05:27 error scripting/lua: [option]message= is deprecated, use label= instead.
20171015 00:05:27 error scripting/lua: The &image=col1=col2 syntax is deprecated, use new DescriptionWML instead.

Edit: the 2nd is related to the new 1.13 syntax, this can only be fixed when dropping 1.12 support.

sevu commented 6 years ago

The 1st is resolved by the commits linked here. The remaining of the 2nd are all in the SP modification – which should use the building option macros from utils too, as there is no point in maintaining separate copy-pasted code.

Robertdebrus commented 6 years ago

The problem is that WORKER_OPTIONS TYPES does not account for unit level, which is what I am doing with SP_WORKER_OPTIONS Now, I will work on copying your better macros over to the sp version, unless there is a way of making a macro have two optional arguments that I have forgotten

sevu commented 6 years ago

This problem should be better solved on the macro level, as when further adding or changing this they would need to be copied again. And currently that file is all but carved in stone.

Optional arguments – that can be done, new in 1.13. Optional in the sense of really optional. Edit: looking for an code example

sevu commented 6 years ago

Okay, an (optional) macro has the problem that the change is needed in the [show_if] macro, and that is called by the macro we want to include – so we would need to give an optional macro to both.

I though about the ANL_SHOW_IF macro slightly being different, that it does not contain type= but that this is given by the macro too, and in MP one could give type=Peasant,Ruffian, ... while SP gives

level=0 (linebreak is important here)
type= (may be empty, but is needed for the cases where an type is appended with some building macros)

However, it's a bit fragile, I'm not sure if the preprocessor may just list type first, and then the appending may not work.

What I hoped a bit was to reuse the macros without changes among SP and MP, so redefinition can be skipped entirely (#38), but… An easy way for that would to have the condition in ANL_SHOW_IF baked in, taking care of both, playing by modification or era.

#define ANL_SHOW_IF TYPES TERRAINLIST
    [show_if]
        [have_unit]
            side=$side_number
            x,y=$x1,$y1
            type={TYPES}
            [filter_location]
                terrain={TERRAINLIST}
            [/filter_location]
            [or]
                side=$side_number
                x,y=$x1,$y1
                level=0
                [not]
                    type={ALL_TYPES_USED_BY_ANLERA}
                [/not]
                [filter_location]
                    terrain={TERRAINLIST}
                [/filter_location]
            [/or]
        [/have_unit]
    [/show_if]
#enddef

In case you don't like to have the most of the filter twice:

#define ANL_SHOW_IF TYPES TERRAINLIST
    [show_if]
        [have_unit]
            side=$side_number
            x,y=$x1,$y1
            [filter_location]
                terrain={TERRAINLIST}
            [/filter_location]
            [and]
                type={TYPES}
                [or]
                    level=0
                    [not]
                        type={ALL_BUILDERS_KNOWN_TO_ANLERA}
                    [/not]
                [/or]
            [/and]
        [/have_unit]
    [/show_if]
#enddef

TYPES, is what one gets from the definition of the actions, e.g. it may or may not contain the Merman Citizen or Peasant. ALL_BUILDERS_KNOWN_TO_ANLERA takes care of not having the Merman Citizien building all kind of things – basically it takes care of SP, while the other valid condition for the [or] takes care of SP.

[When I talked about SP and MP I mean modification vs era, I think the modification would be technically usable for MP too]

PS: credit for the macros goes entirely to Lukc

Robertdebrus commented 6 years ago

One problem with this is that I want all lvl 0s to be able to build in SP, and don't want the era to do this too. I'm trying to remember, is there a tag for only in SP? That could make it easier to make a macro for both

Robertdebrus commented 6 years ago

Actually, I just checked again, at the errors are all gone as of my latest commit

sevu commented 6 years ago

The change to the condition above would allow all lvl 0 in SP to build, expect for the Woodsman who has hunter treatment:

Let's all lvl 0 build, except Peasants, Ruffians, …

level=0
[not]
    type=ALL_BUILDERS_KNOWN_TO_ANLERA
[/not]

Let's the units mentioned in the macros build – which usually are all mainlines ones. A rare exception would be that they can't remove water lilies (which can only do the merfolk, or units matched by the condition above. Peasants can't be added in the condition above because that allows them to remove water lilies when playing with the era too)

[or]
    type={TYPES}
[/or]

Yes, all errors of this issue are gone.

sevu commented 6 years ago

Want to note that the merman case I mentioned above is not directly relevant, as SP doesn't allow doing anything similar to what is defined in utils/buildings/, like removing water lilies or building any kind of castle or village.

I also want to note that using race= instead of type= for the worker actions would allow a more general usage of these macros (and allow in SP village/castle variations too) — the drawback is that Outlaws and Loyalists have the same race.

The unification of both worlds would be to allow both, either by