diff --git a/ReagentManager.cs b/ReagentManager.cs --- a/ReagentManager.cs +++ b/ReagentManager.cs @@ -115,13 +115,19 @@ namespace DesertPaintLab { string ppname = match.Groups["name"].Value; string name = null; - nameLookup.TryGetValue(ppname, out name); - Reagent reagent = GetReagent(name); - if (reagent != null && !reagent.IsCatalyst) + if (nameLookup.TryGetValue(ppname, out name)) { - reagent.Enabled = match.Groups["enabled"].Value.Equals("Y"); - reagent.Cost = uint.Parse(match.Groups["cost"].Value); - reagent.RecipeMax = uint.Parse(match.Groups["max"].Value); + Reagent reagent = GetReagent(name); + if (reagent != null && !reagent.IsCatalyst) + { + reagent.Enabled = match.Groups["enabled"].Value.Equals("Y"); + reagent.Cost = uint.Parse(match.Groups["cost"].Value); + reagent.RecipeMax = uint.Parse(match.Groups["max"].Value); + } + } + else + { + // bad name? } } else @@ -131,12 +137,18 @@ namespace DesertPaintLab { string ppname = match.Groups["name"].Value; string name = null; - nameLookup.TryGetValue(ppname, out name); - Reagent reagent = GetReagent(name); - if (reagent != null && reagent.IsCatalyst) + if (nameLookup.TryGetValue(ppname, out name)) { - reagent.Enabled = match.Groups["enabled"].Value.Equals("Y"); - reagent.Cost = uint.Parse(match.Groups["cost"].Value); + Reagent reagent = GetReagent(name); + if (reagent != null && reagent.IsCatalyst) + { + reagent.Enabled = match.Groups["enabled"].Value.Equals("Y"); + reagent.Cost = uint.Parse(match.Groups["cost"].Value); + } + } + else + { + // bad name? } } } @@ -240,13 +252,11 @@ namespace DesertPaintLab public static Reagent GetReagent(string reagentName) { Reagent returnVal; - reagents.TryGetValue(reagentName, out returnVal); - if (returnVal == null) + if (!reagents.TryGetValue(reagentName, out returnVal)) { // convert pp name to our internal name string otherName = null; - nameLookup.TryGetValue(reagentName, out otherName); - if (otherName != null) + if (nameLookup.TryGetValue(reagentName, out otherName)) { reagents.TryGetValue(otherName, out returnVal); }