From b355bdeccecf727d30e48634df9b5d424db570bc Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 4 Jun 2012 12:08:20 +0000 Subject: Added the new recipe parser, parsing the crafting.txt file. Included are a few recipes. The old parser still works, but will be replaced soon. git-svn-id: http://mc-server.googlecode.com/svn/trunk@549 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cSurvivalInventory.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source/cSurvivalInventory.cpp') diff --git a/source/cSurvivalInventory.cpp b/source/cSurvivalInventory.cpp index 088c4362c..a39cc6b59 100644 --- a/source/cSurvivalInventory.cpp +++ b/source/cSurvivalInventory.cpp @@ -7,6 +7,7 @@ #include "cWindow.h" #include "cItem.h" #include "cRecipeChecker.h" +#include "CraftingRecipes.h" #include "cRoot.h" #include "packets/cPacket_WindowClick.h" @@ -69,16 +70,29 @@ void cSurvivalInventory::Clicked( cPacket* a_ClickPacket ) LOG("No Inventory window! WTF"); } - if( Packet->m_SlotNum >= (short)c_CraftOffset && Packet->m_SlotNum < (short)(c_CraftOffset+c_CraftSlots+1) ) + if ((Packet->m_SlotNum >= (short)c_CraftOffset) && (Packet->m_SlotNum < (short)(c_CraftOffset + c_CraftSlots + 1))) { cItem CookedItem; - if( Packet->m_SlotNum == 0 && !bDontCook ) + if ((Packet->m_SlotNum == 0) && !bDontCook) { - CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2, true ); + // Consume the items from the crafting grid: + CookedItem = cRoot::Get()->GetCraftingRecipes()->Craft(m_Slots + c_CraftOffset + 1, 2, 2); + // Upgrade the crafting result from the new crafting grid contents: + CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(m_Slots + c_CraftOffset + 1, 2, 2); + if (CookedItem.IsEmpty()) + { + // Fallback to the old recipes: + CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2, true ); + } } else { - CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2 ); + CookedItem = cRoot::Get()->GetCraftingRecipes()->Offer(m_Slots + c_CraftOffset + 1, 2, 2); + if (CookedItem.IsEmpty()) + { + // Fallback to the old recipes: + CookedItem = cRoot::Get()->GetRecipeChecker()->CookIngredients( m_Slots+c_CraftOffset+1, 2, 2 ); + } } m_Slots[c_CraftOffset] = CookedItem; LOG("You cooked: %i x %i !!", m_Slots[c_CraftOffset].m_ItemID, m_Slots[c_CraftOffset].m_ItemCount ); -- cgit v1.2.3