Changeset - d6859ea7177f
[Not reviewed]
default
0 1 0
Jason Maltzen - 3 years ago 2021-09-10 00:02:16
jason@hiddenachievement.com
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.
1 file changed with 12 insertions and 0 deletions:
0 comments (0 inline, 0 general)
Services/RecipeGenerator.cs
Show inline comments
...
 
@@ -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);
 
        }
0 comments (0 inline, 0 general)