1
0
forked from 0ad/0ad

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.
This commit is contained in:
wraitii 2021-06-03 10:16:59 +00:00
parent dd0d4dc57a
commit 3662b2d5e2

View File

@ -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;