- fixed: The static variant of PClass::FindFunction may only be used for actual static variables.

This commit is contained in:
Christoph Oelckers 2018-12-03 17:35:53 +01:00
parent 0e095b0c05
commit 1b07bded47
4 changed files with 10 additions and 3 deletions

View file

@ -48,6 +48,7 @@
#include "a_keys.h" #include "a_keys.h"
#include "vm.h" #include "vm.h"
#include "types.h" #include "types.h"
#include "scriptutil.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -255,6 +256,7 @@ void PClass::StaticShutdown ()
{ {
*p = nullptr; *p = nullptr;
} }
ScriptUtil::Clear();
FunctionPtrList.Clear(); FunctionPtrList.Clear();
VMFunction::DeleteAll(); VMFunction::DeleteAll();

View file

@ -367,8 +367,7 @@ DBaseStatusBar::DBaseStatusBar ()
{ {
AltHud = cls->CreateNew(); AltHud = cls->CreateNew();
VMFunction * func = nullptr; VMFunction * func = PClass::FindFunction(classname, "Init");
PClass::FindFunction(&func, classname, "Init");
if (func != nullptr) if (func != nullptr)
{ {
VMValue params[] = { AltHud }; VMValue params[] = { AltHud };

View file

@ -35,6 +35,11 @@
static TArray<VMValue> parameters; static TArray<VMValue> parameters;
static TMap<FName, VMFunction*> functions; static TMap<FName, VMFunction*> functions;
void ScriptUtil::Clear()
{
parameters.Clear();
functions.Clear();
}
void ScriptUtil::BuildParameters(va_list ap) void ScriptUtil::BuildParameters(va_list ap)
{ {
@ -69,7 +74,7 @@ void ScriptUtil::RunFunction(FName functionname, unsigned paramstart, VMReturn &
auto check = functions.CheckKey(functionname); auto check = functions.CheckKey(functionname);
if (!check) if (!check)
{ {
PClass::FindFunction(&func, NAME_ScriptUtil, functionname); func = PClass::FindFunction(NAME_ScriptUtil, functionname);
if (func == nullptr) if (func == nullptr)
{ {
I_Error("Call to undefined function ScriptUtil.%s", functionname.GetChars()); I_Error("Call to undefined function ScriptUtil.%s", functionname.GetChars());

View file

@ -24,4 +24,5 @@ public:
}; };
static int Exec(FName functionname, ...); static int Exec(FName functionname, ...);
static void Clear();
}; };