0ad/binaries/data/mods/public/globalscripts/utility.js
Itms c7edc09f51 Revert 7cc2d65ec7.
The problem caused by nested Maps is actually #3374.
Cloning the data object saved by the !AuraManager fixes #3188.
Also, using Map fixes a serialization problem, refs #3375.

On top of those changes, some reordering of add/multiply to avoid any
ordering mistake.

Fixes #3164, Refs #3374

This was SVN commit r16929.
2015-08-21 07:29:08 +00:00

17 lines
349 B
JavaScript

/**
* returns a clone of a simple object or array
* Only valid JSON objects are accepted
* So no recursion, and only plain objects or arrays
*/
function clone(o)
{
if (o instanceof Array)
var r = [];
else if (o instanceof Object)
var r = {};
else // native data type
return o;
for (var key in o)
r[key] = clone(o[key]);
return r;
}