Array bug in 1.3.7?
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:
Array bug in 1.3.7?
If an array has no elements and its length is used in a comparison, then the length changes to 1 making the comparison evaluate to true. For example,
Code: Select all
[event]
name=moveto
first_time_only=no
...
[store_unit]
variable=horse_store
[filter]
type=Horse
side=3
[filter_location]
x=$x1
y=$y1
radius=1
[not]
terrain=Hh
[/not]
[/filter_location]
[/filter]
[/store_unit]
#DEBUG_LENGTH_A = 0
{VARIABLE DEBUG_LENGTH_A $horse_store.length}
[if]
[variable]
name=horse_store.length
greater_than=0 #Evaluates to true
[/variable]
[then]
#DEBUG_LENGTH_B = 1
{VARIABLE DEBUG_LENGTH_B $horse_store.length}
...
[/then]
[/if]
...
[/event]
right, it looks like the retrieval inside the [if] was mistakenly 'forcing' horse_store to exist before checking length. this may have already been fixed in svn, but I'll have to check. thanks
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
looks like the bug was still active. I fixed it in r20193 /trunk/ "fix a bug with array.length side-effects causing empty arrays to increase to size 1"
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."