diff --git a/src/common/Common.h b/src/common/Common.h index aa31cb59..10af4d62 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -49,13 +49,13 @@ namespace Sapphire::Common uint8_t plot; }; - enum InventoryOperation : uint8_t + enum InventoryOperation : uint16_t { - Discard = 0x07, - Move = 0x08, - Swap = 0x09, - Merge = 0x0C, - Split = 0x0A + Discard = 0x2EB, + Move = 0x2EC, + Swap = 0x2ED, + Merge = 0x2F0, + Split = 0x2EE }; enum ClientLanguage : uint8_t diff --git a/src/common/Network/PacketDef/Zone/ClientZoneDef.h b/src/common/Network/PacketDef/Zone/ClientZoneDef.h index 9c8d0fc0..5b9739b2 100644 --- a/src/common/Network/PacketDef/Zone/ClientZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ClientZoneDef.h @@ -217,7 +217,7 @@ struct FFXIVIpcInventoryModifyHandler : { /* 0000 */ uint32_t seq; /* 0004 */ Common::InventoryOperation action; - /* 0005 */ uint8_t pad_0005[7]; + /* 0005 */ uint8_t pad_0005[6]; /* 000C */ uint16_t fromContainer; /* 000E */ uint8_t pad_000E[2]; /* 0010 */ uint8_t fromSlot; diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 2530a5e4..25d133b4 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -1295,8 +1295,7 @@ namespace Sapphire::Network::Packets::Server struct FFXIVIpcInventoryTransaction : FFXIVIpcBasePacket< InventoryTransaction > { uint32_t sequence; - uint8_t type; - uint8_t padding; + uint16_t type; uint16_t padding1; uint32_t ownerId; uint32_t storageId; diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index f9a13136..299dd346 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -918,7 +918,7 @@ namespace Sapphire::Entity InvSlotPair getFreeBagSlot(); - Sapphire::ItemPtr addItem( uint32_t catalogId, uint32_t quantity = 1, bool isHq = false, bool slient = false ); + Sapphire::ItemPtr addItem( uint32_t catalogId, uint32_t quantity = 1, bool isHq = false, bool slient = false, bool canMerge = true ); void moveItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot ); diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index fe89ca81..9870660c 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -534,7 +534,7 @@ bool Sapphire::Entity::Player::isObtainable( uint32_t catalogId, uint8_t quantit } -Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_t quantity, bool isHq, bool silent ) +Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_t quantity, bool isHq, bool silent, bool canMerge ) { auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >(); auto pExdData = m_pFw->get< Data::ExdDataGenerated >(); @@ -570,10 +570,13 @@ Sapphire::ItemPtr Sapphire::Entity::Player::addItem( uint32_t catalogId, uint32_ for( uint8_t slot = 0; slot < storage->getMaxSize(); slot++ ) { + if ( !canMerge && foundFreeSlot ) + break; + auto item = storage->getItem( slot ); // add any items that are stackable - if( item && !itemInfo->isEquippable && item->getId() == catalogId ) + if( canMerge && item && !itemInfo->isEquippable && item->getId() == catalogId ) { uint32_t count = item->getStackSize(); uint32_t maxStack = item->getMaxStackSize(); @@ -742,7 +745,7 @@ void Sapphire::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t from // todo: correct invalid move? again, not sure what retail does here return; - auto newItem = addItem( fromItem->getId(), itemCount, fromItem->isHq(), true ); + auto newItem = addItem( fromItem->getId(), itemCount, fromItem->isHq(), true, false ); if( !newItem ) return; @@ -840,7 +843,7 @@ void Sapphire::Entity::Player::discardItem( uint16_t fromInventoryId, uint8_t fr invTransPacket->data().catalogId = fromItem->getId(); invTransPacket->data().stackSize = fromItem->getStackSize(); invTransPacket->data().slotId = fromSlotId; - invTransPacket->data().type = 7; + invTransPacket->data().type = Common::InventoryOperation::Discard; queuePacket( invTransPacket ); auto invTransFinPacket = makeZonePacket< FFXIVIpcInventoryTransactionFinish >( getId() );