Infinity loop during lvluping.

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
ChaosRider
Posts: 1170
Joined: April 15th, 2012, 1:15 pm

Infinity loop during lvluping.

Post by ChaosRider »

Anyone know why game is doing infinity loop during lvluping unit with advance unit macro (for example advancing inferno drake to armageddon drake, same with lvluping lich to ancient lich)? Below code from my addon called "More units forms" (which was working fine on Wesnoth v1.10):
Spoiler:
Spoiler:
Screenshot_1.png
Creator of WOTG (+5500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
User avatar
Ravana
Forum Moderator
Posts: 3313
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Infinity loop during lvluping.

Post by Ravana »

Code: Select all

    # Example to advance your leader normally:
    #! {ADVANCE_UNIT canrecruit,side=yes,1 ""}
That does not look correct. There is no reason why [modify_unit] should treat empty type as advancement.
User avatar
ChaosRider
Posts: 1170
Joined: April 15th, 2012, 1:15 pm

Re: Infinity loop during lvluping.

Post by ChaosRider »

Ravana wrote: January 13th, 2025, 5:12 pm

Code: Select all

    # Example to advance your leader normally:
    #! {ADVANCE_UNIT canrecruit,side=yes,1 ""}
That does not look correct. There is no reason why [modify_unit] should treat empty type as advancement.
Where in code Ive empty type :P?
Creator of WOTG (+5500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
User avatar
Atreides
Posts: 1243
Joined: March 30th, 2019, 10:38 pm
Location: On the 2nd story of the centre village in Merwuerdigliebe turning the lights on and off

Re: Infinity loop during lvluping.

Post by Atreides »

ChaosRider wrote: January 13th, 2025, 5:21 pm
Ravana wrote: January 13th, 2025, 5:12 pm

Code: Select all

    # Example to advance your leader normally:
    #! {ADVANCE_UNIT canrecruit,side=yes,1 ""}
That does not look correct. There is no reason why [modify_unit] should treat empty type as advancement.
Where in code Ive empty type :P?
Not familiar with that macro but it's very likely the "" at the end is supposed to take a unit type as a parameter.
User avatar
ChaosRider
Posts: 1170
Joined: April 15th, 2012, 1:15 pm

Re: Infinity loop during lvluping.

Post by ChaosRider »

This code was taken from core macros in Wesnoth v1.18.3.

Code: Select all

Example to advance your leader normally:
    #! {ADVANCE_UNIT canrecruit,side=yes,1 ""}
It looks wrong to me but its not why infinity loop happens after unit advance.
Creator of WOTG (+5500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
User avatar
Ravana
Forum Moderator
Posts: 3313
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Infinity loop during lvluping.

Post by Ravana »

I found that it is custom logic in modify_unit.lua, added to wiki.
User avatar
lhybrideur
Posts: 454
Joined: July 9th, 2019, 1:46 pm

Re: Infinity loop during lvluping.

Post by lhybrideur »

On thing that happened in my add-on was that I was using a [modify_unit] in a pre_advance event. However, [modify_unit] is refreshing the unit, so was triggering a new pre_advance event thus looping.
You might have a similar problem.
Now I use [store_unit], manually modify, then [unstore_unit] to prevent that.
User avatar
ChaosRider
Posts: 1170
Joined: April 15th, 2012, 1:15 pm

Re: Infinity loop during lvluping.

Post by ChaosRider »

lhybrideur wrote: January 14th, 2025, 12:47 pm On thing that happened in my add-on was that I was using a [modify_unit] in a pre_advance event. However, [modify_unit] is refreshing the unit, so was triggering a new pre_advance event thus looping.
You might have a similar problem.
Now I use [store_unit], manually modify, then [unstore_unit] to prevent that.
Once I reach 5000 different units in WOTG I will try rewrite code to use store unit and transform code.
Creator of WOTG (+5500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
Post Reply