From d44d4626867f8e79487ade977ec2c0bc3948a330 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 17 Mar 2026 20:27:45 -0700 Subject: [PATCH] feat: add auto-repair at vendor open When 'Auto Repair' is enabled in Settings > Gameplay, all damaged equipment is automatically repaired when opening any armorer vendor (canRepair=true). The repair is skipped when no items are actually damaged to avoid a pointless server round-trip. A system chat message confirms the repair. Setting persists to ~/.wowee/settings.cfg as auto_repair. --- include/game/game_handler.hpp | 3 +++ include/ui/game_screen.hpp | 1 + src/game/game_handler.cpp | 18 ++++++++++++++++++ src/ui/game_screen.cpp | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index c18f234c..114ee071 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -1396,6 +1396,8 @@ public: bool isAutoLoot() const { return autoLoot_; } void setAutoSellGrey(bool enabled) { autoSellGrey_ = enabled; } bool isAutoSellGrey() const { return autoSellGrey_; } + void setAutoRepair(bool enabled) { autoRepair_ = enabled; } + bool isAutoRepair() const { return autoRepair_; } // Master loot candidates (from SMSG_LOOT_MASTER_LIST) const std::vector& getMasterLootCandidates() const { return masterLootCandidates_; } @@ -2882,6 +2884,7 @@ private: bool lootWindowOpen = false; bool autoLoot_ = false; bool autoSellGrey_ = false; + bool autoRepair_ = false; LootResponseData currentLoot; std::vector masterLootCandidates_; // from SMSG_LOOT_MASTER_LIST diff --git a/include/ui/game_screen.hpp b/include/ui/game_screen.hpp index 4f6e0f84..98b93b67 100644 --- a/include/ui/game_screen.hpp +++ b/include/ui/game_screen.hpp @@ -196,6 +196,7 @@ private: bool pendingShowKeyring = true; bool pendingAutoLoot = false; bool pendingAutoSellGrey = false; + bool pendingAutoRepair = false; // Keybinding customization int pendingRebindAction = -1; // -1 = not rebinding, otherwise action index diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 7b354ddd..7f1c7b02 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -21259,6 +21259,24 @@ void GameHandler::handleListInventory(network::Packet& packet) { } } + // Auto-repair all items if enabled and vendor can repair + if (autoRepair_ && currentVendorItems.canRepair && currentVendorItems.vendorGuid != 0) { + // Check that at least one equipped item is actually damaged to avoid no-op + bool anyDamaged = false; + for (int i = 0; i < Inventory::NUM_EQUIP_SLOTS; ++i) { + const auto& slot = inventory.getEquipSlot(static_cast(i)); + if (!slot.empty() && slot.item.maxDurability > 0 + && slot.item.curDurability < slot.item.maxDurability) { + anyDamaged = true; + break; + } + } + if (anyDamaged) { + repairAll(currentVendorItems.vendorGuid, false); + addSystemChatMessage("|cffaaaaaaAuto-repair triggered.|r"); + } + } + // Play vendor sound if (npcVendorCallback_ && currentVendorItems.vendorGuid != 0) { auto entity = entityManager.getEntity(currentVendorItems.vendorGuid); diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 729c4ea7..e0ed2b03 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -595,6 +595,7 @@ void GameScreen::render(game::GameHandler& gameHandler) { // Apply auto-loot / auto-sell settings to GameHandler every frame (cheap bool sync) gameHandler.setAutoLoot(pendingAutoLoot); gameHandler.setAutoSellGrey(pendingAutoSellGrey); + gameHandler.setAutoRepair(pendingAutoRepair); // Zone entry detection — fire a toast when the renderer's zone name changes if (auto* rend = core::Application::getInstance().getRenderer()) { @@ -16334,6 +16335,11 @@ void GameScreen::renderSettingsWindow() { } if (ImGui::IsItemHovered()) ImGui::SetTooltip("Automatically sell all grey (poor quality) items when opening a vendor"); + if (ImGui::Checkbox("Auto Repair", &pendingAutoRepair)) { + saveSettings(); + } + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("Automatically repair all damaged equipment when opening an armorer vendor"); ImGui::Spacing(); ImGui::Text("Bags"); @@ -18335,6 +18341,7 @@ void GameScreen::saveSettings() { // Gameplay out << "auto_loot=" << (pendingAutoLoot ? 1 : 0) << "\n"; out << "auto_sell_grey=" << (pendingAutoSellGrey ? 1 : 0) << "\n"; + out << "auto_repair=" << (pendingAutoRepair ? 1 : 0) << "\n"; out << "graphics_preset=" << static_cast(currentGraphicsPreset) << "\n"; out << "ground_clutter_density=" << pendingGroundClutterDensity << "\n"; out << "shadows=" << (pendingShadows ? 1 : 0) << "\n"; @@ -18477,6 +18484,7 @@ void GameScreen::loadSettings() { // Gameplay else if (key == "auto_loot") pendingAutoLoot = (std::stoi(val) != 0); else if (key == "auto_sell_grey") pendingAutoSellGrey = (std::stoi(val) != 0); + else if (key == "auto_repair") pendingAutoRepair = (std::stoi(val) != 0); else if (key == "graphics_preset") { int presetVal = std::clamp(std::stoi(val), 0, 4); currentGraphicsPreset = static_cast(presetVal);