1
0

Bug fixes

This commit is contained in:
daniel0916 2014-04-14 11:48:12 +02:00
parent fce9ea65c3
commit 856e900bf8
4 changed files with 21 additions and 26 deletions

View File

@ -2689,14 +2689,14 @@ void cClientHandle::SocketClosed(void)
void cClientHandle::HandleEnchantItem(Byte & WindowID, Byte & Enchantment)
{
cItem Item = m_Player->GetDraggingItem();
cEnchantingWindow * Window = (cEnchantingWindow*)m_Player->GetWindow();
cItem Item = *Window->m_SlotArea->GetSlot(0, *m_Player);
if (!cItem::IsEnchantable(Item.m_ItemType))
{
return;
}
cEnchantingWindow * Window = (cEnchantingWindow*)m_Player->GetWindow();
int BaseEnchantmentLevel = Window->GetPropertyValue(Enchantment);
// Step 1 from Enchanting

View File

@ -1918,10 +1918,7 @@ void cProtocol172::HandlePacketEnchantItem(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, WindowID);
HANDLE_READ(a_ByteBuffer, ReadByte, Byte, Enchantment);
LOGWARN("Protocol 1.7: Enchantment Packet received!");
m_Client->HandleEnchantItem(WindowID, Enchantment);
}

View File

@ -608,8 +608,21 @@ cSlotAreaTemporary(a_NumSlots, a_ParentWindow)
void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
{
// Toss the item in the enchanting slot
TossItems(a_Player, 0, 1);
// Player not found - that is acceptable
}
void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem)
{
super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
// Check if Slot is in the Enchantment Table
if (a_SlotNum == 0)
{
@ -621,20 +634,7 @@ void cSlotAreaEnchanting::Clicked(cPlayer & a_Player, int a_SlotNum, eClickActio
{
ClickedResult(a_Player);
}
return;
}
super::Clicked(a_Player, a_SlotNum, a_ClickAction, a_ClickedItem);
}
void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
{
// Toss the item in the enchanting slot
TossItems(a_Player, 0, 0);
// Player not found - that is acceptable
}
@ -643,13 +643,15 @@ void cSlotAreaEnchanting::OnPlayerRemoved(cPlayer & a_Player)
void cSlotAreaEnchanting::ClickedResult(cPlayer & a_Player)
{
if (a_Player.GetDraggingItem().IsEmpty())
cItem Item = *GetSlot(0, a_Player);
if (Item.IsEmpty())
{
m_ParentWindow.SetProperty(0, 0, a_Player);
m_ParentWindow.SetProperty(1, 0, a_Player);
m_ParentWindow.SetProperty(2, 0, a_Player);
}
else if (cItem::IsEnchantable(a_Player.GetDraggingItem().m_ItemType))
else if (cItem::IsEnchantable(Item.m_ItemType))
{
int PosX = 0;
int PosY = 0;

View File

@ -258,21 +258,17 @@ class cSlotAreaEnchanting :
typedef cSlotAreaTemporary super;
public:
/// a_GridSize is allowed to be only 2 or 3
cSlotAreaEnchanting(int a_NumSlots, cWindow & a_ParentWindow);
// cSlotAreaTemporary overrides:
virtual void Clicked(cPlayer & a_Player, int a_SlotNum, eClickAction a_ClickAction, const cItem & a_ClickedItem) override;
virtual void OnPlayerRemoved(cPlayer & a_Player) override;
// Distributing items into this area is completely disabled
virtual void DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots) override {}
protected:
/// Handles a click in the result slot. Crafts using the current recipe, if possible
/// Handles a click in the item slot.
void ClickedResult(cPlayer & a_Player);
/// Handles a shift-click in the result slot. Crafts using the current recipe until it changes or no more space for result.
/// Handles a shift-click in the item slot.
void ShiftClickedResult(cPlayer & a_Player);
};