- fixed damage handling in A_BetaSkullAttack. For unknown reasons this completely bypassed the normal damage function semantics and even multiplied that with a random value.

- made some tests about calling script code from native functions.

 * scriptified A_SkullAttack to have something to test
 * changed the A_SkullAttack call in A_PainShootSkull.
 * use a macro to declare the function pointer. Using local static variable init directly results in hideous code for the need of being thread-safe (which, even if the engine was made multithreaded is not needed here.)
 * Importsnt node here: Apparently passing an actor pointer to the VMValue constructor results in the void * version being called, not the DObject * version.
This commit is contained in:
Christoph Oelckers 2016-11-06 11:36:12 +01:00
parent dbde0971ef
commit 062574b726
12 changed files with 97 additions and 98 deletions

View file

@ -99,7 +99,9 @@ FxVMFunctionCall *DoActionSpecials(FScanner &sc, FState & state, Baggage &bag)
{
sc.ScriptError ("Too many arguments to %s", specname.GetChars());
}
return new FxVMFunctionCall(new FxSelf(sc), FindGlobalActionFunction("A_CallSpecial"), args, sc, false);
auto f = dyn_cast<PFunction>(RUNTIME_CLASS(AActor)->Symbols.FindSymbol("A_CallSpecial", false));
assert(f != nullptr);
return new FxVMFunctionCall(new FxSelf(sc), f, args, sc, false);
}
return NULL;
}

View file

@ -602,9 +602,10 @@ AFuncDesc *FindFunction(const char * string)
//
//==========================================================================
PFunction *FindGlobalActionFunction(const char *name)
VMFunction *FindVMFunction(PClass *cls, const char *name)
{
return dyn_cast<PFunction>(RUNTIME_CLASS(AActor)->Symbols.FindSymbol(name, false));
auto f = dyn_cast<PFunction>(cls->Symbols.FindSymbol(name, true));
return f == nullptr ? nullptr : f->Variants[0].Implementation;
}

View file

@ -1071,7 +1071,8 @@ void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self);
class PFunction;
PFunction *FindGlobalActionFunction(const char *name);
VMFunction *FindVMFunction(PClass *cls, const char *name);
#define DECLARE_VMFUNC(cls, name) static VMFunction *name; if (name == nullptr) name = FindVMFunction(RUNTIME_CLASS(cls), #name);

View file

@ -495,6 +495,7 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur
class AActor;
void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self)
{
VMValue params[3] = { self, self, VMValue(nullptr, ATAG_GENERIC) };
// Without the type cast this picks the 'void *' assignment...
VMValue params[3] = { (DObject*)self, (DObject*)self, VMValue(nullptr, ATAG_GENERIC) };
stack->Call(vmfunc, params, vmfunc->ImplicitArgs, nullptr, 0, nullptr);
}