Skip to content

Commit

Permalink
Fix for Morph virtual
Browse files Browse the repository at this point in the history
Allows class<MorphedMonster> to be used as an argument type in place of class<Actor> within the third argument for backwards compatibility.
  • Loading branch information
Boondorl authored and madame-rachelle committed Apr 20, 2024
1 parent 5ed4f47 commit 06eee55
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/common/objects/dobjtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/namedef_custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ xx(WBobSpeed)
xx(WBobFire)
xx(PlayerClass)
xx(MonsterClass)
xx(Morph)
xx(MorphedMonster)
xx(Wi_NoAutostartMap)

Expand Down
13 changes: 13 additions & 0 deletions src/scripting/backend/codegen_doom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 06eee55

Please sign in to comment.