From c9a96ed0aef5eeb2c3d851483c585c766699727e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 6 Nov 2016 01:34:54 +0100 Subject: [PATCH] - fixed: CALL_ACTION always set 3 args, even for normal methods. Also moved this to a sunfunction because the macro created a lot of code. --- src/scripting/vm/vm.h | 7 +++---- src/scripting/vm/vmframe.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 811fb82e0..3120bbd61 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -1034,10 +1034,9 @@ struct AFuncDesc //#define DECLARE_PARAMINFO AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall //#define PUSH_PARAMINFO self, stateowner, CallingState, ParameterIndex, statecall -#define CALL_ACTION(name,self) { /*AF_##name(self, self, NULL, 0, NULL)*/ \ - VMValue params[3] = { self, self, VMValue(NULL, ATAG_GENERIC) }; \ - stack->Call(name##_VMPtr, params, countof(params), NULL, 0, NULL); \ - } +class AActor; +void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self); +#define CALL_ACTION(name, self) CallAction(stack, name##_VMPtr, self); #define ACTION_RETURN_STATE(v) do { FState *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state, ATAG_STATE); return 1; } return 0; } while(0) diff --git a/src/scripting/vm/vmframe.cpp b/src/scripting/vm/vmframe.cpp index c54b585e9..1ccf3321e 100644 --- a/src/scripting/vm/vmframe.cpp +++ b/src/scripting/vm/vmframe.cpp @@ -491,3 +491,10 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur throw; } } + +class AActor; +void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self) +{ + VMValue params[3] = { self, self, VMValue(nullptr, ATAG_GENERIC) }; + stack->Call(vmfunc, params, vmfunc->ImplicitArgs, nullptr, 0, nullptr); +}