Don't serialize the templates of autoresearched technologies.

Refs #3834, #4239
Differential Revision: https://code.wildfiregames.com/D1109
Reviewed By: temple
Comments By: Itms
Proposed By: sanderd17
This was SVN commit r20606.
This commit is contained in:
elexis 2017-12-07 23:26:29 +00:00
parent 02cb770c1d
commit 9c0e37f2c0

View File

@ -40,13 +40,11 @@ TechnologyManager.prototype.Init = function()
// Some technologies are automatically researched when their conditions are met. They have no cost and are
// researched instantly. This allows civ bonuses and more complicated technologies.
this.autoResearchTech = {};
this.unresearchedAutoResearchTechs = new Set();
var allTechs = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager).GetAllTechs();
for (var key in allTechs)
{
if (allTechs[key].autoResearch || allTechs[key].top)
this.autoResearchTech[key] = allTechs[key];
}
this.unresearchedAutoResearchTechs.add(key);
};
TechnologyManager.prototype.OnUpdate = function()
@ -59,13 +57,13 @@ TechnologyManager.prototype.OnUpdate = function()
TechnologyManager.prototype.UpdateAutoResearch = function()
{
var cmpDataTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager);
for (var key in this.autoResearchTech)
for (let key of this.unresearchedAutoResearchTechs)
{
var tech = cmpDataTempMan.GetTechnologyTemplate(key);
if ((tech.autoResearch && this.CanResearch(key))
|| (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom))))
{
delete this.autoResearchTech[key];
this.unresearchedAutoResearchTechs.delete(key);
this.ResearchTechnology(key);
return; // We will have recursively handled any knock-on effects so can just return
}