summaryrefslogtreecommitdiffstats
path: root/src/CraftingRecipes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/CraftingRecipes.cpp')
-rw-r--r--src/CraftingRecipes.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp
index 472044fa3..0bb77d341 100644
--- a/src/CraftingRecipes.cpp
+++ b/src/CraftingRecipes.cpp
@@ -168,7 +168,14 @@ void cCraftingGrid::ConsumeGrid(const cCraftingGrid & a_Grid)
m_Items[ThisIdx].m_ItemCount -= NumWantedItems;
if (m_Items[ThisIdx].m_ItemCount == 0)
{
- m_Items[ThisIdx].Clear();
+ if ((m_Items[ThisIdx].m_ItemType == E_ITEM_MILK) || (m_Items[ThisIdx].m_ItemType == E_ITEM_WATER_BUCKET) || (m_Items[ThisIdx].m_ItemType == E_ITEM_LAVA_BUCKET))
+ {
+ m_Items[ThisIdx] = cItem(E_ITEM_BUCKET, m_Items[ThisIdx].m_ItemCount);
+ }
+ else
+ {
+ m_Items[ThisIdx].Clear();
+ }
}
} // for x, for y
}
@@ -373,12 +380,12 @@ void cCraftingRecipes::AddRecipeLine(int a_LineNum, const AString & a_RecipeLine
AStringVector Sides = StringSplit(RecipeLine, "=");
if (Sides.size() != 2)
{
- LOGWARNING("crafting.txt: line %d: A single '=' was expected, got %d", a_LineNum, (int)Sides.size() - 1);
+ LOGWARNING("crafting.txt: line %d: A single '=' was expected, got " SIZE_T_FMT, a_LineNum, Sides.size() - 1);
LOGINFO("Offending line: \"%s\"", a_RecipeLine.c_str());
return;
}
- std::unique_ptr<cCraftingRecipes::cRecipe> Recipe(new cCraftingRecipes::cRecipe);
+ std::unique_ptr<cCraftingRecipes::cRecipe> Recipe = cpp14::make_unique<cCraftingRecipes::cRecipe>();
// Parse the result:
AStringVector ResultSplit = StringSplit(Sides[0], ",");
@@ -759,7 +766,7 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
} // for y, for x
// The recipe has matched. Create a copy of the recipe and set its coords to match the crafting grid:
- std::unique_ptr<cRecipe> Recipe(new cRecipe);
+ std::unique_ptr<cRecipe> Recipe = cpp14::make_unique<cRecipe>();
Recipe->m_Result = a_Recipe->m_Result;
Recipe->m_Width = a_Recipe->m_Width;
Recipe->m_Height = a_Recipe->m_Height;
@@ -771,9 +778,12 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti
continue;
}
Recipe->m_Ingredients.push_back(*itrS);
+ Recipe->m_Ingredients.back().x += a_OffsetX;
+ Recipe->m_Ingredients.back().y += a_OffsetY;
}
Recipe->m_Ingredients.insert(Recipe->m_Ingredients.end(), MatchedSlots.begin(), MatchedSlots.end());
+ // Handle the fireworks-related effects:
// We use Recipe instead of a_Recipe because we want the wildcard ingredients' slot numbers as well, which was just added previously
HandleFireworks(a_CraftingGrid, Recipe.get(), a_GridStride, a_OffsetX, a_OffsetY);
@@ -833,7 +843,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe
case E_ITEM_DYE:
{
int GridID = (itr->x + a_OffsetX) + a_GridStride * (itr->y + a_OffsetY);
- DyeColours.push_back(cFireworkItem::GetVanillaColourCodeFromDye((NIBBLETYPE)(a_CraftingGrid[GridID].m_ItemDamage & 0x0f)));
+ DyeColours.push_back(cFireworkItem::GetVanillaColourCodeFromDye(static_cast<NIBBLETYPE>(a_CraftingGrid[GridID].m_ItemDamage & 0x0f)));
break;
}
case E_ITEM_GUNPOWDER: break;