
[cata classic] v11.1.0.3 pin error
Closed this issue ยท 4 comments
I get error spam to the tune of
30x ...Ons/MinimalArchaeology/addon/components/Digsites.lua:1020: attempt to index local 'pin' (a nil value)
[string "@MinimalArchaeology/addon/components/Digsites.lua"]:1020: in function `ShowRaceIconsOnMap'
[string "@MinimalArchaeology/addon/core/Events.lua"]:153: in function `EventMain'
[string "@MinimalArchaeology/addon/components/Main.lua"]:175: in function <MinimalArchaeology/addon/components/Main.lua:174>
Locals:
self = <table> {
wpButton = MinArchDigsitesAutoWayButton {
}
showAfterCombat = false
frame = MinArchDigsites {
}
}
uiMapID = 1439
count = 0
(for state) = <table> {
1 = <table> {
}
2 = <table> {
}
}
(for control) = 1
key = 1
digsite = <table> {
researchSiteID = 299
name = "Jaedenar Digsite"
position = <table> {
}
textureIndex = 177
poiBlobID = 56347
}
pin = nil
(*temporary) = 1.200000
(*temporary) = "Jaedenar Digsitepin"
(*temporary) = "pin"
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = <table> {
}
(*temporary) = nil
(*temporary) = "attempt to index local 'pin' (a nil value)"
SpamBlock = <table> {
Jaedenar Digsitepin = 1
}
Common = <table> {
}
when zoning into Uldum from Stormwind portal
Taking a quick look through interface code I think I see where the problem is.
pins do not draw (or initialize data) on the DigSitePinTemplate
unless your map is zoomed out to the continent level.
Zooming into the zone level means that your WorldMapFrame:EnumeratePinsByTemplate("DigSitePinTemplate")
returns nothing / nil.
You'll probably refactor this to something following the addon structure (I can see a compatibility layer in shared\Common
where some of that code would probably be moved to, but for the purpose of illustration something like this seems to fix the immediate problem
*Another option would be to "blindly" iterate both types of pinTemplates in AquirePin
and return from whichever is populated.
Changing :ShowRaceIconsOnMap()
to something like
local mapType = C_Map.GetMapInfo(uiMapID) and C_Map.GetMapInfo(uiMapID).mapType
for key, digsite in pairs(C_ResearchInfo.GetDigSitesForMap(uiMapID)) do
local pin = AcquireMapPin(digsite.name, mapType);
if not SpamBlock[digsite.name .. 'pin'] and (not pin) then
Common:DisplayStatusMessage("Minimal Archaeology: Could not find pin for digsite "..digsite.name .. " " .. uiMapID)
SpamBlock[digsite.name .. 'pin'] = 1
return
end
and AquireMapPin
to
local function AcquireMapPin(nodeName, mapType)
local pinTemplate
if mapType == Enum.UIMapType.Continent then
pinTemplate = "DigSitePinTemplate"
elseif mapType == Enum.UIMapType.Zone then
pinTemplate = "DigSiteBlobPinTemplate"
end
if pinTemplate then
for pin in WorldMapFrame:EnumeratePinsByTemplate(pinTemplate) do
if pin.name == nodeName then
return pin
end
end
end
end
stops the error at least.
The reason this doesn't work as is originally is because of this block in DigSiteDataProvider (Blizzard)
if(self:IsZoneMapType()) then
-- Only use blob pins if we are zoomed into a zone on the world map
local pin = self:GetMap():AcquirePin("DigSiteBlobPinTemplate", digSiteInfo);
pin.digSiteInfo = digSiteInfo;
pin:SetMapID(mapID);
else
-- Create shovel icon pin
self:GetMap():AcquirePin("DigSitePinTemplate", digSiteInfo);
end
Thanks for reporting this. Should be fixed in v11.1.0.4.
I noticed some loss of functionality with the new method so I ended up using my previous method for acquiring pins on Cata, since it doesn't seem to be causing the taint on Cata that was happening on Mainline.
Please feel free to reopen this issue if you encounter any errors after this update.