Ticket #4455: fixAssumptions_v1-1.patch

File fixAssumptions_v1-1.patch, 3.6 KB (added by s0600204, 7 years ago)
  • binaries/data/mods/public/globalscripts/Templates.js

    diff --git a/binaries/data/mods/public/globalscripts/Templates.js b/binaries/data/mods/public/globalscripts/Templates.js
    index db54ca469..5f01d698e 100644
    a b function GetTechnologyDataHelper(template, civ, resources)  
    367367
    368368    ret.cost = { "time": template.researchTime ? +template.researchTime : 0 };
    369369    for (let type of resources.GetCodes())
    370         ret.cost[type] = template.cost ? +template.cost[type] : 0;
     370        ret.cost[type] = +(template.cost && template.cost[type] || 0);
    371371
    372372    ret.tooltip = template.tooltip;
    373373    ret.requirementsTooltip = template.requirementsTooltip || "";
  • binaries/data/mods/public/gui/structree/draw.js

    diff --git a/binaries/data/mods/public/gui/structree/draw.js b/binaries/data/mods/public/gui/structree/draw.js
    index 44be50783..ffa34a0e3 100644
    a b function draw()  
    183183                    prod = g_ParsedData.units[prod];
    184184                    break;
    185185                case "techs":
    186                     prod = clone(g_ParsedData.techs[civCode][prod]);
     186                    prod = clone(g_ParsedData.techs[g_SelectedCiv][prod]);
    187187                    for (let res in trainer.techCostMultiplier)
    188188                        if (prod.cost[res])
    189189                            prod.cost[res] *= trainer.techCostMultiplier[res];
  • binaries/data/mods/public/gui/structree/helper.js

    diff --git a/binaries/data/mods/public/gui/structree/helper.js b/binaries/data/mods/public/gui/structree/helper.js
    index da01b79e1..6ab61a583 100644
    a b function GetPhaseOfTechnology(techName)  
    8080    }
    8181
    8282    if (!g_ParsedData.techs[g_SelectedCiv][techName])
    83         warn(g_SelectedCiv + " : " + techName);
     83    {
     84        warn("The \"" + techName + "\" technology is not researchable in any structure buildable by the " + g_SelectedCiv + " civilisation, but is required by something that this civ *can* research, train or build!");
     85        g_ParsedData.techs[g_SelectedCiv][techName] = loadTechnology(techName);
     86    }
     87
    8488    let techReqs = g_ParsedData.techs[g_SelectedCiv][techName].reqs;
    8589    if (!techReqs)
    8690        return false;
    function GetPhaseOfTechnology(techName)  
    9195            {
    9296                if (basename(tech).slice(0, 5) === "phase")
    9397                    return tech;
     98                if (basename(tech).slice(0, 4) === "pair")
     99                    continue;
    94100                phaseIdx = Math.max(phaseIdx, g_ParsedData.phaseList.indexOf(GetPhaseOfTechnology(tech)));
    95101            }
    96102    return g_ParsedData.phaseList[phaseIdx] || false;
  • binaries/data/mods/public/gui/structree/structree.js

    diff --git a/binaries/data/mods/public/gui/structree/structree.js b/binaries/data/mods/public/gui/structree/structree.js
    index 20f20fdcb..8b40b9e37 100644
    a b function selectCiv(civCode)  
    245245        buildList[phase].push(structCode);
    246246    }
    247247    for (let unitCode of g_Lists.units)
    248         if (g_ParsedData.units[unitCode] && g_ParsedData.units[unitCode].production)
     248        if (g_ParsedData.units[unitCode] && g_ParsedData.units[unitCode].production && Object.keys(g_ParsedData.units[unitCode].production).length)
     249        {
     250            // Splice out any `pair_*` techs for the actual techs of that pair
     251            if (g_ParsedData.units[unitCode].production.techs)
     252                for (let prod of g_ParsedData.units[unitCode].production.techs)
     253                    if (prod in techPairs)
     254                        g_ParsedData.units[unitCode].production.techs.splice(
     255                            g_ParsedData.units[unitCode].production.techs.indexOf(prod),
     256                            1, ...techPairs[prod].techs
     257                        );
     258
    249259            trainerList.push(unitCode);
     260        }
    250261
    251262    g_CivData[g_SelectedCiv].buildList = buildList;
    252263    g_CivData[g_SelectedCiv].trainList = trainerList;