1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-09 12:17:45 +00:00

Update findFirstItemWithId to take list of bags

This commit is contained in:
Rushi 2022-02-12 00:58:52 +01:00
parent dc562bfe61
commit 9644b61ae1
2 changed files with 4 additions and 4 deletions

View file

@ -747,7 +747,7 @@ namespace Sapphire::Entity
uint32_t getNextInventorySequence();
bool findFirstItemWithId( uint32_t catalogId, Inventory::InventoryContainerPair& location );
bool findFirstItemWithId( uint32_t catalogId, Inventory::InventoryContainerPair& location, std::initializer_list< Common::InventoryType > bags = { Common::Bag0, Common::Bag1, Common::Bag2, Common::Bag3 } );
uint16_t getFreeSlotsInBags();

View file

@ -1076,15 +1076,15 @@ void Sapphire::Entity::Player::insertInventoryItem( Sapphire::Common::InventoryT
}
bool Sapphire::Entity::Player::findFirstItemWithId( uint32_t catalogId,
Inventory::InventoryContainerPair& location )
Inventory::InventoryContainerPair& location, std::initializer_list< InventoryType > bags )
{
for( auto bagId : { Bag0, Bag1, Bag2, Bag3 } )
for( auto bagId : bags )
{
auto& container = m_storageMap[ bagId ];
for( const auto& item : container->getItemMap() )
{
if( item.second->getId() != catalogId )
if(( item.second && item.second->getId() != catalogId ) || !item.second )
continue;
location = std::make_pair( bagId, item.first );