From 1b07bded471fd4cb4608db9df3c9ad3774f8f0f5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Dec 2018 17:35:53 +0100 Subject: [PATCH] - fixed: The static variant of PClass::FindFunction may only be used for actual static variables. --- src/dobjtype.cpp | 2 ++ src/g_statusbar/shared_sbar.cpp | 3 +-- src/scriptutil.cpp | 7 ++++++- src/scriptutil.h | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index d96695cee..b2e4c16ed 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -48,6 +48,7 @@ #include "a_keys.h" #include "vm.h" #include "types.h" +#include "scriptutil.h" // MACROS ------------------------------------------------------------------ @@ -255,6 +256,7 @@ void PClass::StaticShutdown () { *p = nullptr; } + ScriptUtil::Clear(); FunctionPtrList.Clear(); VMFunction::DeleteAll(); diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index c24f1b2f7..bb1709594 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -367,8 +367,7 @@ DBaseStatusBar::DBaseStatusBar () { AltHud = cls->CreateNew(); - VMFunction * func = nullptr; - PClass::FindFunction(&func, classname, "Init"); + VMFunction * func = PClass::FindFunction(classname, "Init"); if (func != nullptr) { VMValue params[] = { AltHud }; diff --git a/src/scriptutil.cpp b/src/scriptutil.cpp index 6a9d5ab26..d233d80fd 100644 --- a/src/scriptutil.cpp +++ b/src/scriptutil.cpp @@ -35,6 +35,11 @@ static TArray parameters; static TMap functions; +void ScriptUtil::Clear() +{ + parameters.Clear(); + functions.Clear(); +} void ScriptUtil::BuildParameters(va_list ap) { @@ -69,7 +74,7 @@ void ScriptUtil::RunFunction(FName functionname, unsigned paramstart, VMReturn & auto check = functions.CheckKey(functionname); if (!check) { - PClass::FindFunction(&func, NAME_ScriptUtil, functionname); + func = PClass::FindFunction(NAME_ScriptUtil, functionname); if (func == nullptr) { I_Error("Call to undefined function ScriptUtil.%s", functionname.GetChars()); diff --git a/src/scriptutil.h b/src/scriptutil.h index 6d8f83cc8..12f137764 100644 --- a/src/scriptutil.h +++ b/src/scriptutil.h @@ -24,4 +24,5 @@ public: }; static int Exec(FName functionname, ...); + static void Clear(); };