Item reference system deprecated in favor of smart pointer system. Converted all items to use pointers instead, removed all reference wrappers for item system. Fixed buggy last item sorting when removing items from InventoryScrollableWindowComponents. Implemented proper inventory removal checks when items are completely removed from an inventory. Sorted inventories now copy the pointer as a shared pointer from the main inventory code instead of needlessly creating extra copies of the same item.
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
GetLoadoutItem(slot).amt=std::min((uint32_t)"Player.Item Loadout Limit"_I,GetLoadoutItem(slot).Amt());//We are only allowed to have up to 10 maximum of an item on a journey.
GetLoadoutItem(slot).lock()->amt=std::min((uint32_t)"Player.Item Loadout Limit"_I,GetLoadoutItem(slot).lock()->Amt());//We are only allowed to have up to 10 maximum of an item on a journey.
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
//There are two places to manipulate items in (Both the sorted inventory and the actual inventory)
if(!itemAmt)returnfalse;
if(!itemAmt)returnfalse;
if(amt>=itemAmt){
if(amt>=itemAmt){
inv.erase(inv.begin()+count);//Clears it from the detected sorted inventory as well!
if(!eraseFromLootWindow){
if(!eraseFromLootWindow){//We must clear out the item AFTER we've updated context-sensitive inventories because they may be borrowing a ref from this structure!!!
_inventory.erase(it);
_inventory.erase(it);
}else{
inv.erase(inv.begin()+count);
}
}
//Callback for GUI inventories.
//Callback for GUI inventories.
Menu::InventorySlotsUpdated(inventory);
Menu::InventorySlotsUpdated(inventory);
returntrue;
returntrue;
}else{
}else{
if(!eraseFromLootWindow){
if(!eraseFromLootWindow){
_inventory.at(it).amt-=amt;
_inventory.at(it)->amt-=amt;
}else{
}else{
inv.at(count).amt-=amt;
inv.at(count)->amt-=amt;//Don't touch the sorted inventory unless this is monster loot or stage loot because there's only "1" of this item in the entry list.
if(Item::IsBlankStaticCallCounter!=1)ERR("WARNING! You should not call the IsBlank() function directly! Use ISBLANK() macro instead!")
Item::IsBlankStaticCallCounter--;
returnamt==0||it==nullptr;
returnamt==0||it==nullptr;
}
}
voidInventory::Clear(ITCategoryitemCategory){
voidInventory::Clear(ITCategoryitemCategory){
std::vector<Item>itemList=get(itemCategory);//We have to make a copy here because RemoveItem() will modify the list provided by get() inline.
std::vector<std::shared_ptr<Item>>itemList=get(itemCategory);//We have to make a copy here because RemoveItem() will modify the list provided by get() inline.
for(Item&item:itemList){
for(std::shared_ptr<Item>&item:itemList){
size_titemQuantity=GetItemCount(item.ActualName());//Normally we want to clear all the items that are actually in our inventory...But...
size_titemQuantity=GetItemCount(item->ActualName());//Normally we want to clear all the items that are actually in our inventory...But...
if(itemCategory=="Monster Loot"||itemCategory=="Stage Loot"){//These do not affect the actual inventory, we just clear the lists.
if(itemCategory=="Monster Loot"||itemCategory=="Stage Loot"){//These do not affect the actual inventory, we just clear the lists.
//Returns the actual amount available in your main inventory.
//Returns the actual amount available in your main inventory.
staticuint32_tGetItemCount(ITit);
staticuint32_tGetItemCount(ITit);
staticItemCopyItem(ITit);
staticstd::shared_ptr<Item>CopyItem(ITit);
staticItem&GetItem(ITit);
staticstd::weak_ptr<Item>GetItem(ITit);
//Auto-executes its use function and removes the amt specified from the inventory. Multiple amounts will cause the item to execute its useFunc multiple times.
//Auto-executes its use function and removes the amt specified from the inventory. Multiple amounts will cause the item to execute its useFunc multiple times.
intitemQuantity=Inventory::GetItemCount(invRef.at(inventoryIndex).ActualName());//Normally we'd retrieve how many of this item we have from our inventory...However Monster Loot and Stage Loot inventories are special and hold their own inventory counts...
intitemQuantity=Inventory::GetItemCount(invRef.at(inventoryIndex)->ActualName());//Normally we'd retrieve how many of this item we have from our inventory...However Monster Loot and Stage Loot inventories are special and hold their own inventory counts...