mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-29 04:32:17 +00:00
Fix sparse array serialization
This was SVN commit r10442.
This commit is contained in:
@@ -72,6 +72,13 @@ void CBinarySerializerScriptImpl::HandleScriptVal(jsval val)
|
||||
{
|
||||
m_Serializer.NumberU8_Unbounded("type", SCRIPT_TYPE_ARRAY);
|
||||
// TODO: probably should have a more efficient storage format
|
||||
|
||||
// Arrays like [1, 2, ] have an 'undefined' at the end which is part of the
|
||||
// length but seemingly isn't enumerated, so store the length explicitly
|
||||
jsuint length = 0;
|
||||
if (!JS_GetArrayLength(cx, obj, &length))
|
||||
throw PSERROR_Serialize_ScriptError("JS_GetArrayLength failed");
|
||||
m_Serializer.NumberU32_Unbounded("array length", length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user