Ticket #4239: PRIOR_broken_serialization_patch.diff
File PRIOR_broken_serialization_patch.diff, 3.2 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Auras.js
6 6 "</attribute>" + 7 7 "<text a:help='A whitespace-separated list of aura files, placed under simulation/data/auras/'/>"; 8 8 9 Auras.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 27 Auras.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 9 40 Auras.prototype.Init = function() 10 41 { 11 42 let cmpDataTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager); 12 43 this.auras = {}; 13 44 this.affectedPlayers = {}; 14 let auraNames = this.GetAuraNames(); 15 for (let name of auraNames) 45 for (let name of this.GetAuraNames()) 16 46 { 17 47 this.affectedPlayers[name] = []; 18 48 this.auras[name] = cmpDataTemplateManager.GetAuraTemplate(name); -
binaries/data/mods/public/simulation/components/DataTemplateManager.js
15 15 this.GetTechnologyTemplate(techNames[i]); 16 16 }; 17 17 18 DataTemplateManager.prototype.Serialize = null; // we have no dynamic state to save 19 20 DataTemplateManager.prototype.Deserialize = function() 21 { 22 this.Init(); 23 }; 24 18 25 DataTemplateManager.prototype.GetTechnologyTemplate = function(template) 19 26 { 20 27 if (!this.allTechs[template]) -
binaries/data/mods/public/simulation/components/TechnologyManager.js
5 5 6 6 TechnologyManager.prototype.Serialize = function() 7 7 { 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]; 10 12 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. 17 15 ret.modificationCache = {}; 16 18 17 return ret; 19 18 }; 20 19 … … 45 44 for (var key in allTechs) 46 45 { 47 46 if (allTechs[key].autoResearch || allTechs[key].top) 48 this.autoResearchTech[key] = allTechs[key];47 this.autoResearchTech[key] = true; 49 48 } 50 49 }; 51 50