From 134e49cc8e442e582608411832363e15f68ea6eb Mon Sep 17 00:00:00 2001 From: JacobF Date: Thu, 25 Aug 2011 19:27:50 -0400 Subject: Merged 2 branches because they relied on each other. This one contains these changes from main c55: * Adds a function to check if there is room for a specific item * Using that, you can now pick up rats if you have a full inventory and a not full rat stack * Furnace would cook only 1 item if that item used the last available result slot, now it will continue * Furnace will say it's overloaded * Furnace won't wait until the next step to start on the next item - This caused small fuels to cook slower than meant to - Also caused furnaces to say they were out of fuel after finishing the last fuel item --- src/inventory.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/inventory.cpp') diff --git a/src/inventory.cpp b/src/inventory.cpp index 1ee63819d..62aedb536 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -549,7 +549,7 @@ InventoryItem * InventoryList::addItem(u32 i, InventoryItem *newitem) } } -bool InventoryList::itemFits(u32 i, InventoryItem *newitem) +bool InventoryList::itemFits(const u32 i, const InventoryItem *newitem) { // If it is an empty position, it's an easy job. const InventoryItem *to_item = getItem(i); @@ -558,11 +558,11 @@ bool InventoryList::itemFits(u32 i, InventoryItem *newitem) return true; } - // If not addable, return the item + // If not addable, fail if(newitem->addableTo(to_item) == false) return false; - // If the item fits fully in the slot, add counter and delete it + // If the item fits fully in the slot, pass if(newitem->getCount() <= to_item->freeSpace()) { return true; @@ -571,6 +571,24 @@ bool InventoryList::itemFits(u32 i, InventoryItem *newitem) return false; } +bool InventoryList::roomForItem(const InventoryItem *item) +{ + for(u32 i=0; icreateCookResult(); + if(!cook) + return false; + bool room = roomForItem(cook); + delete cook; + return room; +} + InventoryItem * InventoryList::takeItem(u32 i, u32 count) { if(count == 0) -- cgit v1.2.3