From 673910cf774df56bc6b02d607e3d1ad57c0c8fe0 Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Thu, 22 Jan 2026 03:11:10 +0400 Subject: [PATCH] disable sort debug --- Core/Init.lua | 11 +++++++++++ Core/Main.lua | 6 ++++++ Sorting/SortEngine.lua | 16 ++++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Core/Init.lua b/Core/Init.lua index 9066e04..54f49fa 100644 --- a/Core/Init.lua +++ b/Core/Init.lua @@ -12,6 +12,9 @@ addon.BUILD = "TurtleWoW-1.12.1" -- Debug flag addon.DEBUG = false +-- Debug sort flag (verbose sorting output) +addon.DEBUG_SORT = false + -- Constants addon.Constants = { -- Bag IDs @@ -232,6 +235,14 @@ function addon:Debug(msg, a1, a2, a3, a4, a5, a6, a7) end end +-- Debug sort print (only shows when DEBUG_SORT is enabled) +function addon:DebugSort(msg, a1, a2, a3, a4, a5, a6, a7) + if self.DEBUG_SORT then + local text = string.format(msg, a1, a2, a3, a4, a5, a6, a7) + DEFAULT_CHAT_FRAME:AddMessage("|cFF87CEEB[Sort]|r |cFF00FF96Guda:|r " .. text) + end +end + -- Error handler function addon:Error(msg, a1, a2, a3, a4, a5, a6, a7) local text = string.format(msg, a1, a2, a3, a4, a5, a6, a7) diff --git a/Core/Main.lua b/Core/Main.lua index 2025155..939603e 100644 --- a/Core/Main.lua +++ b/Core/Main.lua @@ -122,6 +122,11 @@ function Main:SetupSlashCommands() addon.DEBUG = not addon.DEBUG addon:Print("Debug mode: %s", addon.DEBUG and "ON" or "OFF") + elseif msg == "debugsort" then + -- Toggle debug sort (verbose sorting output) + addon.DEBUG_SORT = not addon.DEBUG_SORT + addon:Print("Debug sort mode: %s", addon.DEBUG_SORT and "ON" or "OFF") + elseif msg == "quest" then -- Toggle quest bar local show = not addon.Modules.DB:GetSetting("showQuestBar") @@ -154,6 +159,7 @@ function Main:SetupSlashCommands() addon:Print("/guda sortbank - Sort bank") addon:Print("/guda track - Toggle item tracking") addon:Print("/guda debug - Toggle debug mode") + addon:Print("/guda debugsort - Toggle sort debug output") addon:Print("/guda cleanup - Remove old characters") else diff --git a/Sorting/SortEngine.lua b/Sorting/SortEngine.lua index 708078e..43f3614 100644 --- a/Sorting/SortEngine.lua +++ b/Sorting/SortEngine.lua @@ -1457,8 +1457,8 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort self.sortingInProgress = true self:UpdateSortButtonState(true) - -- Print analysis results - addon:Print("Sorting %s... (%d/%d items need sorting, estimated %d passes)", + -- Print analysis results (only when debug sort is enabled) + addon:DebugSort("Sorting %s... (%d/%d items need sorting, estimated %d passes)", sortType, analysis.itemsOutOfPlace, analysis.totalItems, analysis.passes) local passCount = 0 @@ -1467,7 +1467,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort local totalMoves = 0 local noProgressPasses = 0 - addon:Print("Starting %s sort (estimated: %d passes, safety limit: %d)", sortType, maxPasses, safetyLimit) + addon:DebugSort("Starting %s sort (estimated: %d passes, safety limit: %d)", sortType, maxPasses, safetyLimit) local function DoSortPass() passCount = passCount + 1 @@ -1481,7 +1481,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort if currentAnalysis.alreadySorted then -- Sorting is complete! - addon:Print("%s sort complete! (%d passes, %d total moves)", sortType, passCount, totalMoves) + addon:DebugSort("%s sort complete! (%d passes, %d total moves)", sortType, passCount, totalMoves) -- Final update local frame = CreateFrame("Frame") @@ -1496,7 +1496,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort end) elseif passCount >= safetyLimit then -- Hit safety limit but not fully sorted - addon:Print("%s sort stopped at safety limit! (%d/%d items still need sorting after %d passes)", + addon:DebugSort("%s sort stopped at safety limit! (%d/%d items still need sorting after %d passes)", sortType, currentAnalysis.itemsOutOfPlace, currentAnalysis.totalItems, passCount) -- Final update @@ -1519,7 +1519,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort end if noProgressPasses >= 5 then - addon:Print("%s sort stopped due to no progress after %d passes (items remaining: %d/%d)", + addon:DebugSort("%s sort stopped due to no progress after %d passes (items remaining: %d/%d)", sortType, passCount, currentAnalysis.itemsOutOfPlace, currentAnalysis.totalItems) -- Final update local frame = CreateFrame("Frame") @@ -1537,7 +1537,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort -- More sorting needed local remainingRatio = currentAnalysis.itemsOutOfPlace / math.max(1, currentAnalysis.totalItems) - addon:Print("%s Pass %d: %d moves, %d/%d items remaining (%.1f%%)", + addon:DebugSort("%s Pass %d: %d moves, %d/%d items remaining (%.1f%%)", sortType, passCount, moveCount, currentAnalysis.itemsOutOfPlace, currentAnalysis.totalItems, remainingRatio * 100) -- PROGRESSIVE DELAY: Calculate delay based on remaining complexity @@ -1545,7 +1545,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort local complexityDelay = math.min(currentAnalysis.itemsOutOfPlace * 0.06, 2.5) -- max 2.5 seconds local totalDelay = baseDelay + complexityDelay - addon:Print("Waiting %.1f seconds before next pass...", totalDelay) + addon:DebugSort("Waiting %.1f seconds before next pass...", totalDelay) -- Wait with progressive delay, then sort again local frame = CreateFrame("Frame")