mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
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:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user