diff options
author | bibo38 <bibo38@github.com> | 2020-10-09 17:41:44 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-10-20 12:45:58 +0200 |
commit | c221aa3653c00cd2f942294690cbd21dea0daa85 (patch) | |
tree | 637c09ed878a789ceaf1395346d0d6f6f5cdb2c5 /src/BlockEntities/BrewingstandEntity.cpp | |
parent | cBlockInfo: further cleanup (#5001) (diff) | |
download | cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.gz cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.bz2 cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.lz cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.xz cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.tar.zst cuberite-c221aa3653c00cd2f942294690cbd21dea0daa85.zip |
Diffstat (limited to 'src/BlockEntities/BrewingstandEntity.cpp')
-rw-r--r-- | src/BlockEntities/BrewingstandEntity.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/BlockEntities/BrewingstandEntity.cpp b/src/BlockEntities/BrewingstandEntity.cpp index 9c43f257f..1c659a3c3 100644 --- a/src/BlockEntities/BrewingstandEntity.cpp +++ b/src/BlockEntities/BrewingstandEntity.cpp @@ -54,14 +54,8 @@ void cBrewingstandEntity::CopyFrom(const cBlockEntity & a_Src) Super::CopyFrom(a_Src); auto & src = static_cast<const cBrewingstandEntity &>(a_Src); m_IsBrewing = src.m_IsBrewing; - for (size_t i = 0; i < ARRAYCOUNT(m_CurrentBrewingRecipes); ++i) - { - m_CurrentBrewingRecipes[i] = src.m_CurrentBrewingRecipes[i]; - } - for (size_t i = 0; i < ARRAYCOUNT(m_Results); ++i) - { - m_Results[i] = src.m_Results[i]; - } + m_CurrentBrewingRecipes = src.m_CurrentBrewingRecipes; + m_Results = src.m_Results; m_TimeBrewed = src.m_TimeBrewed; m_RemainingFuel = src.m_RemainingFuel; } @@ -130,12 +124,12 @@ bool cBrewingstandEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) const cBrewingRecipes::cRecipe * Recipe = nullptr; for (int i = 0; i < 3; i++) { - if (m_Contents.GetSlot(i).IsEmpty() || (m_CurrentBrewingRecipes[i] == nullptr)) + if (m_Contents.GetSlot(i).IsEmpty() || (m_CurrentBrewingRecipes[static_cast<size_t>(i)] == nullptr)) { continue; } - Recipe = m_CurrentBrewingRecipes[i]; + Recipe = m_CurrentBrewingRecipes[static_cast<size_t>(i)]; m_Contents.SetSlot(i, Recipe->Output.CopyOne()); } @@ -254,14 +248,14 @@ void cBrewingstandEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) { if (GetSlot(i).IsEmpty()) { - m_CurrentBrewingRecipes[i] = nullptr; - m_Results[i].Clear(); + m_CurrentBrewingRecipes[static_cast<size_t>(i)] = nullptr; + m_Results[static_cast<size_t>(i)].Clear(); continue; } - if (m_CurrentBrewingRecipes[i] != nullptr) + if (m_CurrentBrewingRecipes[static_cast<size_t>(i)] != nullptr) { - Recipe = m_CurrentBrewingRecipes[i]; + Recipe = m_CurrentBrewingRecipes[static_cast<size_t>(i)]; if (Recipe->Ingredient.IsEqual(GetSlot(bsIngredient)) && Recipe->Input.IsEqual(GetSlot(i))) { Stop = false; @@ -273,8 +267,8 @@ void cBrewingstandEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) if (Recipe != nullptr) { // Found a brewing recipe for the items - m_CurrentBrewingRecipes[i] = Recipe; - m_Results[i] = Recipe->Output.CopyOne(); + m_CurrentBrewingRecipes[static_cast<size_t>(i)] = Recipe; + m_Results[static_cast<size_t>(i)] = Recipe->Output.CopyOne(); Stop = false; } } @@ -348,8 +342,8 @@ void cBrewingstandEntity::LoadRecipes(void) Recipe = BR->GetRecipeFrom(GetSlot(i), GetSlot(bsIngredient)); if (Recipe != nullptr) { - m_CurrentBrewingRecipes[i] = Recipe; - m_Results[i] = Recipe->Output.CopyOne(); + m_CurrentBrewingRecipes[static_cast<size_t>(i)] = Recipe; + m_Results[static_cast<size_t>(i)] = Recipe->Output.CopyOne(); } } } |