mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-28 17:28:45 +00:00
Fix lossy fixed<->jsval conversion.
(Hopefully this will really fix the OOS errors.) This was SVN commit r7692.
This commit is contained in:
@@ -186,7 +186,8 @@ template<> bool ScriptInterface::FromJSVal<fixed>(JSContext* cx, jsval v, fixed&
|
||||
if (!JS_ValueToNumber(cx, v, &ret))
|
||||
return false;
|
||||
out = fixed::FromDouble(ret);
|
||||
// TODO: ought to check that this conversion is consistent and portable
|
||||
// double can precisely represent the full range of fixed, so this is a non-lossy conversion
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -194,7 +195,6 @@ template<> jsval ScriptInterface::ToJSVal<fixed>(JSContext* cx, const fixed& val
|
||||
{
|
||||
jsval rval = JSVAL_VOID;
|
||||
JS_NewNumberValue(cx, val.ToDouble(), &rval); // ignore return value
|
||||
// TODO: ought to check that this conversion is consistent and portable
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user