1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 20:13:07 +01:00

Ensure all paths return a value regardless of duk_error

This commit is contained in:
Ted John
2020-04-21 22:08:19 +01:00
parent ea632a8eed
commit d9cbdf29ad

View File

@@ -132,6 +132,7 @@ namespace OpenRCT2::Scripting
DukValue getAll(const std::string& ns)
{
DukValue result;
auto ctx = GetContext()->GetScriptEngine().GetContext();
if (IsValidNamespace(ns))
{
@@ -142,18 +143,19 @@ namespace OpenRCT2::Scripting
{
obj.Set("general.showFps", gConfigGeneral.show_fps);
}
return obj.Take();
result = obj.Take();
}
else
{
auto obj = GetNamespaceObject(ns);
return obj ? *obj : DukObject(ctx).Take();
result = obj ? *obj : DukObject(ctx).Take();
}
}
else
{
duk_error(ctx, DUK_ERR_ERROR, "Namespace was invalid.");
}
return result;
}
DukValue get(const std::string& key, const DukValue& defaultValue)