Players can't set items in the result slot, when they shift a item.
This commit is contained in:
parent
a18b6c2311
commit
12f3c0fcdf
|
@ -1484,6 +1484,44 @@ void cSlotAreaFurnace::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cSlotAreaFurnace::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
const cItem * Slot = GetSlot(i, a_Player);
|
||||||
|
if (!Slot->IsEqual(a_ItemStack) && (!Slot->IsEmpty() || a_KeepEmptySlots))
|
||||||
|
{
|
||||||
|
// Different items
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
|
||||||
|
if (NumFit <= 0)
|
||||||
|
{
|
||||||
|
// Full stack already
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (NumFit > a_ItemStack.m_ItemCount)
|
||||||
|
{
|
||||||
|
NumFit = a_ItemStack.m_ItemCount;
|
||||||
|
}
|
||||||
|
if (a_ShouldApply)
|
||||||
|
{
|
||||||
|
cItem NewSlot(a_ItemStack);
|
||||||
|
NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit;
|
||||||
|
SetSlot(i, a_Player, NewSlot);
|
||||||
|
}
|
||||||
|
a_ItemStack.m_ItemCount -= NumFit;
|
||||||
|
if (a_ItemStack.IsEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} // for i - Slots
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
|
const cItem * cSlotAreaFurnace::GetSlot(int a_SlotNum, cPlayer & a_Player) const
|
||||||
{
|
{
|
||||||
UNUSED(a_Player);
|
UNUSED(a_Player);
|
||||||
|
|
|
@ -392,6 +392,7 @@ public:
|
||||||
virtual ~cSlotAreaFurnace();
|
virtual ~cSlotAreaFurnace();
|
||||||
|
|
||||||
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
|
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
|
||||||
|
virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override;
|
||||||
virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
|
virtual const cItem * GetSlot(int a_SlotNum, cPlayer & a_Player) const override;
|
||||||
virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
|
virtual void SetSlot(int a_SlotNum, cPlayer & a_Player, const cItem & a_Item) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user