Issue information

Issue ID
#5673
Status
Fixed
Severity
Fair
Started
Hercules Elf Bot
Apr 30, 2012 0:28
Last Post
Hercules Elf Bot
May 9, 2012 7:38
Confirmation
N/A

Hercules Elf Bot - Apr 30, 2012 0:28

Originally posted by [b]Toshiro[/b]
The callfunc function does not parse scope (.@) variables as arguments anymore. Passing those variables is recognized by callfunc, but when accessing the arguments with getarg it just return their default values (0 or empty string). It's working file with all other kinds of variable types (not tested with instance variables).

Probably related with change [rev='15997'].

The following test script and it's output shows that the variables' content are only ignored/lost when using as arguments for [i]callfunc[/i], not for other functions like [i]monster[/i].

Test script:
[code]
prontera,160,180,0 script test 50,{
OnInit:
set .@v1, 42;
set .@v2, 5;
set .@v3$, "blub";
callfunc "myfunc", .@v1, .@v2, .@v3$;
debugmes ".@v1: "+.@v1+" .@v2: "+.@v2+" .@v3$: "+.@v3$;
monster "prontera", 0, 0, "test", .@v1, 1;
}

function script myfunc {
debugmes "getargcount: "+getargcount()+" arg[0]: "+getarg(0)+" arg[1]: "+getarg(1)+" arg[2]: "+getarg(2);
return;
}[/code]
Output:
[quote][Debug]: script debug : 0 110013191 : getargcount: [color=#008000]3[/color] arg[0]: [color=#ff0000]0[/color] arg[1]: [color=#ff0000]0[/color] arg[2]:
[Debug]: script debug : 0 110013191 : .@v1: [color=#008000]42[/color] .@v2: [color=#008000]5[/color] .@v3$: [color=#008000]blub[/color]
[Warning]: buildin_monster: Attempted to spawn non-existing monster class [color=#008000]42[/color][/quote]

Hercules Elf Bot - Apr 30, 2012 6:27

Originally posted by [b]v00m3r[/b]
do you think toasty warper i not working becasue of this also?

Hercules Elf Bot - Apr 30, 2012 6:27

Originally posted by [b]v00m3r[/b]
sorry for the double post.. my net is a slow today

This post has been edited by v00m3r on Apr 30, 2012 6:32

Hercules Elf Bot - Apr 30, 2012 7:17

Originally posted by [b]Toshiro[/b]
[quote name='v00m3r' timestamp='1335767271' post='8763']
do you think toasty warper i not working becasue of this also?
[/quote]
I don't know if there are other problems with the warper as well, but since there are two [i]callfunc[/i] calls that have scope variables passed as arguments, it's most likely the same cause.

Hercules Elf Bot - Apr 30, 2012 12:35

Originally posted by [b]Epoque[/b]
Indeed, I can confirm this.

[b]callfunc:4469:[/b]
[code]const char* name = reference_getname(data);
if( name[0] == '.' && name[1] == '@' )
data->ref = &st->stack->var_function;
else if( name[0] == '.' )
data->ref = &st->script->script_vars;[/code]

[b]callfunc:4489:[/b]
[code]st->stack->var_function = idb_alloc(DB_OPT_RELEASE_DATA);[/code]

With the var_function parameter being re-allocated upon the end of the callfunc method, it appears the variables are wiped clean. Not sure how this behaviour properly worked before, will have to do some research.

[b]Edit[/b] Fixed in [rev='16018'].

This post has been edited by Epoque on Apr 30, 2012 12:51