mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 14:53:56 -07:00
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.
17 lines
349 B
JavaScript
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;
|
|
}
|