error deprecation: unit.side has been deprecated - query
Moderator: Forum Moderators
Forum rules
Before reporting issues in this section, you must read the following topic:
Before reporting issues in this section, you must read the following topic:
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
error deprecation: unit.side has been deprecated - query
Hi,
I'm (still ) developing a new campaign and have a query regarding the following warning that appears multiple times in the logfile.
That's fine but in my logic I also need to know
How will this be implemented in 1.17?
All help and suggestions gratefully appreciated!
Cheers!
-- Spannerbag
I'm (still ) developing a new campaign and have a query regarding the following warning that appears multiple times in the logfile.
error deprecation: unit.side has been deprecated and will be removed in version 1.17.0.; This returns 0 for side 1 etc and should not be used. Use side_number instead
That's fine but in my logic I also need to know
$second_unit.side
.How will this be implemented in 1.17?
All help and suggestions gratefully appreciated!
Cheers!
-- Spannerbag
-
- Posts: 484
- Joined: August 4th, 2019, 5:27 pm
Re: error deprecation: unit.side has been deprecated - query
Use side_number instead, as it's written.
So $second_unit.side_number, I guess
So $second_unit.side_number, I guess
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: error deprecation: unit.side has been deprecated - query
Thanks for the reply, but unless I've misunderstood (quite likely!) it just meansdwarftough wrote: ↑June 26th, 2022, 8:52 pm Use side_number instead, as it's written.
So $second_unit.side_number, I guess
second_unit.side
has been renamed to second_unit.side_number
which seems... odd.Re: error deprecation: unit.side has been deprecated - query
I think what it's trying to say is that, if there are N sides, thenSpannerbag wrote: ↑June 26th, 2022, 9:12 pm Thanks for the reply, but unless I've misunderstood (quite likely!) it just meanssecond_unit.side
has been renamed tosecond_unit.side_number
which seems... odd.
side
is a number between 0 and N-1, while side_number
is a number between 1 and N. (So side_number
will equal side
+ 1.)- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: error deprecation: unit.side has been deprecated - query
Thanks for the reply, not sure my original post was clear enough, so I'll explain a bit further.
Quoting from side turn event
side turn
Triggers when a side is about to start its turn. Before events of this type trigger, the value of the WML variable side_number is set to the number of the side of the player about to take their turn. This is before any healing takes place for that side, before calculating income, and before restoring unit movement and status.
Unless this behaviour changes in 1.17 then yes,
$side_number
will cycle through all sides during a full turn (of all sides).However,
$side_number
is only ever=the side currently in play (be it human or ai), what I need is to know the side of the second_unit
involved in a fight which I don't see how $side_number
can ever provide, with the usual caveat that I've understood everything correctly (dangerous assumption, that!).So, I don't have a problem with
unit.side
being removed in 1.17 and using $side_number
instead.However in combat a
second_unit
is just a defending unit
(i.e. not playing its turn) and is the same data entity.So if
unit.side
is removed then it seems to me that second_unit.side
will also be nuked but without an equivalent of $side_number
for unit.side
.To reiterate the original log message
error deprecation: unit.side has been deprecated and will be removed in version 1.17.0.; This returns 0 for side 1 etc and should not be used. Use side_number instead
Hope this makes sense and thanks for taking the trouble to reply!
Cheers,
-- Spannerbag
Re: error deprecation: unit.side has been deprecated - query
There are several things which have similar names but they aren't really related:
- The
side_number
variable mentioned here - The
unit
andsecond_unit
variables documented here - these have aside
key documented here - The unit object inside a Wesnoth Formula Language formula documented here - this has a
side
key and aside_number
key (actually I don't see theside
key documented at all)
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: error deprecation: unit.side has been deprecated - query
Basically what gnombat said. The error message you're seeing has nothing to do
$second_unit.side
and also has nothing to do with $side_number
. It refers to the side
used in a formula
key, which should be changed to side_number
.- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: error deprecation: unit.side has been deprecated - query
gnombat wrote: ↑June 27th, 2022, 2:08 am There are several things which have similar names but they aren't really related:
The deprecation message is referring to #3 - I believe that is the only thing that needs to be fixed.
- The
side_number
variable mentioned here- The
unit
andsecond_unit
variables documented here - these have aside
key documented here- The unit object inside a Wesnoth Formula Language formula documented here - this has a
side
key and aside_number
key (actually I don't see theside
key documented at all)
Thanks very much for the detailed explanation, your time and patience are appreciated!Celtic_Minstrel wrote: ↑June 27th, 2022, 2:45 am Basically what gnombat said. The error message you're seeing has nothing to do$second_unit.side
and also has nothing to do with$side_number
. It refers to theside
used in aformula
key, which should be changed toside_number
.
My consufion arose because:
- the warning didn't mention it applied specifically to formulas
- none of my formulas reference a unit's side
- several event filters do reference a unit's side
So I presumed the warning was triggered by the presence of
unit.side
clauses in various [event]
statements rather than by the presence of formula
code that did not (I'm assuming the warning is issued whenever a formula is encountered rather than specifically when said formula references a unit's side - if not I'm still not fully understanding what's going on but hey, that's normal in my world ).Again, many thanks for taking the time, much appreciated.
Cheers,
-- Spannerbag
Re: error deprecation: unit.side has been deprecated - query
I'm not sure how it would be possible to get the warning, then - are you sure these warnings are coming from your own add-on, and not from some other add-on?
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: error deprecation: unit.side has been deprecated - query
As sure as I can be; I tried loading my campaign and the warning appears when scenario 3 starts (a rather complicated scenario) and the warning timestamp fits...
Here are all the occurrences of "formula" in that scenario:
Code: Select all
[filter]
x,y=20,1
side=1
formula="alignment = chaotic"
[/filter]
[if]
[have_unit]
id=Magnus
formula="hitpoints < max_hitpoints"
[/have_unit]
[then]
[filter_condition]
[have_unit]
ability=lifesaving
formula="hitpoints = max_hitpoints"
side=1
[/have_unit]
[/filter_condition]
[filter]
ability=lifesaving
formula="hitpoints = max_hitpoints"
side=1
[/filter]
[filter]
side=4
[filter_location]
terrain=*^Efm
[/filter_location]
formula="hitpoints < max_hitpoints"
[/filter]
scenarios\03_Mushgrots.cfg: formula="alignment = chaotic"
scenarios\03_Mushgrots.cfg: formula="hitpoints < max_hitpoints"
scenarios\03_Mushgrots.cfg: formula="hitpoints = max_hitpoints"
scenarios\03_Mushgrots.cfg: formula="hitpoints = max_hitpoints"
scenarios\03_Mushgrots.cfg: formula="hitpoints < max_hitpoints"
scenarios\04a_Lornstead.cfg: [set_variable] # This is the formula used by the game:
utils\dialogue.cfg: formula="alignment = chaotic"
utils\dialogue.cfg: formula="alignment = chaotic"
_main.cfg: formula="hitpoints <= $goldband.et_hp and hitpoints > 0"
_main.cfg: formula="hitpoints <= $goldband.et_hp and hitpoints > 0"
My only idea is that it's maybe the last formula in the scenario block:
Code: Select all
[filter]
side=4
[filter_location]
terrain=*^Efm
[/filter_location]
formula="hitpoints < max_hitpoints"
[/filter]
However I'm just happy to understand what the issue is, finally!
Cheers!
--Spannerbag
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: error deprecation: unit.side has been deprecated - query
Nope, it only triggers if a formula actually references a unit's side. The fact that you're seeing it means there's a formula somewhere in use in your campaign that references a unit's side.Spannerbag wrote: ↑June 27th, 2022, 12:02 pm (I'm assuming the warning is issued whenever a formula is encountered rather than specifically when said formula references a unit's side - if not I'm still not fully understanding what's going on but hey, that's normal in my world ).
It's clearly not any of the formulas you've posted, however. It must be in some other code that your scenario is loading. Do you reference other add-ons in that scenario? Or maybe it comes from a macro? There are also places that use formula code where the key is not "formula", for example in unit ability definitions; maybe it's in one of those?
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: error deprecation: unit.side has been deprecated - query
Hi,Celtic_Minstrel wrote: ↑June 28th, 2022, 2:07 amNope, it only triggers if a formula actually references a unit's side. The fact that you're seeing it means there's a formula somewhere in use in your campaign that references a unit's side.Spannerbag wrote: ↑June 27th, 2022, 12:02 pm (I'm assuming the warning is issued whenever a formula is encountered rather than specifically when said formula references a unit's side - if not I'm still not fully understanding what's going on but hey, that's normal in my world ).
It's clearly not any of the formulas you've posted, however. It must be in some other code that your scenario is loading. Do you reference other add-ons in that scenario? Or maybe it comes from a macro? There are also places that use formula code where the key is not "formula", for example in unit ability definitions; maybe it's in one of those?
Losing the will to live... removed most of the add-ons on my system and cleared up various other warnings to declutter the log.
My campaign doesn't reference any other add-ons, the custom abilities are either
[dummy]
abilities or derivatives of existing ones (e.g. slow) and none have any side dependencies (that I can see).I've searched the entire campaign directory tree (including the campaign's macros) for "side" and "self" without seeing anything relevant.
I've also scanned various files by eye.
The warning appears after scenario 3's opening dialogue (when objectives are displayed) as far as I can determine by repeatedly viewing the log.
Nothing relevant (that I can see) in
prestart
, start
or side 1 turn 1
- or anywhere else in the .cfg.The only method I have left is to systematically remove chunks of the code until the error vanishes - but after spending several days finally getting the damn thing working as I wanted I really can't face more bug snagging right now (getting it to work after major surgery isn't straightforward, at least for me).
My eyesight needs a break too; I've gone a bit codeblind.
If there was some way of knowing what code snippet or file was the cause I'd have something to go on...
Clearly I'm missing something and it's probably staring me in the face but I can't see it...
Thanks for your help and suggestions but the cause of this warning continues to elude me and just now, I need a break... or I'll throw my PC out the window!
If anyone's interested I'm happy to post something here if/when I fix the issue, but that'll probably not be for a few days at least.
Cheers,
-- Spannerbag
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: error deprecation: unit.side has been deprecated - WTF?
Hi.
Me again. Couldn't let it rest as it was bugging me.
First, I was being too impatient, if I wait a short while the warning appears in the log when the scenario loads (I put a message in prestart and looked at the log and the warning was already there - it isn't there when the previous scenario is active).
Sooo... changed the scenario for a test scenario: warning went away.
Then started deleting code from the scenario and an early delete removed the warning!
It also explains why, under normal circumstances, I'd never have found the source of the warning.
The warning comes from a core macro:
Specifically, if I comment out
So, anyone got any idea what I'm doing wrong?
Cheers,
-- Spannerbag
Me again. Couldn't let it rest as it was bugging me.
First, I was being too impatient, if I wait a short while the warning appears in the log when the scenario loads (I put a message in prestart and looked at the log and the warning was already there - it isn't there when the previous scenario is active).
Sooo... changed the scenario for a test scenario: warning went away.
Then started deleting code from the scenario and an early delete removed the warning!
It also explains why, under normal circumstances, I'd never have found the source of the warning.
The warning comes from a core macro:
Code: Select all
# Giant spiders
[side]
side=7
team_name=Spiders
user_team_name= _ "Spiders"
no_leader=yes
controller=ai
recruit=
color=black
gold=0
{NO_INCOME}
[ai]
aggression=0.7
caution=0
{MODIFY_AI_ADD_CANDIDATE_ACTION 7 main_loop {AI_CA_POISONING}}
[/ai]
hidden=yes
[/side]
{MODIFY_AI_ADD_CANDIDATE_ACTION 7 main_loop {AI_CA_POISONING}}
the warning goes away???So, anyone got any idea what I'm doing wrong?
Cheers,
-- Spannerbag
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: error deprecation: unit.side has been deprecated - query
It looks like {AI_CA_POISONING} eventually leads to here, which is probably what's generating the warning.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: error deprecation: unit.side has been deprecated - query
Many thanks for taking the trouble to enlighten mePentarctagon wrote: ↑June 28th, 2022, 8:58 pm It looks like {AI_CA_POISONING} eventually leads to here, which is probably what's generating the warning.
Re.:
'unit', index_of(unit.side, enemies) != -1 and unit.abilities
Wow, this means - for once - it ain't something stupid I've done?
Cheers,
-- Spannerbag