From c2f7ed7f1c2266b72d35f8ef0684096225f35dbc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Nov 2016 12:45:17 +0100 Subject: [PATCH] - fixed: BuiltinNameToClass should treat NAME_None as 'nothing'. It's names that get here, after all, so the name for 'nothing' should actually mean 'nothing' here. --- src/scripting/codegeneration/codegen.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index b7e20f7fc..a34e12f7d 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -9150,15 +9150,19 @@ int BuiltinNameToClass(VMFrameStack *stack, VMValue *param, TArray &def assert(ret->RegType == REGT_POINTER); FName clsname = ENamedName(param[0].i); - const PClass *cls = PClass::FindClass(clsname); - const PClass *desttype = reinterpret_cast(param[1].a); - - if (!cls->IsDescendantOf(desttype)) + if (clsname != NAME_None) { - Printf("class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); - cls = nullptr; + const PClass *cls = PClass::FindClass(clsname); + const PClass *desttype = reinterpret_cast(param[1].a); + + if (!cls->IsDescendantOf(desttype)) + { + Printf("class '%s' is not compatible with '%s'\n", clsname.GetChars(), desttype->TypeName.GetChars()); + cls = nullptr; + } + ret->SetPointer(const_cast(cls), ATAG_OBJECT); } - ret->SetPointer(const_cast(cls), ATAG_OBJECT); + else ret->SetPointer(nullptr, ATAG_OBJECT); return 1; }