From 9644b61ae1a6ade606dd8da998e3954712455074 Mon Sep 17 00:00:00 2001 From: Rushi <44952533+Skyliegirl33@users.noreply.github.com> Date: Sat, 12 Feb 2022 00:58:52 +0100 Subject: [PATCH] Update findFirstItemWithId to take list of bags --- src/world/Actor/Player.h | 2 +- src/world/Actor/PlayerInventory.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/world/Actor/Player.h b/src/world/Actor/Player.h index 10dfe28c..df7fea04 100644 --- a/src/world/Actor/Player.h +++ b/src/world/Actor/Player.h @@ -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(); diff --git a/src/world/Actor/PlayerInventory.cpp b/src/world/Actor/PlayerInventory.cpp index 44335086..4915c279 100644 --- a/src/world/Actor/PlayerInventory.cpp +++ b/src/world/Actor/PlayerInventory.cpp @@ -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 );