From 3bb05a74b650edf8f4e6da352e40535b7854c7b2 Mon Sep 17 00:00:00 2001 From: Kirk McDonald Date: Tue, 22 Oct 2024 14:11:52 -0700 Subject: [PATCH] Fix crash on ignoring building-count build target. --- factory.js | 12 ++++++++++++ target.js | 16 +++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/factory.js b/factory.js index 8899892..18bc64b 100644 --- a/factory.js +++ b/factory.js @@ -568,10 +568,12 @@ class FactorySpecification { d3.select(target.element).remove() } toggleIgnore(item) { + let updateTargets = false if (this.ignore.has(item)) { this.ignore.delete(item) if (!this.isItemDisabled(item)) { this.priority.removeRecipe(item.disableRecipe) + updateTargets = true } } else { this.ignore.add(item) @@ -589,6 +591,16 @@ class FactorySpecification { } let hundred = Rational.from_float(100) this.priority.addRecipe(item.disableRecipe, hundred, level) + updateTargets = true + } + } + if (updateTargets) { + // Update build targets. + for (let target of this.buildTargets) { + if (target.item === item) { + target.displayRecipes() + target.rateChanged() + } } } } diff --git a/target.js b/target.js index d703c25..d3fd532 100644 --- a/target.js +++ b/target.js @@ -202,14 +202,16 @@ export class BuildTarget { this.recipeSelector.selectAll("*").remove() let recipes = [] let found = false - for (let recipe of this.item.recipes) { - if (spec.disable.has(recipe) || !recipe.isNetProducer(this.item)) { - continue + if (!spec.ignore.has(this.item)) { + for (let recipe of this.item.recipes) { + if (spec.disable.has(recipe) || !recipe.isNetProducer(this.item)) { + continue + } + if (recipe === this.recipe) { + found = true + } + recipes.push(recipe) } - if (recipe === this.recipe) { - found = true - } - recipes.push(recipe) } if (!found) { this.recipe = null