From 3662b2d5e2162c4fc430399cac75c3566fbfc952 Mon Sep 17 00:00:00 2001 From: wraitii Date: Thu, 3 Jun 2021 10:16:59 +0000 Subject: [PATCH] Fix error in HasSameMods with old matchsettings. Add some retro-compatibility to avoid issues. First reported by: gameboy Differential Revision: https://code.wildfiregames.com/D4066 This was SVN commit r25651. --- source/ps/scripting/JSInterface_Mod.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/ps/scripting/JSInterface_Mod.cpp b/source/ps/scripting/JSInterface_Mod.cpp index e7c6199af6..ab2aec4819 100644 --- a/source/ps/scripting/JSInterface_Mod.cpp +++ b/source/ps/scripting/JSInterface_Mod.cpp @@ -64,6 +64,21 @@ void Script::ToJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret, const template<> bool Script::FromJSVal(const ScriptRequest& rq, const JS::HandleValue val, Mod::ModData& data) { + // To avoid errors & for convenience, some retro-compatibility when reading + // TODO: remove this once we hit A26. + JS::RootedObject obj(rq.cx, val.toObjectOrNull()); + bool isArray = false; + if (JS::IsArray(rq.cx, obj, &isArray) && isArray) + { + if (!Script::GetPropertyInt(rq, val, 0, data.m_Pathname)) + return false; + if (!Script::GetPropertyInt(rq, val, 1, data.m_Version)) + return false; + // Set a sane default for this. + data.m_Name = data.m_Pathname; + return true; + } + // This property is not set in mod.json files, so don't fail if it's not there. if (Script::HasProperty(rq, val, "mod") && !Script::GetProperty(rq, val, "mod", data.m_Pathname)) return false;