anchor.diff:        MsgLog.Add(_('You need more gold.'));
         Exit;
       end;
  -    FItem.Durability := FItem.MaxDurability;
  -    if ((Items_Inventory_DeleteItemAmount(Ord(ivGold), RepairCost) > 0) and
  -      (Items_Inventory_SetItem(Index, FItem) > 0)) then
  -      MsgLog.Add(Format(_('You repaired %s (-%d gold).'),
  -        [Items.GetNameThe(FItem), RepairCost]));
  +    if (FItem.MaxDurability > 0) then
  +    begin
  +      Dec(FItem.MaxDurability);
  +      if (FItem.MaxDurability = 0) then
  +      begin
  +        RnItem(FItem, Index);
  +        Exit;
  +      end;
  +      FItem.Durability := FItem.MaxDurability;
  +      if ((Items_Inventory_DeleteItemAmount(Ord(ivGold), RepairCost) > 0) and
  +        (Items_Inventory_SetItem(Index, FItem) > 0)) then
  +        MsgLog.Add(Format(_('You repaired %s (-%d gold).'),
  +          [Items.GetNameThe(FItem), RepairCost]));
  +    end;
     end;
     Self.Calc;
   end;
  
positive.code:   uShop, BearLibTerminal, uAbility, uAffixes, uAttribute, uSpellbook, uUI,
    uBearLibItemsCommon, uBearLibItemsDungeon, uBearLibItemsInventory;
  
  { TPlayer }
  
  // Generate a random background (from Kharne roguelike)
  
negative.code:       [Items.GetNameThe(FItem), FItem.Durability, FItem.MaxDurability]),
        clAlarm));
    Items_Inventory_SetItem(Index, FItem);
    RnItem(FItem, Index);
    Self.Calc;
  end;
  
  