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.
This commit is contained in:
Boondorl 2024-03-08 13:54:02 -05:00 committed by Rachael Alexanderson
parent 5ed4f477ed
commit 06eee55671
No known key found for this signature in database
GPG key ID: 26A8ACCE97115EE0
3 changed files with 17 additions and 1 deletions

View file

@ -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;

View file

@ -462,6 +462,7 @@ xx(WBobSpeed)
xx(WBobFire)
xx(PlayerClass)
xx(MonsterClass)
xx(Morph)
xx(MorphedMonster)
xx(Wi_NoAutostartMap)

View file

@ -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);