mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
efd8dabd91
commit
134e49cc8e
4 changed files with 55 additions and 13 deletions
|
@ -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; i<m_items.size(); i++)
|
||||
if(itemFits(i, item))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InventoryList::roomForCookedItem(const InventoryItem *item)
|
||||
{
|
||||
const InventoryItem *cook = item->createCookResult();
|
||||
if(!cook)
|
||||
return false;
|
||||
bool room = roomForItem(cook);
|
||||
delete cook;
|
||||
return room;
|
||||
}
|
||||
|
||||
InventoryItem * InventoryList::takeItem(u32 i, u32 count)
|
||||
{
|
||||
if(count == 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue