From 013da806ec20b62a742aded9a9d2b8131193f30d Mon Sep 17 00:00:00 2001 From: jfhumann Date: Fri, 18 Apr 2014 21:09:44 +0200 Subject: Did some static analysis, fixed some bugs and optimized a lot of code --- src/CraftingRecipes.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/CraftingRecipes.cpp') diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 30e7a8733..fb32c9cf3 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -661,14 +661,16 @@ cCraftingRecipes::cRecipe * cCraftingRecipes::MatchRecipe(const cItem * a_Crafti ASSERT(itrS->x + a_OffsetX < a_GridWidth); ASSERT(itrS->y + a_OffsetY < a_GridHeight); int GridID = (itrS->x + a_OffsetX) + a_GridStride * (itrS->y + a_OffsetY); + + const cItem & Item = itrS->m_Item; if ( (itrS->x >= a_GridWidth) || (itrS->y >= a_GridHeight) || - (itrS->m_Item.m_ItemType != a_CraftingGrid[GridID].m_ItemType) || // same item type? - (itrS->m_Item.m_ItemCount > a_CraftingGrid[GridID].m_ItemCount) || // not enough items + (Item.m_ItemType != a_CraftingGrid[GridID].m_ItemType) || // same item type? + (Item.m_ItemCount > a_CraftingGrid[GridID].m_ItemCount) || // not enough items ( - (itrS->m_Item.m_ItemDamage > 0) && // should compare damage values? - (itrS->m_Item.m_ItemDamage != a_CraftingGrid[GridID].m_ItemDamage) + (Item.m_ItemDamage > 0) && // should compare damage values? + (Item.m_ItemDamage != a_CraftingGrid[GridID].m_ItemDamage) ) ) { -- cgit v1.2.3 From 4c7621ed16bfa9f0224eab52f8f7acbb0b61ec14 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 21 Apr 2014 09:21:31 +0200 Subject: Fixed a warning in CraftingRecipes. --- src/CraftingRecipes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/CraftingRecipes.cpp') diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 30e7a8733..c3d6de74d 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -824,7 +824,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(a_CraftingGrid[GridID].m_ItemDamage)); + DyeColours.push_back(cFireworkItem::GetVanillaColourCodeFromDye((NIBBLETYPE)(a_CraftingGrid[GridID].m_ItemDamage & 0x0f))); break; } case E_ITEM_GUNPOWDER: break; -- cgit v1.2.3 From f763242e5c5d8e6469685c4be95d3dc264ed6a67 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 23 Apr 2014 21:06:07 +0100 Subject: Small changes --- src/CraftingRecipes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/CraftingRecipes.cpp') diff --git a/src/CraftingRecipes.cpp b/src/CraftingRecipes.cpp index 30e7a8733..157d634cd 100644 --- a/src/CraftingRecipes.cpp +++ b/src/CraftingRecipes.cpp @@ -800,7 +800,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe break; } case E_ITEM_PAPER: break; - default: LOG("Unexpected item in firework rocket a_Recipe, was the crafting file fireworks section changed?"); break; + default: LOG("Unexpected item in firework rocket recipe, was the crafting file's fireworks section changed?"); break; } } } @@ -835,7 +835,7 @@ void cCraftingRecipes::HandleFireworks(const cItem * a_CraftingGrid, cCraftingRe case E_ITEM_GOLD_NUGGET: a_Recipe->m_Result.m_FireworkItem.m_Type = 2; break; case E_ITEM_FEATHER: a_Recipe->m_Result.m_FireworkItem.m_Type = 4; break; case E_ITEM_HEAD: a_Recipe->m_Result.m_FireworkItem.m_Type = 3; break; - default: LOG("Unexpected item in firework star a_Recipe, was the crafting file fireworks section changed?"); break; // ermahgerd BARD ardmins + default: LOG("Unexpected item in firework star recipe, was the crafting file's fireworks section changed?"); break; // ermahgerd BARD ardmins } } -- cgit v1.2.3