Remove sold items from equipment slots and loadout slots if they exist there so they no longer linger. Relase Build 7870. Game Version 0.4.2
This commit is contained in:
@@ -205,9 +205,30 @@ void Merchant::SellItem(std::weak_ptr<Item>item,uint32_t amt){
|
||||
}
|
||||
totalCost=item.lock()->SellValue()*amt;
|
||||
|
||||
//If the item is equipped on our character, remove it.
|
||||
EquipSlot equippedItemSlot=Inventory::GetSlotEquippedIn(item);
|
||||
if(equippedItemSlot!=EquipSlot::NONE)Inventory::UnequipItem(equippedItemSlot);
|
||||
|
||||
int foundLoadoutSlot=-1;
|
||||
//If the item exists in our loadout, remove it.
|
||||
for(int i=0;i<game->GetLoadoutSize();i++){
|
||||
if(!ISBLANK(game->GetLoadoutItem(i))&&game->GetLoadoutItem(i).lock()->ActualName()==item.lock()->ActualName()){
|
||||
game->ClearLoadoutItem(i);
|
||||
if(foundLoadoutSlot!=-1)ERR("WARNING! Found two loadout item slots with the same item! THIS SHOULD NOT BE HAPPENING!")
|
||||
foundLoadoutSlot=i;
|
||||
}
|
||||
}
|
||||
|
||||
std::string itemName=item.lock()->ActualName(); //We need the item name since our reference to the item is about to be deleted.
|
||||
|
||||
Inventory::RemoveItem(item,amt);
|
||||
game->GetPlayer()->SetMoney(game->GetPlayer()->GetMoney()+totalCost);
|
||||
|
||||
//If we still have some in our inventory, we'll add them back in.
|
||||
if(Inventory::GetItemCount(itemName)>0){
|
||||
game->SetLoadoutItem(foundLoadoutSlot,itemName);
|
||||
}
|
||||
|
||||
sellFunctionPrimed=false;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user