From 0beed83ae9e6d8502450489edddd27171ff15b53 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 31 Aug 2014 19:00:36 +0200 Subject: Rewrited furnace.txt loading. --- src/FurnaceRecipe.h | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'src/FurnaceRecipe.h') diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h index 77ed35a57..de3ee56a0 100644 --- a/src/FurnaceRecipe.h +++ b/src/FurnaceRecipe.h @@ -19,23 +19,23 @@ public: void ReloadRecipes(void); - struct Fuel + struct cFuel { cItem * In; int BurnTime; ///< How long this fuel burns, in ticks }; - struct Recipe + struct cRecipe { cItem * In; cItem * Out; int CookTime; ///< How long this recipe takes to smelt, in ticks }; - /// Returns a recipe for the specified input, NULL if no recipe found - const Recipe * GetRecipeFrom(const cItem & a_Ingredient) const; + /** Returns a recipe for the specified input, NULL if no recipe found */ + const cRecipe * GetRecipeFrom(const cItem & a_Ingredient) const; - /// Returns the amount of time that the specified fuel burns, in ticks + /** Returns the amount of time that the specified fuel burns, in ticks */ int GetBurnTime(const cItem & a_Fuel) const; private: @@ -49,27 +49,8 @@ private: Logs a warning to the console on input error. */ void AddRecipeFromLine(const AString & a_Line, int a_LineNum); - /** Calls LOGWARN with the line, position, and error */ - static void PrintParseError(unsigned int a_Line, size_t a_Position, const AString & a_CharactersMissing); - - /** Reads a number from a string given, starting at a given position and ending at a delimiter given - Updates beginning position to the delimiter found + 1, and updates the value to the one read - If it encounters a substring that is not fully numeric, it will call SetParseError() and return false; the caller should abort processing - Otherwise, the function will return true - */ - static bool ReadMandatoryNumber(AString::size_type & a_Begin, const AString & a_Delimiter, const AString & a_Text, unsigned int a_Line, int & a_Value, bool a_IsLastValue = false); - - /** Reads two numbers from a string given, starting at a given position and ending at the first delimiter given, then again (with an updated position) until the second delimiter given - Updates beginning position to the second delimiter found + 1, and updates the values to the ones read - If it encounters a substring that is not fully numeric whilst reading the second value, it will call SetParseError() and return false; the caller should abort processing - If this happens whilst reading the first value, it will call ReadMandatoryNumber() with the appropriate position, as this may legitimately occur with the optional value and AString::find_first_of finding the incorrect delimiter. It will return the result of ReadMandatoryNumber() - True will be returned definitively for an optional value that is valid - */ - static bool ReadOptionalNumbers(AString::size_type & a_Begin, const AString & a_DelimiterOne, const AString & a_DelimiterTwo, const AString & a_Text, unsigned int a_Line, int & a_ValueOne, int & a_ValueTwo, bool a_IsLastValue = false); - - /** Uses std::all_of to determine if a string contains only digits */ - static bool DoesStringContainOnlyNumbers(const AString & a_String); - + /** Parses an item string in the format "[^][,]", returns true if successful. */ + bool ParseItem(const AString & a_String, cItem & a_Item); struct sFurnaceRecipeState; sFurnaceRecipeState * m_pState; -- cgit v1.2.3 From 66417f7a48c36b63a73d8fddc147ef5b90a91e09 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 31 Aug 2014 19:29:54 +0200 Subject: Fixed wrong doxy-comment. --- src/FurnaceRecipe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/FurnaceRecipe.h') diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h index de3ee56a0..e3840d0d9 100644 --- a/src/FurnaceRecipe.h +++ b/src/FurnaceRecipe.h @@ -49,7 +49,7 @@ private: Logs a warning to the console on input error. */ void AddRecipeFromLine(const AString & a_Line, int a_LineNum); - /** Parses an item string in the format "[^][,]", returns true if successful. */ + /** Parses an item string in the format "[:][,]", returns true if successful. */ bool ParseItem(const AString & a_String, cItem & a_Item); struct sFurnaceRecipeState; -- cgit v1.2.3 From 0d392f53ed5ef96886003afd90c6ce37c16dc7d3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 31 Aug 2014 20:53:41 +0200 Subject: Fixed compile warnings. --- src/FurnaceRecipe.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/FurnaceRecipe.h') diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h index e3840d0d9..207480fa9 100644 --- a/src/FurnaceRecipe.h +++ b/src/FurnaceRecipe.h @@ -43,11 +43,11 @@ private: /** Parses the fuel contained in the line, adds it to m_pState's fuels. Logs a warning to the console on input error. */ - void AddFuelFromLine(const AString & a_Line, int a_LineNum); + void AddFuelFromLine(const AString & a_Line, unsigned int a_LineNum); /** 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, int a_LineNum); + void AddRecipeFromLine(const AString & a_Line, unsigned int a_LineNum); /** Parses an item string in the format "[:][,]", returns true if successful. */ bool ParseItem(const AString & a_String, cItem & a_Item); -- cgit v1.2.3 From ea39c1d21cab2533504172f735e46b28664c8327 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 1 Sep 2014 13:43:10 +0200 Subject: Avoid false positive in style check. --- src/FurnaceRecipe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/FurnaceRecipe.h') diff --git a/src/FurnaceRecipe.h b/src/FurnaceRecipe.h index 207480fa9..6a1650695 100644 --- a/src/FurnaceRecipe.h +++ b/src/FurnaceRecipe.h @@ -49,7 +49,7 @@ private: Logs a warning to the console on input error. */ void AddRecipeFromLine(const AString & a_Line, unsigned int a_LineNum); - /** Parses an item string in the format "[:][,]", returns true if successful. */ + /** Parses an item string in the format "[: ][, ]", returns true if successful. */ bool ParseItem(const AString & a_String, cItem & a_Item); struct sFurnaceRecipeState; -- cgit v1.2.3