Fix atlas crash with RM capture the relic.

As no default values got set, some game settings became NaN, which
triggered exceptions.
This sets sane default.

This also includes better debugging logic in case of exception, so it's
easier to know what happens.

Fixes #6200

Reported by: langbart
Differential Revision: https://code.wildfiregames.com/D4113
This was SVN commit r25736.
This commit is contained in:
wraitii
2021-06-07 18:48:16 +00:00
parent 67539a8837
commit f5f493681d
5 changed files with 50 additions and 16 deletions
+19
View File
@@ -131,6 +131,25 @@ inline bool SetPropertyInt(const ScriptRequest& rq, JS::HandleValue obj, int nam
return SetProperty<T, int>(rq, obj, name, value, constant, enumerable);
}
template<typename T>
inline bool GetObjectClassName(const ScriptRequest& rq, JS::HandleObject obj, T& name)
{
JS::RootedValue constructor(rq.cx, JS::ObjectOrNullValue(JS_GetConstructor(rq.cx, obj)));
return constructor.isObject() && Script::HasProperty(rq, constructor, "name") && Script::GetProperty(rq, constructor, "name", name);
}
/**
* Get the name of the object's class. Note that inheritance may lead to unexpected results.
*/
template<typename T>
inline bool GetObjectClassName(const ScriptRequest& rq, JS::HandleValue val, T& name)
{
JS::RootedObject obj(rq.cx, val.toObjectOrNull());
if (!obj)
return false;
return GetObjectClassName(rq, obj, name);
}
inline bool FreezeObject(const ScriptRequest& rq, JS::HandleValue objVal, bool deep)
{
if (!objVal.isObject())