Changeset - 339712c9aa0a
[Not reviewed]
default
0 1 0
Jason Maltzen (jmaltzen) - 9 years ago 2015-12-26 04:08:57
jason.maltzen@unsanctioned.net
Fix up a crash that can happen one resume if ingredients are disabled between recipe generation runs.
1 file changed with 14 insertions and 11 deletions:
0 comments (0 inline, 0 general)
RecipeGenerator.cs
Show inline comments
...
 
@@ -246,7 +246,7 @@ namespace DesertPaintLab
 
                for (; idx < costSortedReagents.Count; ++idx)
 
                {
 
                    bool inUse = reagentInUse[idx];
 
                    if (inUse == false)
 
                    if ((inUse == false) && (costSortedReagents[(int)idx].Enabled))
 
                    {
 
                        //Console.WriteLine("Found free reagent idx {0}", idx);
 
                        reagentInUse[idx] = true;
...
 
@@ -384,7 +384,10 @@ namespace DesertPaintLab
 
                                        currentWeights[nextReagentPos] = weight;
 
                                        if (isInUse != 0)
 
                                        {
 
                                            reagentInUse[reagentId] = true;
 
                                            if (reagentId != INVALID_REAGENT)
 
                                            {
 
                                                reagentInUse[reagentId] = true;
 
                                            }
 
                                        }
 
                                        ++nextReagentPos;
 
                                    }
...
 
@@ -540,10 +543,7 @@ namespace DesertPaintLab
 
            foreach (string name in ReagentManager.Names)
 
            {
 
                Reagent reagent = ReagentManager.GetReagent(name);
 
                if (reagent.Enabled)
 
                {
 
                    costSortedReagents.Add(reagent);
 
                }
 
                costSortedReagents.Add(reagent);
 
            }
 
            costSortedReagents.Sort(new ReagentCostSort());
 
        }
...
 
@@ -574,7 +574,7 @@ namespace DesertPaintLab
 
            recipe.Reactions = reactions;
 
            foreach (Reagent reagent in costSortedReagents)
 
            {
 
                if (!reagent.IsCatalyst && reagent.RecipeMax >= 10)
 
                if (!reagent.IsCatalyst && reagent.RecipeMax >= 10 && reagent.Enabled)
 
                {
 
                    recipe.Clear();
 
                    recipe.AddReagent(reagent.Name, 10);
...
 
@@ -589,10 +589,13 @@ namespace DesertPaintLab
 
            }
 
            for (uint reagentIdx = 0; reagentIdx < costSortedReagents.Count; ++reagentIdx)
 
            {
 
                SearchNode initialNode = new SearchNode(costSortedReagents, reagentIdx);
 
                initialNode.MaxQuantity = maxQuantity;
 
                initialNode.MaxReagents = maxReagents;
 
                searchQueue.Enqueue(initialNode);
 
                if (costSortedReagents[(int)reagentIdx].Enabled)
 
                {
 
                    SearchNode initialNode = new SearchNode(costSortedReagents, reagentIdx);
 
                    initialNode.MaxQuantity = maxQuantity;
 
                    initialNode.MaxReagents = maxReagents;
 
                    searchQueue.Enqueue(initialNode);
 
                }
 
            }
 
            
 
            // start worker threads to do the actual work
0 comments (0 inline, 0 general)