Merge pull request #909 from jfhumann/fixes
Bug fixes and optimizations. We need to visit the API functions and check that they return only those values expected. `cWorld::CreateProjectile()` seems affected, too, by the same issue of ToLua returning extra values. In the cleanest form, these functions will need moving to ManualBindings.cpp
This commit is contained in:
@@ -128,10 +128,11 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
|
||||
if (DispChunk->GetBlock(DispX, DispY, DispZ) == E_BLOCK_AIR)
|
||||
{
|
||||
DispChunk->SetBlock(DispX, DispY, DispZ, E_BLOCK_FIRE, 0);
|
||||
m_Contents.SetSlot(a_SlotNum, m_Contents.GetSlot(a_SlotNum).m_ItemType, m_Contents.GetSlot(a_SlotNum).m_ItemCount, m_Contents.GetSlot(a_SlotNum).m_ItemDamage + 1);
|
||||
// If the durability has run out destroy the item.
|
||||
if (m_Contents.GetSlot(a_SlotNum).m_ItemDamage > 64)
|
||||
{
|
||||
|
||||
bool ItemBroke = m_Contents.DamageItem(a_SlotNum, 1);
|
||||
|
||||
if (ItemBroke)
|
||||
{
|
||||
m_Contents.ChangeSlotCount(a_SlotNum, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,19 +413,20 @@ bool cFurnaceEntity::CanCookInputToOutput(void) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Contents.GetSlot(fsOutput).IsEmpty())
|
||||
const cItem & Slot = m_Contents.GetSlot(fsOutput);
|
||||
if (Slot.IsEmpty())
|
||||
{
|
||||
// The output is empty, can cook
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!m_Contents.GetSlot(fsOutput).IsEqual(*m_CurrentRecipe->Out))
|
||||
if (!Slot.IsEqual(*m_CurrentRecipe->Out))
|
||||
{
|
||||
// The output slot is blocked with something that cannot be stacked with the recipe's output
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_Contents.GetSlot(fsOutput).IsFullStack())
|
||||
if (Slot.IsFullStack())
|
||||
{
|
||||
// Cannot add any more items to the output slot
|
||||
return false;
|
||||
|
||||
@@ -234,24 +234,27 @@ bool cHopperEntity::MovePickupsIn(cChunk & a_Chunk, Int64 a_CurrentTick)
|
||||
|
||||
bool TrySuckPickupIn(cPickup * a_Pickup)
|
||||
{
|
||||
cItem & Item = a_Pickup->GetItem();
|
||||
|
||||
for (int i = 0; i < ContentsWidth * ContentsHeight; i++)
|
||||
{
|
||||
if (m_Contents.IsSlotEmpty(i))
|
||||
{
|
||||
m_bFoundPickupsAbove = true;
|
||||
m_Contents.SetSlot(i, a_Pickup->GetItem());
|
||||
m_Contents.SetSlot(i, Item);
|
||||
a_Pickup->Destroy(); // Kill pickup
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (m_Contents.GetSlot(i).IsEqual(a_Pickup->GetItem()) && !m_Contents.GetSlot(i).IsFullStack())
|
||||
else if (m_Contents.GetSlot(i).IsEqual(Item) && !m_Contents.GetSlot(i).IsFullStack())
|
||||
{
|
||||
m_bFoundPickupsAbove = true;
|
||||
|
||||
int PreviousCount = m_Contents.GetSlot(i).m_ItemCount;
|
||||
a_Pickup->GetItem().m_ItemCount -= m_Contents.ChangeSlotCount(i, a_Pickup->GetItem().m_ItemCount) - PreviousCount; // Set count to however many items were added
|
||||
|
||||
if (a_Pickup->GetItem().IsEmpty())
|
||||
Item.m_ItemCount -= m_Contents.ChangeSlotCount(i, Item.m_ItemCount) - PreviousCount; // Set count to however many items were added
|
||||
|
||||
if (Item.IsEmpty())
|
||||
{
|
||||
a_Pickup->Destroy(); // Kill pickup if all items were added
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user