Files
pfUI/modules/mapreveal.lua
T
roby-brok e017dbf515 Fix guards, cache keys and comparisons that never match (#40)
* chat: detect whispers before the timestamp is prepended

Whisper detection tests for the whisper colour code at position 1, but the
timestamp is prepended first, so with timestamps enabled the code is no longer
at position 1 and every whisper failed the test -- losing both the recolour and
the correct chat-history entry.

(cherry picked from commit 4b69d597631c422d9360a94ff129323288a28cc2)

* macrotweak + libpredict: inverted install guard, misspelled globals

macrotweak: _AddHistoryLine is the backup slot this block creates, so it is nil
until line 18 runs. Guarding on its truthiness meant the chat-history filter
never installed at all -- macro calls kept landing in chat input history.

libpredict: UKNOWNBEING / UNKOWNBEING are misspelled, so both resolve to nil and
the guards never matched the real UNKNOWNBEING. Neutral if the global is absent
on this client, correct if present.

Not needed: his libpredict already fixed the always-true
'event == "A" or "B"' condition (libs/libpredict.lua:828).

(cherry picked from commit 4068110dc4134823f1c09f60ca5f8959302cd14f)

* mapreveal: look the explore cache up by the key it is actually stored under

explorecaches is keyed by the plain area name (line ~160), but the hover frame
carried only a decorated 'mapFileName (area)' display string, so every lookup
missed and the hover highlight never fired. Store the plain name alongside it
and key off that; the tooltip keeps the decorated string.

(cherry picked from commit 5e6fe969a03a88c68e28614548b9d44db562ab9a)

* socialmod: don't clobber the friend-online match with the offline one

The offline match was assigned unconditionally over the online match, so a
friend coming online never had lastseen recorded.

(cherry picked from commit ad927806c46042163f84bde4db1082726bedf28b)

* swingtimer: off-hand weapons are inventory type 22, not 21

The off-hand slot accepts one-hand (13) and off-hand (22) weapons. Type 21 is
INVTYPE_WEAPONMAINHAND and can never be equipped there, so the off-hand swing
timer never recognised a real off-hand weapon.

The other two swingtimer fixes are not needed here: his hunter check already
uses UnitClassBase (locale-independent, better than our UnitClass second
return), and his generic on-next-swing detection covers Raptor Strike without
our hardcoded spell-id list.

(cherry picked from commit 9ab7f5f7224d12361ca6cd5a49181cbb4bebd387)

* superwow: compare the version numerically, not by exact string

SUPERWOW_VERSION == "1.5" silently disables the GUID-to-name combat text hook
on any release past 1.5. Currently 1.5 here, so this is forward-compat only.

Not needed: the clickthrough slash commands already go through
RegisterSlashCommand, which writes _G properly.

(cherry picked from commit 82a37752a5782479849ce7e1304c24733c2ff97a)

* api: measure a real pixel against UIParent, not the uiScale cvar

The uiScale cvar caps at 1.0 while both the pixelperfect module and the
firstrun slider push UIParent past it via SetScale, and it is ignored entirely
while useUiScale is off, so borders came out the wrong thickness on the
Huge/Large presets. Ask the frame for its effective scale instead, and guard an
unparseable gxResolution.

Also cache GetItemLinkByName and count its failures: the scan walked every id
on each call with no memory, so an unresolvable name hitched on every tooltip
hover. Raise the ceiling from 25818 to 61000 as well -- Octo/Turtle custom
items live well past the vanilla range and never resolved.

(cherry picked from commit dac2d3416aef85a4c4b71c0239d93d309e76e30b)

* init: load pixelperfect first so GetPerfectPixel caches the right scale

pixelperfect sets the UI scale that GetPerfectPixel measures against, and that
value is cached on first use. Loading it 56th baked in the previous scale.

(cherry picked from commit dd89a210330583f890a51a82b29e968f3ad36b34)

* modules: route two global overrides through _G so they leave the sandbox

pfUI.env has __index but no __newindex, so a bare global assignment inside a
RegisterModule closure is written into the sandbox table and never reaches _G.
unitxp's BattlefieldFrame_Show override therefore never fired the BG queue-pop
notification, and RaidFrame.lua never saw GROUP_REPLACE_PARTY.

The slash-command half of this fix is not needed here: RegisterSlashCommand
already writes through _G.

(cherry picked from commit 617c8320aca2465af62cf0ff5be7dceaed29a3b2)

* bags: remove the duplicate search OnHide handler

Two byte-identical frame.search OnHide handlers were installed back to back;
the second overwrote the first, so the first was dead code.

(cherry picked from commit e77650448b92e5d7f18ae58632e4531cb2813ea6)

* buffwatch: invalidate the filter cache when a skill is listed

fcache is built once per config table and never cleared, so ctrl/shift-clicking
a skill onto the whitelist or blacklist had no effect until the next reload.

* roll: actually capture the everyone-passed subject

strfind(LOOT_ROLL_ALL_PASSED, LOOT_ROLL_PASSED) has no captures, so `everyone`
was always nil, never reached the blacklist, and "Everyone has passed on: X"
was recorded as a real player passing.

Builds a sample from LOOT_ROLL_ALL_PASSED and runs the same LOOT_ROLL_PASSED
match the scanner uses, so the subject is captured the way it will actually
appear.
2026-08-10 01:13:32 -05:00

179 lines
6.7 KiB
Lua

pfUI:RegisterModule("mapreveal", function ()
if Cartographer then return end
if METAMAP_TITLE then return end
pfUI.mapreveal = {}
function pfUI.mapreveal:UpdateConfig()
WorldMapFrame_Update()
end
pfUI.mapreveal.onmap = CreateFrame("CheckButton", "pfUI_mapreveal_onmap", WorldMapFrame, "UICheckButtonTemplate")
pfUI.mapreveal.onmap:SetNormalTexture("")
pfUI.mapreveal.onmap:SetPushedTexture("")
pfUI.mapreveal.onmap:SetHighlightTexture("")
pfUI.mapreveal.onmap.text = _G["pfUI_mapreveal_onmapText"]
CreateBackdrop(pfUI.mapreveal.onmap, nil, true)
pfUI.mapreveal.onmap:SetWidth(14)
pfUI.mapreveal.onmap:SetHeight(14)
pfUI.mapreveal.onmap:SetPoint("LEFT", WorldMapZoomOutButton, "RIGHT", 20, 0)
pfUI.mapreveal.onmap.text:SetPoint("LEFT", pfUI.mapreveal.onmap, "RIGHT", 2, 0)
pfUI.mapreveal.onmap.text:SetText(T["Reveal Unexplored Areas"])
pfUI.mapreveal.onmap:SetScript("OnShow", function()
this:SetChecked(C.appearance.worldmap.mapreveal == "1")
end)
pfUI.mapreveal.onmap:SetScript("OnClick", function ()
if this:GetChecked() then
C.appearance.worldmap.mapreveal = "1"
else
C.appearance.worldmap.mapreveal = "0"
end
pfUI.mapreveal:UpdateConfig()
end)
local explores = {}
local explorecaches = {}
local alreadyknown = {} -- per-zone accumulator: { [zone] = { [texName] = true } }
-- Own texture pool - separate from Blizzard's WorldMapOverlay textures
local pfOverlays = {}
local pfOverlayMax = 0
local function pfGetOverlay(idx)
if not pfOverlays[idx] then
pfOverlays[idx] = WorldMapDetailFrame:CreateTexture("pfReveal"..idx, "BORDER")
end
return pfOverlays[idx]
end
local exploreEnter = function()
WorldMapTooltip:ClearLines()
WorldMapTooltip:SetOwner(this, "ANCHOR_TOP")
WorldMapTooltip:AddLine(T["Exploration Point"]..":", .3, 1, .8)
WorldMapTooltip:AddLine(this.name, 1, 1, 1)
WorldMapTooltip:Show()
if not explorecaches[this.area] then return end
if C.appearance.worldmap.mapreveal == "0" then return end
for texture in pairs(explorecaches[this.area]) do
texture:SetVertexColor(1,1,1,1)
end
end
local exploreLeave = function()
WorldMapTooltip:Hide()
if not explorecaches[this.area] then return end
if C.appearance.worldmap.mapreveal == "0" then return end
local r,g,b,a = GetStringColor(C.appearance.worldmap.mapreveal_color)
for texture in pairs(explorecaches[this.area]) do
texture:SetVertexColor(r,g,b,a)
end
end
local function pfWorldMapFrame_Update()
-- clear stale caches
for k in pairs(explorecaches) do explorecaches[k] = nil end
-- hide all our textures from last frame
for i = 1, pfOverlayMax do
pfOverlays[i]:Hide()
end
local r,g,b,a = GetStringColor(C.appearance.worldmap.mapreveal_color)
local mapFileName = GetMapInfo()
if not mapFileName then mapFileName = "World" end
local numOverlays = GetNumMapOverlays()
-- accumulate explored overlays per zone (never clear, only add)
if not alreadyknown[mapFileName] then alreadyknown[mapFileName] = {} end
for i = 1, numOverlays do
local texName = GetMapOverlayInfo(i)
if texName then alreadyknown[mapFileName][string.upper(texName)] = true end
end
local zoneKnown = alreadyknown[mapFileName]
-- hide explore icons
for _, frame in pairs(explores) do frame:Hide() end
-- ClassicAPI: full overlay list for the viewed zone (explored + unexplored),
-- read straight from WorldMapOverlay.dbc. Replaces the hand-measured pfMapOverlayData.
local zoneData = C_Map.GetMapOverlays() or {}
local textureCount = 0
for i, overlay in ipairs(zoneData) do
local name = overlay.textureName -- bare, e.g. "DRYGULCHRAVINE"
local textureName = overlay.texturePath -- full engine path (for SetTexture)
local textureWidth = overlay.textureWidth
local textureHeight = overlay.textureHeight
local offsetX = overlay.offsetX
local offsetY = overlay.offsetY
-- explore magnifying glass icon
explores[i] = explores[i] or CreateFrame("Frame", nil, WorldMapDetailFrame)
local explore = explores[i]
explore:SetWidth(16)
explore:SetHeight(16)
explore:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", offsetX + textureWidth/2, -offsetY - textureHeight/2)
explore:SetScript("OnEnter", exploreEnter)
explore:SetScript("OnLeave", exploreLeave)
explore:EnableMouse(true)
explore:SetFrameLevel(255)
explore.name = mapFileName .. " (" .. name .. ")"
explore.area = name -- cache key: explorecaches is keyed by the plain area name
explore.tex = explore.tex or explore:CreateTexture("", "OVERLAY")
explore.tex:SetBlendMode("ADD")
explore.tex:SetTexCoord(.08, .92, .08, .92)
explore.tex:SetAllPoints()
-- `alreadyknown` stores the FULL paths GetMapOverlayInfo returns,
-- so compare with the full path, not the bare name.
if C.appearance.worldmap.mapexploration == "1" and not zoneKnown[string.upper(textureName)] then
explore.tex:SetTexture("Interface\\WorldMap\\WorldMap-MagnifyingGlass")
explore:Show()
else
explore:Hide()
end
-- render overlay texture tiles on BORDER draw layer
-- Blizzard's explored overlays on ARTWORK draw on top of BORDER
--
-- overlay.tiles is pre-resolved by ClassicAPI: per-tile file /
-- draw size / texcoords / canvas position, with Octo's data
-- quirks (sliver columns the DBC rect rounds away, foreign tiles
-- appended to the number sequence, upscaled re-exports) already
-- disambiguated from the actual BLP dimensions. No 256px grid
-- math here — deriving the grid from textureWidth/Height is
-- exactly what shears quirky overlays (e.g. Icepoint's Kaneq'nuun).
if C.appearance.worldmap.mapreveal == "1" then
for _, tile in ipairs(overlay.tiles) do
textureCount = textureCount + 1
local tex = pfGetOverlay(textureCount)
tex:SetWidth(tile.width)
tex:SetHeight(tile.height)
tex:SetTexCoord(0, tile.texCoordX, 0, tile.texCoordY)
tex:ClearAllPoints()
tex:SetPoint("TOPLEFT", "WorldMapDetailFrame", "TOPLEFT", tile.offsetX, -tile.offsetY)
tex:SetTexture(tile.file)
explorecaches[name] = explorecaches[name] or {}
explorecaches[name][tex] = true
tex:SetVertexColor(r,g,b,a)
tex:Show()
end
end
end
pfOverlayMax = math.max(pfOverlayMax, textureCount)
end
-- hook WorldMapFrame_Update
local origUpdate = _G.WorldMapFrame_Update
_G.WorldMapFrame_Update = function(...)
origUpdate(unpack(arg))
pfWorldMapFrame_Update()
end
end)