1
0
forked from 0ad/0ad

Fix (de)serialisation in the Researcher component.

A typo in the serialisation function.
Also just serialise the properties that are assigned in cmpResearcher
and cmpTrainer.

Introduced in e4925e02d0
Reported by: @nwtour
Differential revision: https://code.wildfiregames.com/D4386
Tested by: @nwtour
This was SVN commit r26105.
This commit is contained in:
Freagarach 2021-12-24 08:11:17 +00:00
parent 478164962f
commit 381bbb59e8
2 changed files with 11 additions and 7 deletions

View File

@ -167,15 +167,17 @@ Researcher.prototype.Item.prototype.Serialize = function(id)
const result = {
"id": id
};
for (const att in this.SerializableAttributes)
result[att] = this[att];
for (const att of this.SerializableAttributes)
if (this.hasOwnProperty(att))
result[att] = this[att];
return result;
};
Researcher.prototype.Item.prototype.Deserialize = function(data)
{
for (const att of this.SerializableAttributes)
this[att] = data[att];
for (const att in data)
if (this.SerializableAttributes.includes(att))
this[att] = data[att];
};
Researcher.prototype.Init = function()

View File

@ -394,14 +394,16 @@ Trainer.prototype.Item.prototype.Serialize = function(id)
"id": id
};
for (const att of this.SerializableAttributes)
result[att] = this[att];
if (this.hasOwnProperty(att))
result[att] = this[att];
return result;
};
Trainer.prototype.Item.prototype.Deserialize = function(data)
{
for (const att of this.SerializableAttributes)
this[att] = data[att];
for (const att in data)
if (this.SerializableAttributes.includes(att))
this[att] = data[att];
};
Trainer.prototype.Init = function()