diff options
author | Alex Sweet <sweet.giorni@gmail.com> | 2018-04-11 08:46:11 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2018-04-11 08:46:11 +0200 |
commit | a0896c63d7a02d1b90572d591a16a79b4274feac (patch) | |
tree | e3b58fdc79e6891181e057824c8a39769da4ee72 /src/FurnaceRecipe.cpp | |
parent | Fix cUUID::Variant (#4213) (diff) | |
download | cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.gz cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.bz2 cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.lz cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.xz cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.tar.zst cuberite-a0896c63d7a02d1b90572d591a16a79b4274feac.zip |
Diffstat (limited to '')
-rw-r--r-- | src/FurnaceRecipe.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index a2199cd33..a4647b7a0 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -161,6 +161,7 @@ void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, unsigned int a_Li Line.erase(std::remove_if(Line.begin(), Line.end(), isspace), Line.end()); int CookTime = 200; + float Reward = 0; std::unique_ptr<cItem> InputItem = cpp14::make_unique<cItem>(); std::unique_ptr<cItem> OutputItem = cpp14::make_unique<cItem>(); @@ -189,18 +190,27 @@ void cFurnaceRecipe::AddRecipeFromLine(const AString & a_Line, unsigned int a_Li return; } } - - if (!ParseItem(Sides[1], *OutputItem)) + const AStringVector & OutputSplit = StringSplit(Sides[1], "$"); + if (!ParseItem(OutputSplit[0], *OutputItem)) { - LOGWARNING("furnace.txt: line %d: Cannot parse output item \"%s\".", a_LineNum, Sides[1].c_str()); + LOGWARNING("furnace.txt: line %d: Cannot parse output item \"%s\".", a_LineNum, OutputSplit[0].c_str()); LOGINFO("Offending line: \"%s\"", a_Line.c_str()); return; } - + if (OutputSplit.size() > 1) + { + if (!StringToFloat(OutputSplit[1], Reward)) + { + LOGWARNING("furnace.txt: line %d: Cannot parse reward \"%s\".", a_LineNum, OutputSplit[1].c_str()); + LOGINFO("Offending line: \"%s\"", a_Line.c_str()); + return; + } + } cRecipe Recipe; Recipe.In = InputItem.release(); Recipe.Out = OutputItem.release(); Recipe.CookTime = CookTime; + Recipe.Reward = Reward; m_pState->Recipes.push_back(Recipe); } |