From 2691e8daed826e944ca38f4787c77273edbf9404 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 18 Aug 2012 09:56:28 +0000 Subject: Packet refactoring, phase two, partial. Rewritten a few packet handling functions not to use cPacket-descendant objects. This breaks plugin API! Plugins need to modify their hook functions to match those used in the Core plugin git-svn-id: http://mc-server.googlecode.com/svn/trunk@750 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cCreativeInventory.cpp | 45 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'source/cCreativeInventory.cpp') diff --git a/source/cCreativeInventory.cpp b/source/cCreativeInventory.cpp index 77b9107b7..f1a1ae89c 100644 --- a/source/cCreativeInventory.cpp +++ b/source/cCreativeInventory.cpp @@ -14,37 +14,50 @@ #include "packets/cPacket_WholeInventory.h" #include "packets/cPacket_InventorySlot.h" -cCreativeInventory::~cCreativeInventory() -{ -} -cCreativeInventory::cCreativeInventory(cPlayer* a_Owner) + + + +cCreativeInventory::cCreativeInventory(cPlayer * a_Owner) : cInventory(a_Owner) { } -void cCreativeInventory::Clicked( cPacket* a_ClickPacket ) + + + + +cCreativeInventory::~cCreativeInventory() { - cPacket_CreativeInventoryAction* Packet = reinterpret_cast(a_ClickPacket); - short Slot = Packet->m_Slot; - if (Slot == -1) +} + + + + + +void cCreativeInventory::Clicked( + short a_SlotNum, bool a_IsRightClick, bool a_IsShiftPressed, + const cItem & a_HeldItem +) +{ + if (a_SlotNum == -1) { // object thrown out - m_Owner->TossItem(false, Packet->m_Quantity, Packet->m_ItemID, Packet->m_Damage); + m_Owner->TossItem(false, a_HeldItem.m_ItemCount, a_HeldItem.m_ItemType, a_HeldItem.m_ItemDamage); return; } - if ((Slot < c_HotOffset) || (Slot >= c_NumSlots)) + if ((a_SlotNum < c_HotOffset) || (a_SlotNum >= c_NumSlots)) { - LOG("%s: Invalid slot (%d) in CreativeInventoryAction packet. Ignoring...", m_Owner->GetName().c_str(), Slot); + LOG("%s: Invalid slot (%d) in cCreativeInventory::Clicked(). Ignoring...", m_Owner->GetName().c_str(), a_SlotNum); return; } - cItem * SlotItem = &(this->m_Slots[Slot]); - - SlotItem->m_ItemID = (ENUM_ITEM_ID) Packet->m_ItemID; - SlotItem->m_ItemHealth = Packet->m_Damage; - SlotItem->m_ItemCount = Packet->m_Quantity; + m_Slots[a_SlotNum] = a_HeldItem; } + + + + -- cgit v1.2.3