From 0a0dcf59ae0650ebfb70ecf0b89958c23cceba78 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 12 Aug 2018 22:30:18 +1000 Subject: [PATCH] fix item splitting --- .../Network/PacketDef/Zone/ClientZoneDef.h | 6 +++--- .../sapphire_zone/Actor/PlayerInventory.cpp | 18 ++++++++++++------ .../sapphire_zone/Script/NativeScriptApi.h | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ClientZoneDef.h b/src/common/Network/PacketDef/Zone/ClientZoneDef.h index 3b77195f..b7cd1b32 100644 --- a/src/common/Network/PacketDef/Zone/ClientZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ClientZoneDef.h @@ -153,9 +153,7 @@ struct FFXIVIpcInventoryModifyHandler : FFXIVIpcBasePacket< InventoryModifyHandl { /* 0000 */ uint32_t seq; /* 0004 */ Common::InventoryOperation action; - /* 0005 */ char pad_0005[3]; - /* 0008 */ uint16_t splitCount; // todo: check packet handler in game and see if this is sent as a u16 or u32 - /* 000A */ char pad_000A[2]; + /* 0005 */ char pad_0005[7]; /* 000C */ uint16_t fromContainer; /* 000E */ char pad_000E[2]; /* 0010 */ uint8_t fromSlot; @@ -163,6 +161,8 @@ struct FFXIVIpcInventoryModifyHandler : FFXIVIpcBasePacket< InventoryModifyHandl /* 0020 */ uint16_t toContainer; /* 0022 */ char pad_0022[2]; /* 0024 */ uint8_t toSlot; + /* 0025 */ uint8_t pad_0025[3]; + /* 0028 */ uint32_t splitCount; }; } diff --git a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp index e55db651..bce81ff2 100644 --- a/src/servers/sapphire_zone/Actor/PlayerInventory.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerInventory.cpp @@ -533,16 +533,19 @@ int16_t Core::Entity::Player::addItem( uint16_t inventoryId, int8_t slotId, uint " WHERE storageId = " + std::to_string( inventoryId ) + " AND CharacterId = " + std::to_string( getId() ) ); + if( !slient ) + { + auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), + rSlotId, + inventoryId, + *item ); - auto invUpdate = boost::make_shared< UpdateInventorySlotPacket >( getId(), - rSlotId, - inventoryId, - *item ); - queuePacket( invUpdate ); + queuePacket( invUpdate ); - if( !silent ) queuePacket( boost::make_shared< ActorControlPacket143 >( getId(), ItemObtainIcon, catalogId, item->getStackSize() ) ); + } + } @@ -613,6 +616,9 @@ bool Core::Entity::Player::updateContainer( uint16_t storageId, uint8_t slotId, void Core::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot, uint16_t itemCount ) { + if( itemCount == 0 ) + return; + auto fromItem = m_storageMap[fromInventoryId]->getItem( fromSlotId ); if( !fromItem ) return; diff --git a/src/servers/sapphire_zone/Script/NativeScriptApi.h b/src/servers/sapphire_zone/Script/NativeScriptApi.h index cf6393cb..7a300f29 100644 --- a/src/servers/sapphire_zone/Script/NativeScriptApi.h +++ b/src/servers/sapphire_zone/Script/NativeScriptApi.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "Forwards.h" #ifdef _MSC_VER