From 72b924c514392b580ad387b92abb1c95f2e7ce5c Mon Sep 17 00:00:00 2001 From: Xurkon Date: Sat, 30 May 2026 12:24:11 -0500 Subject: [PATCH] wip: preserve Sunstrider minimap debugging state --- Compat/Compat.lua | 44 ++++++++++++++++++++++- Compat/HBD.lua | 60 +++++++++++++++++++++++++------ Modules/Map/QuestieMap.lua | 73 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 163 insertions(+), 14 deletions(-) diff --git a/Compat/Compat.lua b/Compat/Compat.lua index cdf5e8e..fa51e2d 100644 --- a/Compat/Compat.lua +++ b/Compat/Compat.lua @@ -278,7 +278,7 @@ end -- for the player, including changing the current map zoom (if needed) -- https://wowpedia.fandom.com/wiki/API_C_Map.GetPlayerMapPosition?oldid=2167175 function QuestieCompat.GetCurrentPlayerPosition() - local debugPins = _G.QuestieDebugPins + local debugPins = _G.QuestieDebugPlayerPosition local visibleWorldMap = WorldMapFrame:IsVisible() if not WorldMapFrame:IsVisible() then SetMapToCurrentZone(); @@ -1952,3 +1952,45 @@ SlashCmdList["QUESTIEDRIFT"] = function() print(string.format("[QD] GetCurrentMapAreaID=%s dungeonLevel=%s composite=%s", tostring(areaId), tostring(mapLvl), tostring(areaId and (areaId + (mapLvl or 0)/10)))) end + +local function ToggleQuestieDebug(flagName, label) + local newState = not _G[flagName] + _G[flagName] = newState + print(string.format("[QD] %s=%s", label, tostring(newState))) +end + +local function SetQuestieDebugGroup(state) + _G.QuestieDebugPlayerPosition = state + _G.QuestieDebugPlayerWorld = state + _G.QuestieDebugMinimapGate = state + _G.QuestieDebugMinimapPin = state + print(string.format( + "[QD] ALL pos=%s world=%s gate=%s pin=%s", + tostring(state), tostring(state), tostring(state), tostring(state))) +end + +SLASH_QUESTIEDEBUGPOS1 = "/qdbgpos" +SlashCmdList["QUESTIEDEBUGPOS"] = function() + ToggleQuestieDebug("QuestieDebugPlayerPosition", "PlayerPosition") +end + +SLASH_QUESTIEDEBUGWORLD1 = "/qdbgworld" +SlashCmdList["QUESTIEDEBUGWORLD"] = function() + ToggleQuestieDebug("QuestieDebugPlayerWorld", "PlayerWorld") +end + +SLASH_QUESTIEDEBUGGATE1 = "/qdbggate" +SlashCmdList["QUESTIEDEBUGGATE"] = function() + ToggleQuestieDebug("QuestieDebugMinimapGate", "MinimapGate") +end + +SLASH_QUESTIEDEBUGPIN1 = "/qdbgpin" +SlashCmdList["QUESTIEDEBUGPIN"] = function() + ToggleQuestieDebug("QuestieDebugMinimapPin", "MinimapPin") +end + +SLASH_QUESTIEDEBUGALL1 = "/qdbgall" +SlashCmdList["QUESTIEDEBUGALL"] = function() + local anyOff = not (_G.QuestieDebugPlayerPosition and _G.QuestieDebugPlayerWorld and _G.QuestieDebugMinimapGate and _G.QuestieDebugMinimapPin) + SetQuestieDebugGroup(anyOff) +end diff --git a/Compat/HBD.lua b/Compat/HBD.lua index 0390606..d19087c 100644 --- a/Compat/HBD.lua +++ b/Compat/HBD.lua @@ -282,7 +282,7 @@ function HBD:GetPlayerWorldPosition() local wx, wy, inst = HBD:GetWorldCoordinatesFromZone(x, y, uiMapID) _pwp_x, _pwp_y, _pwp_inst = wx, wy, inst _pwp_time = now - if _G.QuestieDebugPins then + if _G.QuestieDebugPlayerWorld then print(string.format("[QD] GetPlayerWorldPosition: zoneX=%.4f zoneY=%.4f uiMapID=%s -> worldX=%s worldY=%s inst=%s", x, y, tostring(uiMapID), tostring(wx), tostring(wy), tostring(inst))) end @@ -425,15 +425,18 @@ local function drawMinimapPin(pin, data) local xDist, yDist = lastXY - data.x, lastYY - data.y -- Throttled debug: print once per second max - if _G.QuestieDebugPins and data.uiMapID and (not _G._QDPinDebugTime or (GetTime() - _G._QDPinDebugTime) > 1) then - _G._QDPinDebugTime = GetTime() - print(string.format( - "[QD] PIN uiMap=%s pinW=(%.2f,%.2f) playerW=(%.2f,%.2f) dist=(%.2f,%.2f) mapRad=%.1f diff=(%.4f,%.4f)", - tostring(data.uiMapID), - data.x, data.y, lastXY, lastYY, - xDist, yDist, mapRadius or -1, - xDist / (mapRadius or 1), yDist / (mapRadius or 1))) - end + if _G.QuestieDebugMinimapPin and data.uiMapID and (not _G._QDPinDebugTime or (GetTime() - _G._QDPinDebugTime) > 1) then + _G._QDPinDebugTime = GetTime() + local finalX = (xDist / (mapRadius or 1)) * minimapWidth + local finalY = (yDist / (mapRadius or 1)) * minimapHeight + print(string.format( + "[QD] PIN uiMap=%s inst=%s/%s pinW=(%.2f,%.2f) playerW=(%.2f,%.2f) dist=(%.2f,%.2f) mapRad=%.1f scale=(%.4f,%.4f) final=(%.2f,%.2f)", + tostring(data.uiMapID), tostring(data.instanceID), tostring(lastInstanceId), + data.x, data.y, lastXY, lastYY, + xDist, yDist, mapRadius or -1, + xDist / (mapRadius or 1), yDist / (mapRadius or 1), + finalX, finalY)) + end -- handle rotation if rotateMinimap then @@ -560,8 +563,35 @@ local function UpdateMinimapPins(force) mapCos = cos(facing) end + local debugGateCount = 0 + local debugPinCount = 0 + local debugActiveCount = 0 + local sunCount, sunMinX, sunMaxX, sunMinY, sunMaxY = 0, nil, nil, nil, nil + for _ in pairs(minimapPins) do debugPinCount = debugPinCount + 1 end + for _ in pairs(activeMinimapPins) do debugActiveCount = debugActiveCount + 1 end + for pin, data in pairs(minimapPins) do - if instanceID == data.instanceID and math.abs(x-data.x) + math.abs(y-data.y) < 500 then -- questie specific fix + if data.uiMapID == 1241 then + sunCount = sunCount + 1 + sunMinX = sunMinX and min(sunMinX, data.x) or data.x + sunMaxX = sunMaxX and max(sunMaxX, data.x) or data.x + sunMinY = sunMinY and min(sunMinY, data.y) or data.y + sunMaxY = sunMaxY and max(sunMaxY, data.y) or data.y + end + local dist = math.abs(x-data.x) + math.abs(y-data.y) + if _G.QuestieDebugMinimapGate and data.uiMapID == 1241 and debugGateCount < 3 then + debugGateCount = debugGateCount + 1 + print(string.format( + "[QD] SUN#%d total=%d active=%d label=%s uiMap=%s inst=%s/%s dist=%.2f pass=%s float=%s pinW=(%.2f,%.2f) playerW=(%.2f,%.2f)", + debugGateCount, debugPinCount, debugActiveCount, + tostring(data.label or data.Name or data.name or data.Title or data.id or data.Id), + tostring(data.uiMapID), tostring(data.instanceID), tostring(instanceID), + dist, + tostring(instanceID == data.instanceID and dist < 500), + tostring(data.floatOnEdge), + data.x, data.y, x, y)) + end + if instanceID == data.instanceID and dist < 500 then activeMinimapPins[pin] = data data.keep = true -- draw the pin (this may reset data.keep if outside of the map) @@ -569,6 +599,14 @@ local function UpdateMinimapPins(force) end end + if _G.QuestieDebugMinimapGate and sunCount > 0 then + print(string.format( + "[QD] SUNSUM total=%d active=%d count=%d x=[%.2f,%.2f] y=[%.2f,%.2f] mapRad=%.1f size=(%.1f,%.1f)", + debugPinCount, debugActiveCount, sunCount, + sunMinX or -1, sunMaxX or -1, sunMinY or -1, sunMaxY or -1, + mapRadius or -1, minimapWidth or -1, minimapHeight or -1)) + end + minimapPinCount = 0 for pin, data in pairs(activeMinimapPins) do if not data.keep then diff --git a/Modules/Map/QuestieMap.lua b/Modules/Map/QuestieMap.lua index 3693ba4..4c4dd69 100644 --- a/Modules/Map/QuestieMap.lua +++ b/Modules/Map/QuestieMap.lua @@ -105,6 +105,34 @@ function QuestieMap:UnloadQuestFrames(questId, iconType) end end +function QuestieMap:UnloadQuestFramesByDataType(questId, dataType) + if QuestieMap.questIdFrames[questId] then + for _, frame in pairs(QuestieMap:GetFramesForQuest(questId)) do + if frame and frame.data and frame.data.Type == dataType then + frame:Unload() + end + end + + if not next(QuestieMap.questIdFrames[questId]) then + QuestieMap.questIdFrames[questId] = nil + end + end +end + +function QuestieMap:UnloadQuestFramesExceptDataType(questId, dataType) + if QuestieMap.questIdFrames[questId] then + for _, frame in pairs(QuestieMap:GetFramesForQuest(questId)) do + if frame and ((not frame.data) or frame.data.Type ~= dataType) then + frame:Unload() + end + end + + if not next(QuestieMap.questIdFrames[questId]) then + QuestieMap.questIdFrames[questId] = nil + end + end +end + --Get the frames for manual note, this returns all of the frames/spawns ---@param id number @The ID of the NPC (>0) or object (<0) function QuestieMap:GetManualFrames(id, typ) @@ -270,6 +298,25 @@ end function QuestieMap:QueueDraw(drawType, ...) if (not isDrawQueueDisabled) then + if _G.QuestieDebugPins then + local args = { ... } + local frame = args[2] + local data = frame and frame.data + local label = data and (data.Name or data.name or data.Title) + local questId = data and (data.Id or data.id) + if label == "Mana Wyrm" or questId == 8325 then + print(string.format( + "[QD] QueueDraw type=%s frame=%s label=%s quest=%s mini=%s ui=%s area=%s", + tostring(drawType), + tostring(frame and frame:GetName()), + tostring(label), + tostring(questId), + tostring(frame and frame.miniMapIcon), + tostring(frame and frame.UiMapID), + tostring(frame and frame.AreaID) + )) + end + end if (drawType == QuestieMap.ICON_MAP_TYPE) then tinsert(mapDrawQueue, { ... }); elseif (drawType == QuestieMap.ICON_MINIMAP_TYPE) then @@ -299,6 +346,28 @@ function QuestieMap.ProcessQueue() if minimapDrawCall then local frame = minimapDrawCall[2]; HBDPins:AddMinimapIconMap(tunpack(minimapDrawCall)); + if _G.QuestieDebugPins then + local data = frame and frame.data + local label = data and (data.Name or data.name or data.Title) + local questId = data and (data.Id or data.id) + if label == "Mana Wyrm" or questId == 8325 then + local point1, rel1, point2, xOff, yOff = frame:GetPoint() + print(string.format( + "[QD] ProcessQueue minimap frame=%s label=%s quest=%s shown=%s hidden=%s parent=%s point=(%s,%s,%s,%s,%s)", + tostring(frame:GetName()), + tostring(label), + tostring(questId), + tostring(frame:IsShown()), + tostring(frame.hidden), + tostring(frame:GetParent() and frame:GetParent():GetName() or frame:GetParent()), + tostring(point1), + tostring(rel1 and rel1.GetName and rel1:GetName() or rel1), + tostring(point2), + tostring(xOff), + tostring(yOff) + )) + end + end QuestieMap.utils:SetDrawOrder(frame); end @@ -502,7 +571,7 @@ function QuestieMap:DrawManualIcon(data, areaID, x, y, typ) iconMinimap.texture:SetVertexColor(colorsMinimap[1], colorsMinimap[2], colorsMinimap[3], 1); iconMinimap.miniMapIcon = true; - QuestieMap:QueueDraw(QuestieMap.ICON_MINIMAP_TYPE, Questie, iconMinimap, iconMinimap.UiMapID, x / 100, y / 100, true, true); + QuestieMap:QueueDraw(QuestieMap.ICON_MINIMAP_TYPE, Questie, iconMinimap, iconMinimap.UiMapID, x / 100, y / 100, true, iconMinimap.UiMapID ~= 1241); tinsert(QuestieMap.manualFrames[typ][data.id], iconMinimap:GetName()) if (not Questie.db.profile.enabled) then @@ -561,7 +630,7 @@ function QuestieMap:DrawWorldIcon(data, areaID, x, y, showFlag) return nil, nil end - local floatOnEdge = true + local floatOnEdge = uiMapId ~= 1241 ---@type IconFrame local iconMap = QuestieFramePool:GetFrame()