9 for (
const auto & content: contents)
26 if (!f.
Open(
"Protocol/" + a_ProtocolVersion +
"/base.recipes.txt",
cFile::fmRead))
28 LOGWARNING(
"Cannot open file \"Protocol/%s/base.recipes.txt\", no recipe book recipes will be available!", a_ProtocolVersion);
34 LOGWARNING(
"Cannot read file \"Protocol/%s/base.recipes.txt\", no recipe book recipes will be available!", a_ProtocolVersion);
45 for (AStringVector::const_iterator itr = Split.begin(); itr != Split.end(); ++itr, ++LineNum)
54 AddRecipeLine(a_ProtocolVersion, LineNum, Recipe, RecipeNameMap);
75 if (Sides.size() != 2)
77 LOGINFO(
"Recipe incompletely configured %s", a_RecipeLine);
80 StringToInteger<UInt32>(Sides[0], Id);
82 auto RecipeIndex = a_RecipeNameMap.find(Sides[1]);
83 if (RecipeIndex == a_RecipeNameMap.end())
101 for (
const auto & item: ProtocolMap->second)
103 if (item.second == a_RecipeId)
122 auto Element = ProtocolMap->second.find(a_ProtocolRecipeId);
123 if (Element != ProtocolMap->second.end())
125 return Element->second;
void LOGWARNING(std::string_view a_Format, const Args &... args)
void LOG(std::string_view a_Format, const Args &... args)
void LOGINFO(std::string_view a_Format, const Args &... args)
AString TrimString(const AString &str)
Trims whitespace at both ends of the string.
AStringVector StringSplit(const AString &str, const AString &delim)
Split the string at any of the listed delimiters.
std::vector< AString > AStringVector
const std::map< AString, UInt32 > & GetRecipeNameMap()
Gets a map of all recipes with name and recipe id.
static bool IsFolder(const AString &a_Path)
Returns true if the specified path is a folder.
static char PathSeparator()
bool Open(const AString &iFileName, eMode iMode)
static AStringVector GetFolderContents(const AString &a_Folder)
Returns the list of all items in the specified folder (files, folders, nix pipes, whatever's there).
int ReadRestOfFile(AString &a_Contents)
Reads the file from current position till EOF into an AString; returns the number of bytes read or -1...
std::optional< UInt32 > GetProtocolRecipeId(UInt32 a_RecipeId, UInt32 a_ProtocolVersion)
Translates the cuberite RecipeId to the protocol specific RecipeId.
std::optional< UInt32 > GetCuberiteRecipeId(UInt32 a_ProtocolRecipeId, UInt32 a_ProtocolVersion)
Translates the protocol specific RecipeId to the cuberite RecipeId.
std::map< AString, std::map< UInt32, UInt32 > > m_ProtocolVersionMap
A mapping for each protocol from the protocol specific RecipeId and the cuberite RecipeId.
void AddRecipeLine(const AString &a_ProtocolVersion, int a_LineNum, const AString &a_RecipeLine, const std::map< AString, UInt32 > &a_RecipeNameMap)
Handles a single line of the protocol specific mapping file.
void loadRecipes(const AString &a_ProtocolVersion)
Load Recipes from the protocol specific mapping file.
cCraftingRecipes * GetCraftingRecipes(void)