diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 0b827cb0b..b5e8cd29d 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -56,6 +56,7 @@ #include "g_levellocals.h" #include "vm.h" #include "actor.h" +#include "types.h" // MACROS ------------------------------------------------------------------ @@ -356,11 +357,21 @@ void SetCompatibilityParams(FName checksum) if (cls->IsDescendantOf(RUNTIME_CLASS(DLevelCompatibility))) { PFunction *const func = dyn_cast(cls->FindSymbol("Apply", false)); - if (func != nullptr) + if (func == nullptr) { - VMValue param[] = { lc, checksum.GetIndex(), &level.MapName }; - VMCall(func->Variants[0].Implementation, param, 3, nullptr, 0); + Printf("Missing 'Apply' method in class '%s', level compatibility object ignored\n", cls->TypeName.GetChars()); + continue; } + + auto argTypes = func->Variants[0].Proto->ArgumentTypes; + if (argTypes.Size() != 3 || argTypes[1] != TypeName || argTypes[2] != TypeString) + { + Printf("Wrong signature of 'Apply' method in class '%s', level compatibility object ignored\n", cls->TypeName.GetChars()); + continue; + } + + VMValue param[] = { lc, checksum.GetIndex(), &level.MapName }; + VMCall(func->Variants[0].Implementation, param, 3, nullptr, 0); } } }