From 06eee55671e86c67fcf52e22d93f50ea135e2fca Mon Sep 17 00:00:00 2001 From: Boondorl Date: Fri, 8 Mar 2024 13:54:02 -0500 Subject: [PATCH] Fix for Morph virtual Allows class to be used as an argument type in place of class within the third argument for backwards compatibility. --- src/common/objects/dobjtype.cpp | 4 +++- src/namedef_custom.h | 1 + src/scripting/backend/codegen_doom.cpp | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/common/objects/dobjtype.cpp b/src/common/objects/dobjtype.cpp index 4c2a1bd4d0..0d1bfdf9a8 100644 --- a/src/common/objects/dobjtype.cpp +++ b/src/common/objects/dobjtype.cpp @@ -667,6 +667,8 @@ PClass *PClass::FindClassTentative(FName name) // //========================================================================== +bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PType* varg); + int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType, bool ignorePointerReadOnly) { auto proto = variant->Proto; @@ -698,7 +700,7 @@ int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction break; } } - else + else if(!ShouldAllowGameSpecificVirtual(name, a, proto->ArgumentTypes[a], vproto->ArgumentTypes[a])) { fail = true; break; diff --git a/src/namedef_custom.h b/src/namedef_custom.h index 1beb0d2357..7d6d095f2c 100644 --- a/src/namedef_custom.h +++ b/src/namedef_custom.h @@ -462,6 +462,7 @@ xx(WBobSpeed) xx(WBobFire) xx(PlayerClass) xx(MonsterClass) +xx(Morph) xx(MorphedMonster) xx(Wi_NoAutostartMap) diff --git a/src/scripting/backend/codegen_doom.cpp b/src/scripting/backend/codegen_doom.cpp index 60e0cc6141..0e52790d72 100644 --- a/src/scripting/backend/codegen_doom.cpp +++ b/src/scripting/backend/codegen_doom.cpp @@ -57,6 +57,19 @@ PFunction* FindBuiltinFunction(FName funcname); // //========================================================================== +bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PType* varg) +{ + return (name == NAME_Morph && index == 3u && arg->isClassPointer() && varg->isClassPointer() + && PType::toClassPointer(varg)->ClassRestriction->TypeName == NAME_Actor + && PType::toClassPointer(arg)->ClassRestriction->TypeName == NAME_MorphedMonster); +} + +//========================================================================== +// +// +// +//========================================================================== + bool isActor(PContainerType *type) { auto cls = PType::toClass(type);