From ad4172d21c291dd1ab791900df45dfce5368bbd2 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Sun, 28 May 2017 19:08:23 +0100 Subject: Minor cBrewingRecipes cleanup (#3731) --- src/BrewingRecipes.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/BrewingRecipes.h') diff --git a/src/BrewingRecipes.h b/src/BrewingRecipes.h index f42384896..78e1c196b 100644 --- a/src/BrewingRecipes.h +++ b/src/BrewingRecipes.h @@ -5,7 +5,7 @@ -class cItem; +#include "Item.h" @@ -15,21 +15,21 @@ class cBrewingRecipes { public: cBrewingRecipes(void); - ~cBrewingRecipes(); void ReloadRecipes(void); struct cRecipe { - cRecipe() {} - cRecipe(cRecipe &&) {} - - cRecipe(const cRecipe&) = delete; - cRecipe & operator=(const cRecipe&) = delete; - - std::unique_ptr Input; - std::unique_ptr Output; - std::unique_ptr Ingredient; + cRecipe() + { + // These items always have the same type + Input.m_ItemType = E_ITEM_POTION; + Output.m_ItemType = E_ITEM_POTION; + } + + cItem Input; + cItem Output; + cItem Ingredient; }; /** Returns a recipe for the specified input, nullptr if no recipe found */ @@ -44,15 +44,18 @@ public: /** Returns true if the item is the fuel, false if not. */ bool IsFuel(const cItem & a_Item) const; private: + using cRecipes = std::vector>; + void ClearRecipes(void); /** Parses the recipe contained in the line, adds it to m_pState's recipes. Logs a warning to the console on input error. */ - void AddRecipeFromLine(const AString & a_Line, unsigned int a_LineNum); + void AddRecipeFromLine(AString a_Line, unsigned int a_LineNum); /** Parses an item string, returns true if successful. */ bool ParseItem(const AString & a_String, cItem & a_Item); - struct sBrewingRecipeState; - std::unique_ptr m_pState; + /** The collection of parsed recipes. + GetRecipeFrom may cache splash variants of recipes here but the observable behaviour is constant, so this should be mutable. */ + mutable cRecipes m_Recipes; }; -- cgit v1.2.3