Jump to content

  •  

Bug Tracker Migration

June 3rd
Good news everyone! The staff has decided that it is time to slowly kill off this Bug Tracker. We will begin the process of slowly migrating from this Bug Tracker over to our Github Issues which can be found here: https://github.com/HerculesWS/Hercules/issues

Over the next couple of days, I will be closing off any opportunity to create new reports. However, I still will keep the opportunity to reply to existing Bug Reports. Doing this will allow us to slowly fix any bug reports we have listed here so that we can easily migrate over to our Issue Tracker.

Update - June 7th 2015: Creating new bug posts has been disabled. Please use our https://github.com/HerculesWS/Hercules/issues tracker to post bugs. Users are still able to reply to existing bug posts.

- Administration

Issue Information

  • #008642

  • 0 - None Assigned

  • New

Issue Confirmations

  • Yes (0)No (0)
Photo

Script engine issue: "return getvariableofnpc()" returning wrong values

Posted by Kpy! on 20 April 2015 - 09:23 PM

See the following test case:
prontera,157,180,5    script    test    81,{
    donpcevent "test2::OnSetMyVar";
    mes ".myvar: " + callsub(OnGetMyVar); //OK: displays ".myvar: 1"
    mes ".myvar: " + callsub(OnGetMyVar2); //ERROR: displays ".myvar: 0"    
    .myvar = 2;
    mes ".myvar: " + callsub(OnGetMyVar2); //ERROR: displays ".myvar: 2"
    close;

OnGetMyVar:
    .@myvar = getvariableofnpc(.myvar, "test2");
    return .@myvar;

OnGetMyVar2:
    return getvariableofnpc(.myvar, "test2");
}

-    script    test2    -1,{
OnSetMyVar:
    .myvar = 1;
    end;
}
The variable's (.myvar) ref is being removed by this code in the return function (script.c):
} else if ( name[0] == '.' /* && data->ref != NULL */ ) {
	data->ref = NULL; // Reference to the parent scope's script, remove reference pointer.
}

EDIT:
Pull request: https://github.com/H...rcules/pull/502