From 0ed4bfbc4a27d7fa0950a22219efb224e81f749b Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 30 Apr 2023 17:18:09 +0100 Subject: [PATCH] Return null for legacyIdentifier --- distribution/openrct2.d.ts | 2 +- .../scripting/bindings/object/ScInstalledObject.hpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 05447e94b7..bd1f2caf39 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -1658,7 +1658,7 @@ declare global { * This may have trailing spaces if the name is shorter than 8 characters. * Only .DAT objects or JSON objects based on .DAT objects will have legacy identifiers. */ - readonly legacyIdentifier: string; + readonly legacyIdentifier: string | null; /** * The object version, e.g. "1.5.2-pre". diff --git a/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp b/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp index f722280a38..39b652fade 100644 --- a/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp +++ b/src/openrct2/scripting/bindings/object/ScInstalledObject.hpp @@ -145,17 +145,18 @@ namespace OpenRCT2::Scripting return {}; } - std::string legacyIdentifier_get() const + DukValue legacyIdentifier_get() const { + auto ctx = GetContext()->GetScriptEngine().GetContext(); auto installedObject = GetInstalledObject(); if (installedObject != nullptr) { if (!installedObject->ObjectEntry.IsEmpty()) { - return std::string(installedObject->ObjectEntry.GetName()); + return ToDuk(ctx, installedObject->ObjectEntry.GetName()); } } - return {}; + return ToDuk(ctx, nullptr); } std::vector authors_get() const