diff --git a/src/servers/sapphire_zone/Inventory/Inventory.cpp b/src/servers/sapphire_zone/Inventory/Inventory.cpp index 508b7a62..909065f6 100644 --- a/src/servers/sapphire_zone/Inventory/Inventory.cpp +++ b/src/servers/sapphire_zone/Inventory/Inventory.cpp @@ -404,6 +404,12 @@ void Core::Inventory::updateItemDb( Core::ItemPtr pItem ) const " WHERE itemId = " + std::to_string( pItem->getUId() ) ); } +void Core::Inventory::deleteItemDb( Core::ItemPtr item ) const +{ + auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >(); + pDb->execute( "UPDATE charaglobalitem SET IS_DELETE = 1 WHERE itemId = " + std::to_string( item->getUId() ) ); +} + bool Core::Inventory::removeCurrency( CurrencyType type, uint32_t amount ) { @@ -649,19 +655,20 @@ void Core::Inventory::mergeItem( uint16_t fromInventoryId, uint8_t fromSlotId, u if( stackOverflow == 0 ) { m_inventoryMap[fromInventoryId]->removeItem( fromSlotId ); - fromItem = nullptr; + deleteItemDb( fromItem ); } else + { fromItem->setStackSize( stackOverflow ); + updateItemDb( fromItem ); + } + toItem->setStackSize( stackSize ); + updateItemDb( toItem ); updateContainer( fromInventoryId, fromSlotId, fromItem ); updateContainer( toInventoryId, toSlot, toItem ); - - updateItemDb( toItem ); - if( fromItem ) - updateItemDb( fromItem ); } void Core::Inventory::swapItem( uint16_t fromInventoryId, uint8_t fromSlotId, uint16_t toInventoryId, uint8_t toSlot ) @@ -697,6 +704,8 @@ void Core::Inventory::discardItem( uint16_t fromInventoryId, uint8_t fromSlotId uint32_t transactionId = 1; auto fromItem = m_inventoryMap[fromInventoryId]->getItem( fromSlotId ); + + deleteItemDb( fromItem ); m_inventoryMap[fromInventoryId]->removeItem( fromSlotId ); updateContainer( fromInventoryId, fromSlotId, nullptr ); diff --git a/src/servers/sapphire_zone/Inventory/Inventory.h b/src/servers/sapphire_zone/Inventory/Inventory.h index 69d4b532..57ab2c50 100644 --- a/src/servers/sapphire_zone/Inventory/Inventory.h +++ b/src/servers/sapphire_zone/Inventory/Inventory.h @@ -170,6 +170,7 @@ public: void updateBagDb( InventoryType type ); void updateMannequinDb( InventoryType type ); void updateItemDb( ItemPtr pItem ) const; + void deleteItemDb( ItemPtr pItem ) const; bool isArmory( uint16_t containerId ); bool isEquipment( uint16_t containerId ); diff --git a/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp b/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp index 7ce4de15..71ec3f2e 100644 --- a/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp +++ b/src/servers/sapphire_zone/Network/Handlers/InventoryHandler.cpp @@ -47,6 +47,7 @@ void Core::Network::GameConnection::inventoryModifyHandler( const Packets::GameP uint8_t toSlot = inPacket.getValAt< uint8_t >( 0x44 ); uint16_t fromContainer = inPacket.getValAt< uint16_t >( 0x2C ); uint16_t toContainer = inPacket.getValAt< uint16_t >( 0x40 ); + // todo: check packet handler in game and see if this is sent as a u16 or u32 uint16_t splitCount = inPacket.getValAt< uint16_t >( 0x48 ); ZoneChannelPacket< FFXIVIpcInventoryActionAck > ackPacket( player.getId() );