- fixed crash in DECORATE parsing

The case with forward declared class used as a parent must be handled explicitly

actor MyWeapon : Weapon { Weapon.AmmoType "MyBaseAmmo" }
actor MyAmmo : MyBaseAmmo { }
actor MyBaseAmmo : Ammo { }
This commit is contained in:
alexey.lysiuk 2018-05-10 11:47:16 +03:00
parent 821cc2a140
commit ef536e7b00

View file

@ -62,7 +62,14 @@ EXTERN_CVAR(Bool, strictdecorate);
PClassActor *DecoDerivedClass(const FScriptPosition &sc, PClassActor *parent, FName typeName) PClassActor *DecoDerivedClass(const FScriptPosition &sc, PClassActor *parent, FName typeName)
{ {
if (parent->VMType->mVersion > MakeVersion(2, 0)) const PClassType *const parentVMType = parent->VMType;
if (parentVMType == nullptr)
{
// Abort when forward declared class is used as a parent. This edge case cannot be handled gracefully.
sc.Message(MSG_FATAL, "Tried to define class '%s' without definition of parent class '%s'.", typeName.GetChars(), parent->TypeName.GetChars());
}
else if (parentVMType->mVersion > MakeVersion(2, 0))
{ {
sc.Message(MSG_ERROR, "Parent class %s of %s not accessible to DECORATE", parent->TypeName.GetChars(), typeName.GetChars()); sc.Message(MSG_ERROR, "Parent class %s of %s not accessible to DECORATE", parent->TypeName.GetChars(), typeName.GetChars());
} }