From c747b4911ed4b1833d7f400d62d1835aba704278 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 22 Mar 2023 10:20:16 +0000 Subject: Removed C style arrays from the BlockEntity folder (#5005) * Removed C style arrays from the BlockEntity folder * Update for loops with size_t where there are no item grids involved * Fixed some casts in BrewingstandEntity.cpp --------- Co-authored-by: bibo38 Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com> --- src/BlockEntities/BrewingstandEntity.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'src/BlockEntities/BrewingstandEntity.cpp') diff --git a/src/BlockEntities/BrewingstandEntity.cpp b/src/BlockEntities/BrewingstandEntity.cpp index ff7b49821..12f8d5a36 100644 --- a/src/BlockEntities/BrewingstandEntity.cpp +++ b/src/BlockEntities/BrewingstandEntity.cpp @@ -29,14 +29,8 @@ void cBrewingstandEntity::CopyFrom(const cBlockEntity & a_Src) Super::CopyFrom(a_Src); auto & src = static_cast(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; } @@ -117,15 +111,15 @@ bool cBrewingstandEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) // Loop over all bottle slots and update available bottles const cBrewingRecipes::cRecipe * Recipe = nullptr; - for (int i = 0; i < 3; i++) + for (std::size_t i = 0; i < 3; i++) { - if (m_Contents.GetSlot(i).IsEmpty() || (m_CurrentBrewingRecipes[i] == nullptr)) + if (m_Contents.GetSlot(static_cast(i)).IsEmpty() || (m_CurrentBrewingRecipes[i] == nullptr)) { continue; } Recipe = m_CurrentBrewingRecipes[i]; - m_Contents.SetSlot(i, Recipe->Output.CopyOne()); + m_Contents.SetSlot(static_cast(i), Recipe->Output.CopyOne()); } // Brewing process completed @@ -234,9 +228,9 @@ void cBrewingstandEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) cBrewingRecipes * BR = cRoot::Get()->GetBrewingRecipes(); const cBrewingRecipes::cRecipe * Recipe = nullptr; bool Stop = true; - for (int i = 0; i < 3; i++) + for (std::size_t i = 0; i < 3; i++) { - if (GetSlot(i).IsEmpty()) + if (GetSlot(static_cast(i)).IsEmpty()) { m_CurrentBrewingRecipes[i] = nullptr; m_Results[i].Clear(); @@ -246,14 +240,14 @@ void cBrewingstandEntity::OnSlotChanged(cItemGrid * a_ItemGrid, int a_SlotNum) if (m_CurrentBrewingRecipes[i] != nullptr) { Recipe = m_CurrentBrewingRecipes[i]; - if (Recipe->Ingredient.IsEqual(GetSlot(bsIngredient)) && Recipe->Input.IsEqual(GetSlot(i))) + if (Recipe->Ingredient.IsEqual(GetSlot(bsIngredient)) && Recipe->Input.IsEqual(GetSlot(static_cast(i)))) { Stop = false; continue; } } - Recipe = BR->GetRecipeFrom(m_Contents.GetSlot(i), m_Contents.GetSlot(bsIngredient)); + Recipe = BR->GetRecipeFrom(m_Contents.GetSlot(static_cast(i)), m_Contents.GetSlot(bsIngredient)); if (Recipe != nullptr) { // Found a brewing recipe for the items @@ -323,13 +317,13 @@ void cBrewingstandEntity::LoadRecipes(void) cBrewingRecipes * BR = cRoot::Get()->GetBrewingRecipes(); const cBrewingRecipes::cRecipe * Recipe = nullptr; - for (int i = 0; i < 3; i++) + for (std::size_t i = 0; i < 3; i++) { - if (GetSlot(i).IsEmpty()) + if (GetSlot(static_cast(i)).IsEmpty()) { continue; } - Recipe = BR->GetRecipeFrom(GetSlot(i), GetSlot(bsIngredient)); + Recipe = BR->GetRecipeFrom(GetSlot(static_cast(i)), GetSlot(bsIngredient)); if (Recipe != nullptr) { m_CurrentBrewingRecipes[i] = Recipe; -- cgit v1.2.3