I have been working on a lightweight AddOn to perform some fairly simple modifications to the WorldMapFrame. I am running into issues with the WorldMapFrame tainting when it is opened in combat. I attempted to code my AddOn in such a way that the map won't be touched until combat is dropped, but it is still tainting. Would you guys look over my code and give me some advice?

Lua Code:

-- Local definitions

local hooksecurefunc = hooksecurefunc -- I don't know if this acctually helps, I just want to be cool =[

local mapScale =0.60-- Map scale for easy modification

-- Nevcariel's function for fixing the scale of dropdown menus parented to the WorldMapFrame.

localfunction dropdownScaleFix(self)

ToggleDropDownMenu(nil, nil, self:GetParent())

DropDownList1:SetScale(mapScale)

end

localfunction onShow()

WorldMapFrame:SetScale(mapScale)

end

localfunction sizeDown()

WorldMap_ToggleSizeUp()

end

localfunction sizeUp()

WorldMapFrame:SetAttribute("UIPanelLayout-area", "center")

BlackoutWorld:Hide()

WorldMapFrame:EnableKeyboard(false)

WorldMapFrame:EnableMouse(false)

end

localfunction modifyMap()

if eventHandler then eventHandler:UnregisterEvent("PLAYER_REGEN_ENABLED")end

if not InCombatLockdown() then
modifyMap()
else
local eventHandler = CreateFrame("Frame")
eventHandler:SetScript("OnEvent", modifyMap)
eventHandler:RegisterEvent("PLAYER_REGEN_ENABLED")
end

... I can't conditionally create the frame?

You can, but here's the thing -- that block of code is only read and executed once, when your addon loads. Since you are never considered InCombatLockdown() when your addon's files are first being read and executed, your code is modifying the map once, and never creating a frame.

You should just be able to call the modifyMap function in the main chunk, instead of that whole do-end block at the end of your code (containing the above) since, again, InCombatLockdown() is never true when non-LoD addons are initially read.

Also, upvaluing hooksecurefunc is pointless. The purpose of upvaluing global functions is to speed up access time, but the speed-up is so minute that it's only useful for functions that are potentially called hundreds of times per second inside an OnUpdate handler or COMBAT_LOG_EVENT_UNFILTERED event handler. For a function that you call once or twice during the loading process, the upvalue is just a (granted, minute) waste of disk space and memory.

As for the taint problem, I don't really know, but my first guess would be related to the dropdown menu stuff, since the dropdown menu system is basically a house of cards in a dark basement. Try using a secure post-hook instead:

Code:

local function dropdownScaleFix(self)
- ToggleDropDownMenu(nil, nil, self:GetParent())+ if DropDownList1:IsVisible() then
DropDownList1:SetScale(mapScale)
+ end
end

I see the the DropDownMenu is being tainted, but there are also other aspects of the map that are being tainted. As for the DropDownMenu, I am grabbing that directly from Mapster(Thanks Nev <.<), and I don't ever recall Mapster producing any issues -- and further more, how will I make any changes to the map if it just breaks in combat?

I have seen taint errors from Mapster when opening the map in combat, though it's pretty rare.

Do you get the same errors when your world map addon is the only addon enabled?

Other than that, try just doing SetScale and SetAttribute once when you load, instead of every time the map is shown. I'm not sure why you'd need to repeat them. SetAttribute in particular is likely to have issues in combat.

So I have done some work on my map mod, and I've got it producing no taint at all. The only issue I am running into is that to set the scale for the WorldMapFrame, it has to be done OnShow, and to avoid taint, I have to use a combat lockdown function to handle scaling the map OnShow, so if the map is opened in combat, it doesn't taint, but the scale is wrong.

Is there any way to set the scale of the map permanently? Even doing:

Lua Code:

/run WorldMapFrame:SetScale(0.60)

doesn't affect the scale of the world map, unless run when the frame is opened.

I was able to achieve the desired goal...in a bit of a round-about fashion. I did some investigating as to what would cause the WorldMapFrame's scale to reset to 1 every time it is shown, and I noticed that it doesn't have a parent frame, which I thought was interesting. I tried parenting it to UIParent as a test, and voila, it inherited UIParent's scale.

I was able to manage the scale of the frame, without having to hook the OnShow function, by creating my own frame, setting that frame's scale, and parenting the WorldMapFrame to it. I'd like to not have to create my own frame just to handle the scaling, so if anyone has any insight, I'd greatly appreciate it.