Fix typo in c917c39a0d
.
Reported by @Mr.lie at https://wildfiregames.com/forum/topic/108069-diplomacy-broken-since-rev-27722. Based on a patch by: @elexis This was SVN commit r27824.
This commit is contained in:
parent
3d2561f096
commit
a10e025324
@ -18,7 +18,7 @@ Diplomacy.prototype.SerializableAttributes = [
|
||||
Diplomacy.prototype.Serialize = function()
|
||||
{
|
||||
const state = {};
|
||||
for (const key in this.SerializableAttributes)
|
||||
for (const key of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(key))
|
||||
state[key] = this[key];
|
||||
|
||||
@ -27,8 +27,9 @@ Diplomacy.prototype.Serialize = function()
|
||||
|
||||
Diplomacy.prototype.Deserialize = function(state)
|
||||
{
|
||||
for (const prop in state)
|
||||
this[prop] = state[prop];
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (att in state)
|
||||
this[att] = state[att];
|
||||
};
|
||||
|
||||
Diplomacy.prototype.Init = function()
|
||||
|
@ -77,3 +77,8 @@ diplo = [1, 1, 0];
|
||||
cmpDiplomacy.SetDiplomacy(diplo);
|
||||
diplo[1] = -1;
|
||||
TS_ASSERT(cmpDiplomacy.IsAlly(1));
|
||||
|
||||
|
||||
// (De)serialisation preserves relations.
|
||||
const deserialisedCmp = SerializationCycle(cmpDiplomacy);
|
||||
TS_ASSERT(deserialisedCmp.IsAlly(1));
|
||||
|
Loading…
Reference in New Issue
Block a user