From 9cea2bb8fef210d727fb45fd78b59be1687203a3 Mon Sep 17 00:00:00 2001 From: elexis Date: Thu, 29 Sep 2016 10:25:48 +0000 Subject: [PATCH] Fix paired techs following a754b1bad4. Patch by Imarok, fixes #4251, refs #3823. This was SVN commit r18790. --- .../data/mods/public/gui/session/selection_panels.js | 12 +++++++++--- .../public/simulation/components/ProductionQueue.js | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/binaries/data/mods/public/gui/session/selection_panels.js b/binaries/data/mods/public/gui/session/selection_panels.js index 246493d01e..1e184d2525 100644 --- a/binaries/data/mods/public/gui/session/selection_panels.js +++ b/binaries/data/mods/public/gui/session/selection_panels.js @@ -745,9 +745,15 @@ g_SelectionPanels.Research = { // Remove the techs we already have in ret (with the same name and techCostMultiplier) let filteredTechs = state.production.technologies.filter( tech => tech != null && !ret.some( - item => item.tech == tech && Object.keys(item.techCostMultiplier).every( - k => item.techCostMultiplier[k] == state.production.techCostMultiplier[k] - ))); + item => + (item.tech == tech || + item.tech.pair && + tech.pair && + item.tech.bottom == tech.bottom && + item.tech.top == tech.top) && + Object.keys(item.techCostMultiplier).every( + k => item.techCostMultiplier[k] == state.production.techCostMultiplier[k]) + )); if (filteredTechs.length + ret.length <= this.getMaxNumberOfItems() && getNumberOfRightPanelButtons() <= this.getMaxNumberOfItems() * (filteredTechs.some(tech => !!tech.pair) ? 1 : 2)) diff --git a/binaries/data/mods/public/simulation/components/ProductionQueue.js b/binaries/data/mods/public/simulation/components/ProductionQueue.js index b05f6932c0..531110d094 100644 --- a/binaries/data/mods/public/simulation/components/ProductionQueue.js +++ b/binaries/data/mods/public/simulation/components/ProductionQueue.js @@ -337,9 +337,13 @@ ProductionQueue.prototype.AddBatch = function(templateName, type, count, metadat var template = cmpDataTemplateManager.GetTechnologyTemplate(templateName); if (!template) return; - if (this.GetTechnologiesList().indexOf(templateName) == -1) + if (!this.GetTechnologiesList().some(tech => + tech && + (tech == templateName || + tech.pair && + (tech.top == templateName || tech.bottom == templateName)))) { - warn("This entity cannot research " + JSON.stringify(templateName)); + error("This entity cannot research " + templateName); return; } var cmpPlayer = QueryOwnerInterface(this.entity);