Ticket #4239: PRIOR_broken_serialization_patch.diff

File PRIOR_broken_serialization_patch.diff, 3.2 KB (added by elexis, 8 years ago)

This patch was uploaded by Itms along with comment:9. attachment:oos_backref_patched.7z has shown that patch is incomplete.

  • binaries/data/mods/public/simulation/components/Auras.js

     
    66    "</attribute>" +
    77    "<text a:help='A whitespace-separated list of aura files, placed under simulation/data/auras/'/>";
    88
     9Auras.prototype.Serialize = function()
     10{
     11    let ret = {};
     12    for (let key in this)
     13    {
     14        if (!this.hasOwnProperty(key))
     15            continue;
     16
     17        // Don't serialize the templates themselves
     18        if (key == "auras")
     19            continue;
     20
     21        ret[key] = this[key];
     22    }
     23
     24    return ret;
     25};
     26
     27Auras.prototype.Deserialize = function(data)
     28{
     29    for (let key in data)
     30        if (data.hasOwnProperty(key))
     31            this[key] = data[key];
     32
     33    // Reload aura templates from the disk
     34    this.auras = {};
     35    let cmpDataTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager);
     36    for (let name of this.GetAuraNames())
     37        this.auras[name] = cmpDataTemplateManager.GetAuraTemplate(name);
     38};
     39
    940Auras.prototype.Init = function()
    1041{
    1142    let cmpDataTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager);
    1243    this.auras = {};
    1344    this.affectedPlayers = {};
    14     let auraNames = this.GetAuraNames();
    15     for (let name of auraNames)
     45    for (let name of this.GetAuraNames())
    1646    {
    1747        this.affectedPlayers[name] = [];
    1848        this.auras[name] = cmpDataTemplateManager.GetAuraTemplate(name);
  • binaries/data/mods/public/simulation/components/DataTemplateManager.js

     
    1515        this.GetTechnologyTemplate(techNames[i]);
    1616};
    1717
     18DataTemplateManager.prototype.Serialize = null; // we have no dynamic state to save
     19
     20DataTemplateManager.prototype.Deserialize = function()
     21{
     22    this.Init();
     23};
     24
    1825DataTemplateManager.prototype.GetTechnologyTemplate = function(template)
    1926{
    2027    if (!this.allTechs[template])
  • binaries/data/mods/public/simulation/components/TechnologyManager.js

     
    55
    66TechnologyManager.prototype.Serialize = function()
    77{
    8     // The modifications cache will be affected by property reads from the GUI and other places so we shouldn't
    9     // serialize it.
     8    let ret = {};
     9    for (let key in this)
     10        if (this.hasOwnProperty(key))
     11            ret[key] = this[key];
    1012
    11     var ret = {};
    12     for (var i in this)
    13     {
    14         if (this.hasOwnProperty(i))
    15             ret[i] = this[i];
    16     }
     13    // The modifications cache will be affected by property reads from the GUI and
     14    // other places so we shouldn't serialize it.
    1715    ret.modificationCache = {};
     16
    1817    return ret;
    1918};
    2019
     
    4544    for (var key in allTechs)
    4645    {
    4746        if (allTechs[key].autoResearch || allTechs[key].top)
    48             this.autoResearchTech[key] = allTechs[key];
     47            this.autoResearchTech[key] = true;
    4948    }
    5049};
    5150