# HG changeset patch # User Jason Maltzen # Date 2021-09-10 00:02:16 # Node ID d6859ea7177f26dd26fbc589ed8a64eb7389400d # Parent 57e33102e42b9a8d1487111ad2bfbf608104c5a7 Add some sanity checks on min/max concentration and min/max reagents in recipe generation. Also, clear out the search queue when generation has finished so the queue isn't loaded next time. This fixes the start/resume button state when entering the recipe generator after a prior run had finished. diff --git a/Services/RecipeGenerator.cs b/Services/RecipeGenerator.cs --- a/Services/RecipeGenerator.cs +++ b/Services/RecipeGenerator.cs @@ -186,6 +186,12 @@ namespace DesertPaintCodex.Services FullQuantity = fullQuantity; FullQuantityDepth = fullQuantityDepth; + // Sanity check + if (MinConcentration < 10) MinConcentration = 10; + if (MaxConcentration < MinConcentration) MaxConcentration = MinConcentration; + if (MinReagents < 1) MinReagents = 1; + if (MaxReagents < MinReagents) MaxReagents = MinReagents; + // first, sort reagents by cost. InitSortedReagents(); @@ -521,6 +527,12 @@ namespace DesertPaintCodex.Services if (!done) return; _running = false; + if (!_requestCancel && !_searchQueue.IsEmpty) + { + Debug.WriteLine($"Recipe generation complete, but search queue isn't empty {_searchQueue.Count}."); + WriteLog($"Recipe generation complete, but search queue isn't empty {_searchQueue.Count}."); + _searchQueue.Clear(); + } _requestCancel = false; Finished?.Invoke(this, EventArgs.Empty); }