Skip to content

Commit 1bcedb9

Browse files
Boondorlmadame-rachelle
authored andcommitted
Fix for Morph virtual
Allows class<MorphedMonster> to be used as an argument type in place of class<Actor> within the third argument for backwards compatibility.
1 parent 7720365 commit 1bcedb9

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/common/objects/dobjtype.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ PClass *PClass::FindClassTentative(FName name)
667667
//
668668
//==========================================================================
669669

670+
bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PType* varg);
671+
670672
int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction *parentfunc, bool exactReturnType, bool ignorePointerReadOnly)
671673
{
672674
auto proto = variant->Proto;
@@ -698,7 +700,7 @@ int PClass::FindVirtualIndex(FName name, PFunction::Variant *variant, PFunction
698700
break;
699701
}
700702
}
701-
else
703+
else if(!ShouldAllowGameSpecificVirtual(name, a, proto->ArgumentTypes[a], vproto->ArgumentTypes[a]))
702704
{
703705
fail = true;
704706
break;

src/namedef_custom.h

+1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ xx(WBobSpeed)
462462
xx(WBobFire)
463463
xx(PlayerClass)
464464
xx(MonsterClass)
465+
xx(Morph)
465466
xx(MorphedMonster)
466467
xx(Wi_NoAutostartMap)
467468

src/scripting/backend/codegen_doom.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ PFunction* FindBuiltinFunction(FName funcname);
5757
//
5858
//==========================================================================
5959

60+
bool ShouldAllowGameSpecificVirtual(FName name, unsigned index, PType* arg, PType* varg)
61+
{
62+
return (name == NAME_Morph && index == 3u && arg->isClassPointer() && varg->isClassPointer()
63+
&& PType::toClassPointer(varg)->ClassRestriction->TypeName == NAME_Actor
64+
&& PType::toClassPointer(arg)->ClassRestriction->TypeName == NAME_MorphedMonster);
65+
}
66+
67+
//==========================================================================
68+
//
69+
//
70+
//
71+
//==========================================================================
72+
6073
bool isActor(PContainerType *type)
6174
{
6275
auto cls = PType::toClass(type);

0 commit comments

Comments
 (0)