From c5f100a61d44631950054b06b9802caba9924262 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 16 Jan 2017 20:44:52 +0100 Subject: [PATCH] - fixed class name checks for custom properties. --- src/scripting/decorate/thingdef_parse.cpp | 9 +++++++-- src/scripting/zscript/zcc_compile.cpp | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index 2eee0f01d3..c839a2dc04 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -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(f->Type)->ClassRestriction)) + if (cls == nullptr) { - sc.ScriptMessage("class %s is not compatible with property type %s", cls->TypeName.GetChars(), static_cast(f->Type)->ClassRestriction->TypeName.GetChars()); + cls = static_cast(f->Type)->ClassRestriction->FindClassTentative(sc.String); + } + else if (!cls->IsDescendantOf(static_cast(f->Type)->ClassRestriction)) + { + sc.ScriptMessage("class %s is not compatible with property type %s", sc.String, static_cast(f->Type)->ClassRestriction->TypeName.GetChars()); FScriptPosition::ErrorCounter++; } + *(PClass**)addr = cls; } else { diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 281f707d29..1687983f23 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -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(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(f->Type)->ClassRestriction->TypeName.GetChars()); + cls = static_cast(f->Type)->ClassRestriction->FindClassTentative(clsname); } + else if (!cls->IsDescendantOf(static_cast(f->Type)->ClassRestriction)) + { + Error(property, "class %s is not compatible with property type %s", clsname, static_cast(f->Type)->ClassRestriction->TypeName.GetChars()); + } + *(PClass**)addr = cls; } else {