mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Remove unused serialized cache of technology templates in TechnologyManager.researchedTechs.
Refs #3834, #3909, #4239, #4868, D1108 Differential Revision: https://code.wildfiregames.com/D1130 Reviewed By: mimo This was SVN commit r20610.
This commit is contained in:
parent
5f10ae7551
commit
a6f14f5631
3 changed files with 19 additions and 13 deletions
|
|
@ -219,7 +219,7 @@ m.GameState.prototype.getPhaseEntityRequirements = function(i)
|
|||
|
||||
m.GameState.prototype.isResearched = function(template)
|
||||
{
|
||||
return this.playerData.researchedTechs[template] !== undefined;
|
||||
return this.playerData.researchedTechs.has(template);
|
||||
};
|
||||
|
||||
/** true if started or queued */
|
||||
|
|
@ -242,7 +242,7 @@ m.GameState.prototype.canResearch = function(techTemplateName, noRequirementChec
|
|||
// researching or already researched: NOO.
|
||||
if (this.playerData.researchQueued[techTemplateName] ||
|
||||
this.playerData.researchStarted[techTemplateName] ||
|
||||
this.playerData.researchedTechs[techTemplateName])
|
||||
this.playerData.researchedTechs.has(techTemplateName))
|
||||
return false;
|
||||
|
||||
if (noRequirementCheck)
|
||||
|
|
@ -254,7 +254,7 @@ m.GameState.prototype.canResearch = function(techTemplateName, noRequirementChec
|
|||
let other = template.pairedWith();
|
||||
if (this.playerData.researchQueued[other] ||
|
||||
this.playerData.researchStarted[other] ||
|
||||
this.playerData.researchedTechs[other])
|
||||
this.playerData.researchedTechs.has(other))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ m.GameState.prototype.checkTechRequirements = function(reqs)
|
|||
switch (type)
|
||||
{
|
||||
case "techs":
|
||||
return req[type].every(tech => !!this.playerData.researchedTechs[tech]);
|
||||
return req[type].every(tech => this.playerData.researchedTechs.has(tech));
|
||||
|
||||
case "entities":
|
||||
return req[type].every(doesEntitySpecPass, this);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ TechnologyManager.prototype.Serialize = function()
|
|||
|
||||
TechnologyManager.prototype.Init = function()
|
||||
{
|
||||
this.researchedTechs = {}; // technologies which have been researched
|
||||
// Holds names of technologies which have been researched
|
||||
this.researchedTechs = new Set();
|
||||
|
||||
this.researchQueued = {}; // technologies which are queued for research
|
||||
this.researchStarted = {}; // technologies which are being researched currently (non-queued)
|
||||
|
||||
|
|
@ -94,7 +96,7 @@ TechnologyManager.prototype.IsTechnologyQueued = function(tech)
|
|||
|
||||
TechnologyManager.prototype.IsTechnologyResearched = function(tech)
|
||||
{
|
||||
return this.researchedTechs[tech] !== undefined;
|
||||
return this.researchedTechs.has(tech);
|
||||
};
|
||||
|
||||
TechnologyManager.prototype.IsTechnologyStarted = function(tech)
|
||||
|
|
@ -274,7 +276,7 @@ TechnologyManager.prototype.ResearchTechnology = function(tech)
|
|||
}
|
||||
|
||||
var modifiedComponents = {};
|
||||
this.researchedTechs[tech] = template;
|
||||
this.researchedTechs.add(tech);
|
||||
// store the modifications in an easy to access structure
|
||||
if (template.modifications)
|
||||
{
|
||||
|
|
@ -300,8 +302,7 @@ TechnologyManager.prototype.ResearchTechnology = function(tech)
|
|||
if (!i || this.IsTechnologyResearched(i))
|
||||
continue;
|
||||
|
||||
var template = this.GetTechnologyTemplate(i);
|
||||
this.researchedTechs[i] = template;
|
||||
this.researchedTechs.add(i);
|
||||
|
||||
// Change the EntityLimit if any
|
||||
let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
|
||||
|
|
@ -467,10 +468,15 @@ TechnologyManager.prototype.GetQueuedResearch = function()
|
|||
{
|
||||
return this.researchQueued;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the names of technologies that have already been researched.
|
||||
*/
|
||||
TechnologyManager.prototype.GetResearchedTechs = function()
|
||||
{
|
||||
return this.researchedTechs;
|
||||
};
|
||||
|
||||
TechnologyManager.prototype.GetClassCounts = function()
|
||||
{
|
||||
return this.classCounts;
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), {
|
|||
entityLimitChangers: {"Foo": {}},
|
||||
researchQueued: {},
|
||||
researchStarted: {},
|
||||
researchedTechs: {},
|
||||
researchedTechs: new Set(),
|
||||
classCounts: {},
|
||||
typeCountsByClass: {},
|
||||
canBarter: false,
|
||||
|
|
@ -346,7 +346,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), {
|
|||
entityLimitChangers: {"Bar": {}},
|
||||
researchQueued: {},
|
||||
researchStarted: {},
|
||||
researchedTechs: {},
|
||||
researchedTechs: new Set(),
|
||||
classCounts: {},
|
||||
typeCountsByClass: {},
|
||||
canBarter: false,
|
||||
|
|
@ -404,7 +404,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
|
|||
"entityLimitChangers": {"Foo": {}},
|
||||
"researchQueued": {},
|
||||
"researchStarted": {},
|
||||
"researchedTechs": {},
|
||||
"researchedTechs": new Set(),
|
||||
"classCounts": {},
|
||||
"typeCountsByClass": {},
|
||||
"canBarter": false,
|
||||
|
|
@ -476,7 +476,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
|
|||
"entityLimitChangers": {"Bar": {}},
|
||||
"researchQueued": {},
|
||||
"researchStarted": {},
|
||||
"researchedTechs": {},
|
||||
"researchedTechs": new Set(),
|
||||
"classCounts": {},
|
||||
"typeCountsByClass": {},
|
||||
"canBarter": false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue