diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 3aa474de..d5cfcce6 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -948,7 +948,7 @@ namespace Sapphire::Entity ItemPtr getItemAt( uint16_t containerId, uint8_t slotId ); - bool updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem ); + bool updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem, bool writeToDb = true ); /*! calculate and return player ilvl based off equipped gear */ uint16_t calculateEquippedGearItemLevel(); diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index 81de4add..5ead207c 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -739,7 +739,7 @@ Sapphire::Entity::Player::moveItem( uint16_t fromInventoryId, uint8_t fromSlotId sendStatusEffectUpdate(); // send if any equip is changed } -bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem ) +bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint8_t slotId, ItemPtr pItem, bool writeToDb ) { auto containerType = World::Manager::ItemMgr::getContainerType( storageId ); @@ -752,7 +752,8 @@ bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint8_t slot case Bag: case CurrencyCrystal: { - writeInventory( static_cast< InventoryType >( storageId ) ); + if( writeToDb ) + writeInventory( static_cast< InventoryType >( storageId ) ); break; } @@ -767,7 +768,8 @@ bool Sapphire::Entity::Player::updateContainer( uint16_t storageId, uint8_t slot else unequipItem( static_cast< GearSetSlot >( slotId ), pItem, true ); - writeInventory( static_cast< InventoryType >( storageId ) ); + if( writeToDb ) + writeInventory( static_cast< InventoryType >( storageId ) ); break; } default: @@ -804,7 +806,7 @@ void Sapphire::Entity::Player::splitItem( uint16_t fromInventoryId, uint8_t from fromItem->setStackSize( fromItem->getStackSize() - itemCount ); - updateContainer( fromInventoryId, fromSlotId, fromItem ); + updateContainer( fromInventoryId, fromSlotId, fromItem, fromInventoryId != toInventoryId ); updateContainer( toInventoryId, toSlot, newItem ); updateItemDb( fromItem ); @@ -835,7 +837,7 @@ void Sapphire::Entity::Player::mergeItem( uint16_t fromInventoryId, uint8_t from { fromItem->setStackSize( stackOverflow ); updateItemDb( fromItem ); - updateContainer( fromInventoryId, fromSlotId, fromItem ); + updateContainer( fromInventoryId, fromSlotId, fromItem, fromInventoryId != toInventoryId ); } @@ -871,7 +873,7 @@ void Sapphire::Entity::Player::swapItem( uint16_t fromInventoryId, uint8_t fromS auto containerTypeFrom = World::Manager::ItemMgr::getContainerType( fromInventoryId ); auto containerTypeTo = World::Manager::ItemMgr::getContainerType( toInventoryId ); - updateContainer( toInventoryId, toSlot, fromItem ); + updateContainer( toInventoryId, toSlot, fromItem, fromInventoryId != toInventoryId ); updateContainer( fromInventoryId, fromSlotId, toItem ); if( static_cast< InventoryType >( toInventoryId ) == GearSet0 ||