|
|
|
@ -185,10 +185,7 @@ 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,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; |
|
|
|
|
#pragma region Calculate Inventory to Manipulate |
|
|
|
|
std::vector<Item>&inv=sortedInv.at(inventory); |
|
|
|
|
bool eraseFromLootWindow=false; |
|
|
|
|
if(inventory=="Monster Loot") { |
|
|
|
@ -199,10 +196,17 @@ bool Inventory::RemoveItem(IT it,ITCategory inventory,uint32_t amt){ |
|
|
|
|
inv=sortedInv.at("Stage Loot"); |
|
|
|
|
eraseFromLootWindow=true; |
|
|
|
|
} |
|
|
|
|
int count=0; |
|
|
|
|
for(Item&item:inv){ |
|
|
|
|
if(item.Name()==it)break; |
|
|
|
|
count++; |
|
|
|
|
} |
|
|
|
|
#pragma endregion |
|
|
|
|
|
|
|
|
|
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
|
|
|
|
|
if (!inv.at(count).Amt())return false; |
|
|
|
|
|
|
|
|
|
if (amt>=inv.at(count).Amt()){ |
|
|
|
|
inv.erase(inv.begin()+count); |
|
|
|
|
if(!eraseFromLootWindow){ |
|
|
|
|
_inventory.erase(it); |
|
|
|
@ -211,7 +215,10 @@ bool Inventory::RemoveItem(IT it,ITCategory inventory,uint32_t amt){ |
|
|
|
|
Menu::InventorySlotsUpdated(inventory); |
|
|
|
|
return true; |
|
|
|
|
}else{ |
|
|
|
|
_inventory.at(it).amt-=amt; |
|
|
|
|
inv.at(count).amt-=amt; |
|
|
|
|
if(!eraseFromLootWindow){ |
|
|
|
|
_inventory.at(it).amt-=amt; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|