From 79aa56c704ff4117511cd33be3efd0321683d89a Mon Sep 17 00:00:00 2001 From: Kpy! Date: Tue, 21 Apr 2015 13:48:25 +0200 Subject: Fix script function return always removing references from NPC variables. Bugreport:8642 http://hercules.ws/board/tracker/issue-8642-script-engine-issue-quo/ --- npc/dev/test.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'npc') diff --git a/npc/dev/test.txt b/npc/dev/test.txt index 7b498e922..8e94d6ee7 100644 --- a/npc/dev/test.txt +++ b/npc/dev/test.txt @@ -86,6 +86,15 @@ function script F_TestNPCArrays { return getarraysize(.y); } +function script F_TestVarOfAnotherNPC { + return getvariableofnpc(.x, getarg(0)); +} + +- script TestVarOfAnotherNPC -1,{ + // Used to test getvariableofnpc() + end; +} + function script HerculesSelfTestHelper { if (.once > 0) return .errors; @@ -618,6 +627,9 @@ function script HerculesSelfTestHelper { callsub(OnCheck, "Callsub (parent array vars isolation)", getarraysize(.@x), .@z); deletearray .@x; deletearray .@y; + .x = 2; + set getvariableofnpc(.x, "TestVarOfAnotherNPC"), 1; + callsub(OnCheck, "Callsub (return NPC variables from another NPC)", callsub(OnTestVarOfAnotherNPC, "TestVarOfAnotherNPC"), 1); // Callfunc callsub(OnCheck, "Callfunc return value", callfunc("F_TestReturnValue", 1)); @@ -663,6 +675,9 @@ function script HerculesSelfTestHelper { callsub(OnCheck, "Callfunc (parent array NPC vars isolation)", getarraysize(.@x), .@z); deletearray .x; deletearray .y; + .x = 2; + set getvariableofnpc(.x, "TestVarOfAnotherNPC"), 1; + callsub(OnCheck, "Callfunc (return NPC variables from another NPC)", callfunc("F_TestVarOfAnotherNPC", "TestVarOfAnotherNPC"), 1); if (.errors) { debugmes "Script engine self-test [ \033[0;31mFAILED\033[0m ]"; @@ -704,6 +719,9 @@ OnTestScopeArrays: setarray .@x, 1, 2, 3, 4; copyarray .@y, getarg(0), getarraysize(getarg(0)); return getarraysize(.@y); + +OnTestVarOfAnotherNPC: + return getvariableofnpc(.x, getarg(0)); OnReportError: .@msg$ = getarg(0,"Unknown Error"); -- cgit v1.2.3-70-g09d2