- fixed class name checks for custom properties.

This commit is contained in:
Christoph Oelckers 2017-01-16 20:44:52 +01:00
parent d3ab691afb
commit c5f100a61d
2 changed files with 16 additions and 6 deletions

View file

@ -862,11 +862,16 @@ static void DispatchScriptProperty(FScanner &sc, PProperty *prop, AActor *defaul
sc.MustGetString();
auto cls = PClass::FindClass(sc.String);
*(PClass**)addr = cls;
if (!cls->IsDescendantOf(static_cast<PClassPointer*>(f->Type)->ClassRestriction))
if (cls == nullptr)
{
sc.ScriptMessage("class %s is not compatible with property type %s", cls->TypeName.GetChars(), static_cast<PClassPointer*>(f->Type)->ClassRestriction->TypeName.GetChars());
cls = static_cast<PClassPointer*>(f->Type)->ClassRestriction->FindClassTentative(sc.String);
}
else if (!cls->IsDescendantOf(static_cast<PClassPointer*>(f->Type)->ClassRestriction))
{
sc.ScriptMessage("class %s is not compatible with property type %s", sc.String, static_cast<PClassPointer*>(f->Type)->ClassRestriction->TypeName.GetChars());
FScriptPosition::ErrorCounter++;
}
*(PClass**)addr = cls;
}
else
{

View file

@ -1960,12 +1960,17 @@ void ZCCCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *prop
}
else if (f->Type->IsKindOf(RUNTIME_CLASS(PClassPointer)))
{
auto cls = PClass::FindClass(GetString(exp));
*(PClass**)addr = cls;
if (!cls->IsDescendantOf(static_cast<PClassPointer*>(f->Type)->ClassRestriction))
auto clsname = GetString(exp);
auto cls = PClass::FindClass(clsname);
if (cls == nullptr)
{
Error(property, "class %s is not compatible with property type %s", cls->TypeName.GetChars(), static_cast<PClassPointer*>(f->Type)->ClassRestriction->TypeName.GetChars());
cls = static_cast<PClassPointer*>(f->Type)->ClassRestriction->FindClassTentative(clsname);
}
else if (!cls->IsDescendantOf(static_cast<PClassPointer*>(f->Type)->ClassRestriction))
{
Error(property, "class %s is not compatible with property type %s", clsname, static_cast<PClassPointer*>(f->Type)->ClassRestriction->TypeName.GetChars());
}
*(PClass**)addr = cls;
}
else
{