Fix paired techs following a754b1bad4. Patch by Imarok, fixes #4251, refs #3823.

This was SVN commit r18790.
This commit is contained in:
elexis
2016-09-29 10:25:48 +00:00
parent 5bbed34aaf
commit 9cea2bb8fe
2 changed files with 15 additions and 5 deletions
@@ -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))
@@ -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);