@ -184,21 +184,31 @@ bool Inventory::UseItem(IT it,uint32_t amt){
}
//Returns true if the item has been consumed completely and there are 0 remaining of that type in our inventory.
bool Inventory : : RemoveItem ( IT it , uint32_t amt ) {
bool Inventory : : RemoveItem ( IT it , ITCategory inventory , uint32_t amt ) {
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
if ( ! _inventory . count ( it ) ) return false ;
if ( amt > = _inventory . at ( it ) . Amt ( ) ) {
int count = 0 ;
std : : vector < Item > & sortedList = sortedInv . at ( _inventory . at ( it ) . Category ( ) ) ;
for ( Item & item : sortedList ) {
std : : vector < Item > & inv = sortedInv . at ( inventory ) ;
bool eraseFromLootWindow = false ;
if ( inventory = = " Monster Loot " ) {
inv = sortedInv . at ( " Monster Loot " ) ;
eraseFromLootWindow = true ;
} else
if ( inventory = = " Stage Loot " ) {
inv = sortedInv . at ( " Stage Loot " ) ;
eraseFromLootWindow = true ;
}
for ( Item & item : inv ) {
if ( item . Name ( ) = = it ) break ;
count + + ;
}
sortedList . erase ( sortedList . begin ( ) + count ) ;
inv . erase ( inv . begin ( ) + count ) ;
if ( ! eraseFromLootWindow ) {
_inventory . erase ( it ) ;
ITCategory cat = ITEM_DATA [ it ] . category ;
}
//Callback for GUI inventories.
Menu : : InventorySlotsUpdated ( cat ) ;
Menu : : InventorySlotsUpdated ( inventory ) ;
return true ;
} else {
_inventory . at ( it ) . amt - = amt ;
@ -206,6 +216,12 @@ bool Inventory::RemoveItem(IT it,uint32_t amt){
}
}
//Returns true if the item has been consumed completely and there are 0 remaining of that type in our inventory.
bool Inventory : : RemoveItem ( IT it , uint32_t amt ) {
ITCategory cat = ITEM_DATA [ it ] . category ;
return RemoveItem ( it , cat , amt ) ;
}
std : : vector < Item > & Inventory : : get ( ITCategory itemCategory ) {
return sortedInv . at ( itemCategory ) ;
}
@ -298,7 +314,7 @@ void Inventory::Clear(ITCategory itemCategory){
if ( itemCategory = = " Monster Loot " | | itemCategory = = " Stage Loot " ) { //These do not affect the actual inventory, we just clear the lists.
itemQuantity = item . Amt ( ) ;
}
RemoveItem ( item . Name ( ) , itemQuantity ) ;
RemoveItem ( item . Name ( ) , itemCategory , item Quantity ) ;
}
}