Index: ps/trunk/binaries/data/mods/public/simulation/ai/common-api/gamestate.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/ai/common-api/gamestate.js +++ ps/trunk/binaries/data/mods/public/simulation/ai/common-api/gamestate.js @@ -225,7 +225,7 @@ /** true if started or queued */ m.GameState.prototype.isResearching = function(template) { - return this.playerData.researchStarted[template] !== undefined || + return this.playerData.researchStarted.has(template) || this.playerData.researchQueued[template] !== undefined; }; @@ -241,7 +241,7 @@ // researching or already researched: NOO. if (this.playerData.researchQueued[techTemplateName] || - this.playerData.researchStarted[techTemplateName] || + this.playerData.researchStarted.has(techTemplateName) || this.playerData.researchedTechs.has(techTemplateName)) return false; @@ -253,7 +253,7 @@ { let other = template.pairedWith(); if (this.playerData.researchQueued[other] || - this.playerData.researchStarted[other] || + this.playerData.researchStarted.has(other) || this.playerData.researchedTechs.has(other)) return false; } Index: ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js +++ ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -704,7 +704,7 @@ return {}; let ret = {}; - for (let tech in cmpTechnologyManager.GetStartedTechs()) + for (let tech of cmpTechnologyManager.GetStartedTechs()) { ret[tech] = { "researcher": cmpTechnologyManager.GetResearcher(tech) }; let cmpProductionQueue = Engine.QueryInterface(ret[tech].researcher, IID_ProductionQueue); Index: ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js +++ ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js @@ -24,7 +24,9 @@ this.researchedTechs = new Set(); this.researchQueued = {}; // technologies which are queued for research - this.researchStarted = {}; // technologies which are being researched currently (non-queued) + + // technologies which are being researched currently (non-queued) + this.researchStarted = new Set(); // This stores the modifications to unit stats from researched technologies // Example data: {"ResourceGatherer/Rates/food.grain": [ @@ -101,7 +103,7 @@ TechnologyManager.prototype.IsTechnologyStarted = function(tech) { - return this.researchStarted[tech] !== undefined; + return this.researchStarted.has(tech); }; // Checks the requirements for a technology to see if it can be researched at the current time @@ -400,7 +402,7 @@ // Marks a technology as actively being researched TechnologyManager.prototype.StartedResearch = function(tech, notification) { - this.researchStarted[tech] = true; + this.researchStarted.add(tech); if (notification && tech.startsWith("phase")) { @@ -418,7 +420,7 @@ // Marks a technology as not being currently researched TechnologyManager.prototype.StoppedResearch = function(tech, notification) { - if (notification && tech.startsWith("phase") && this.researchStarted[tech]) + if (notification && tech.startsWith("phase") && this.researchStarted.has(tech)) { let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); @@ -431,7 +433,7 @@ } delete this.researchQueued[tech]; - delete this.researchStarted[tech]; + this.researchStarted.delete(tech); }; // Checks whether a technology is set to be researched @@ -443,7 +445,9 @@ return false; }; -// Get all techs that are currently being researched +/** + * Returns the names of technologies that are currently being researched (non-queued). + */ TechnologyManager.prototype.GetStartedTechs = function() { return this.researchStarted; Index: ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js =================================================================== --- ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js +++ ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js @@ -126,7 +126,7 @@ AddMock(100, IID_TechnologyManager, { IsTechnologyResearched: function(tech) { if (tech == "phase_village") return true; else return false; }, GetQueuedResearch: function() { return {}; }, - GetStartedTechs: function() { return {}; }, + GetStartedTechs: function() { return new Set(); }, GetResearchedTechs: function() { return {}; }, GetClassCounts: function() { return {}; }, GetTypeCountsByClass: function() { return {}; }, @@ -212,7 +212,7 @@ AddMock(101, IID_TechnologyManager, { IsTechnologyResearched: function(tech) { if (tech == "phase_village") return true; else return false; }, GetQueuedResearch: function() { return {}; }, - GetStartedTechs: function() { return {}; }, + GetStartedTechs: function() { return new Set(); }, GetResearchedTechs: function() { return {}; }, GetClassCounts: function() { return {}; }, GetTypeCountsByClass: function() { return {}; }, @@ -296,7 +296,7 @@ entityCounts: {"Foo": 5}, entityLimitChangers: {"Foo": {}}, researchQueued: {}, - researchStarted: {}, + researchStarted: new Set(), researchedTechs: new Set(), classCounts: {}, typeCountsByClass: {}, @@ -345,7 +345,7 @@ entityCounts: {"Bar": 0}, entityLimitChangers: {"Bar": {}}, researchQueued: {}, - researchStarted: {}, + researchStarted: new Set(), researchedTechs: new Set(), classCounts: {}, typeCountsByClass: {}, @@ -403,7 +403,7 @@ "entityCounts": {"Foo": 5}, "entityLimitChangers": {"Foo": {}}, "researchQueued": {}, - "researchStarted": {}, + "researchStarted": new Set(), "researchedTechs": new Set(), "classCounts": {}, "typeCountsByClass": {}, @@ -475,7 +475,7 @@ "entityCounts": {"Bar": 0}, "entityLimitChangers": {"Bar": {}}, "researchQueued": {}, - "researchStarted": {}, + "researchStarted": new Set(), "researchedTechs": new Set(), "classCounts": {}, "typeCountsByClass": {},