Ticket #4251: 4251_fix_v4.patch

File 4251_fix_v4.patch, 2.6 KB (added by elexis, 8 years ago)

Some newlines to keep it readable and group terms logically.

  • binaries/data/mods/public/gui/session/selection_panels.js

    g_SelectionPanels.Research = {  
    743743            if (!state.production || !state.production.technologies)
    744744                continue;
    745745            // Remove the techs we already have in ret (with the same name and techCostMultiplier)
    746746            let filteredTechs = state.production.technologies.filter(
    747747                tech => tech != null && !ret.some(
    748                     item => item.tech == tech && Object.keys(item.techCostMultiplier).every(
    749                         k => item.techCostMultiplier[k] == state.production.techCostMultiplier[k]
    750             )));
     748                    item =>
     749                        (item.tech == tech ||
     750                            item.tech.pair &&
     751                            tech.pair &&
     752                            item.tech.bottom == tech.bottom &&
     753                            item.tech.top == tech.top) &&
     754                        Object.keys(item.techCostMultiplier).every(
     755                            k => item.techCostMultiplier[k] == state.production.techCostMultiplier[k])
     756            ));
    751757
    752758            if (filteredTechs.length + ret.length <= this.getMaxNumberOfItems() &&
    753759                getNumberOfRightPanelButtons() <= this.getMaxNumberOfItems() * (filteredTechs.some(tech => !!tech.pair) ? 1 : 2))
    754760                ret = ret.concat(filteredTechs.map(tech => ({
    755761                    "tech": tech,
  • binaries/data/mods/public/simulation/components/ProductionQueue.js

    ProductionQueue.prototype.AddBatch = fun  
    335335            // Load the technology template
    336336            var cmpDataTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_DataTemplateManager);
    337337            var template = cmpDataTemplateManager.GetTechnologyTemplate(templateName);
    338338            if (!template)
    339339                return;
    340             if (this.GetTechnologiesList().indexOf(templateName) == -1)
     340            if (!this.GetTechnologiesList().some(tech =>
     341                tech &&
     342                    (tech == templateName ||
     343                        tech.pair &&
     344                        (tech.top == templateName || tech.bottom == templateName))))
    341345            {
    342                 warn("This entity cannot research " + JSON.stringify(templateName));
     346                error("This entity cannot research " + uneval(templateName) +
     347                    ". It can only research: " + uneval(this.GetTechnologiesList()));
    343348                return;
    344349            }
    345350            var cmpPlayer = QueryOwnerInterface(this.entity);
    346351            let techCostMultiplier = this.GetTechCostMultiplier();
    347352            let time =  techCostMultiplier.time * template.researchTime * cmpPlayer.GetCheatTimeMultiplier();