Skip to content

Commit

Permalink
Fix crash on ignoring building-count build target.
Browse files Browse the repository at this point in the history
  • Loading branch information
KirkMcDonald committed Oct 22, 2024
1 parent 0f5cf7a commit 3bb05a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
12 changes: 12 additions & 0 deletions factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
}
}
}
}
Expand Down
16 changes: 9 additions & 7 deletions target.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3bb05a7

Please sign in to comment.