diff options
author | Tobias Wilken <TooAngel@TooAngel.de> | 2020-07-14 18:56:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 18:56:42 +0200 |
commit | 36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9 (patch) | |
tree | 04c224231a800002692a296131af4988dd465845 /src/Protocol/RecipeMapper.h | |
parent | Custom command depend is automatic (diff) | |
download | cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.gz cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.bz2 cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.lz cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.xz cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.tar.zst cuberite-36eab1b3237dbeeaaf5b48808bf0d47eb4bd32e9.zip |
Diffstat (limited to 'src/Protocol/RecipeMapper.h')
-rw-r--r-- | src/Protocol/RecipeMapper.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Protocol/RecipeMapper.h b/src/Protocol/RecipeMapper.h new file mode 100644 index 000000000..1cac62f92 --- /dev/null +++ b/src/Protocol/RecipeMapper.h @@ -0,0 +1,35 @@ +#pragma once + +#include "../CraftingRecipes.h" +#include <optional> + +/** +The RecipeMapper handles the translation of crafting recipes into protocol +specific recipe Ids. +The crafting recipes are identified by the RecipeId. +The actual configuration is stored in the protocol specific configuration +directory, e.g. `Server/Protocol/1.12.2/base.recipes.txt` +*/ +class cRecipeMapper +{ +public: + cRecipeMapper(void); + ~cRecipeMapper(); + + /** Translates the cuberite RecipeId to the protocol specific RecipeId */ + std::optional<UInt32> GetProtocolRecipeId(UInt32 a_RecipeId, UInt32 a_ProtocolVersion); + + /** Translates the protocol specific RecipeId to the cuberite RecipeId */ + std::optional<UInt32> GetCuberiteRecipeId(UInt32 a_ProtocolRecipeId, UInt32 a_ProtocolVersion); + +private: + /** A mapping for each protocol from the protocol specific RecipeId and the cuberite RecipeId */ + std::map<AString, std::map<UInt32, UInt32>> m_ProtocolVersionMap; + + /** Load Recipes from the protocol specific mapping file */ + void loadRecipes(const AString & a_ProtocolVersion); + + /** Handles a single line of the protocol specific mapping file */ + void AddRecipeLine(const AString & a_ProtocolVersion, int a_LineNum, const AString & a_RecipeLine, const std::map<AString, UInt32> & a_RecipeNameMap); + +}; |