feat: implement item durability tracking and vendor repair

- Add ITEM_FIELD_DURABILITY (60) and ITEM_FIELD_MAXDURABILITY (61) to
  update_field_table.hpp enum and wotlk/update_fields.json
- Add curDurability/maxDurability to OnlineItemInfo and ItemDef structs
- Parse durability fields in OBJECT_CREATE and OBJECT_VALUES handlers;
  preserve existing values on partial updates (fixes stale durability
  being reset to 0 on stack-count-only updates)
- Propagate durability to ItemDef in all 5 rebuildOnlineInventory() paths
- Implement GameHandler::repairItem() and repairAll() via CMSG_REPAIR_ITEM
  (itemGuid=0 repairs all equipped items per WotLK protocol)
- Add canRepair flag to ListInventoryData; set it when player selects
  GOSSIP_OPTION_ARMORER in gossip window
- Show "Repair All" button in vendor window header when canRepair=true
- Display color-coded durability in item tooltip (green >50%, yellow
  >25%, red <=25%)
This commit is contained in:
Kelsi 2026-03-10 16:21:09 -07:00
parent 094ef88e57
commit 0afa41e908
9 changed files with 96 additions and 10 deletions

View file

@ -1258,6 +1258,8 @@ public:
uint32_t count = 1;
};
void buyBackItem(uint32_t buybackSlot);
void repairItem(uint64_t vendorGuid, uint64_t itemGuid);
void repairAll(uint64_t vendorGuid, bool useGuildBank = false);
const std::deque<BuybackItem>& getBuybackItems() const { return buybackItems_; }
void autoEquipItemBySlot(int backpackIndex);
void autoEquipItemInBag(int bagIndex, int slotIndex);
@ -1269,6 +1271,7 @@ public:
void useItemById(uint32_t itemId);
bool isVendorWindowOpen() const { return vendorWindowOpen; }
const ListInventoryData& getVendorItems() const { return currentVendorItems; }
void setVendorCanRepair(bool v) { currentVendorItems.canRepair = v; }
// Mail
bool isMailboxOpen() const { return mailboxOpen_; }
@ -1831,6 +1834,8 @@ private:
struct OnlineItemInfo {
uint32_t entry = 0;
uint32_t stackCount = 1;
uint32_t curDurability = 0;
uint32_t maxDurability = 0;
};
std::unordered_map<uint64_t, OnlineItemInfo> onlineItems_;
std::unordered_map<uint32_t, ItemQueryResponseData> itemInfoCache_;

View file

@ -46,6 +46,8 @@ struct ItemDef {
int32_t spirit = 0;
uint32_t displayInfoId = 0;
uint32_t sellPrice = 0;
uint32_t curDurability = 0;
uint32_t maxDurability = 0;
};
struct ItemSlot {

View file

@ -56,6 +56,8 @@ enum class UF : uint16_t {
// Item fields
ITEM_FIELD_STACK_COUNT,
ITEM_FIELD_DURABILITY,
ITEM_FIELD_MAXDURABILITY,
// Container fields
CONTAINER_FIELD_NUM_SLOTS,

View file

@ -2179,6 +2179,7 @@ struct VendorItem {
struct ListInventoryData {
uint64_t vendorGuid = 0;
std::vector<VendorItem> items;
bool canRepair = false; // Set when vendor was opened via GOSSIP_OPTION_ARMORER
bool isValid() const { return true; }
};