Skip to content

Commit

Permalink
Fixes hangups when an unknown itemID is imported. (e.g. typo in CSV)
Browse files Browse the repository at this point in the history
  • Loading branch information
dieck committed Jul 1, 2020
1 parent 0748db4 commit bebf8d0
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Prio3.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: Prio3
## Notes: Loot notification for Priority Loot system. Can use export from Sahne-Team.de website
## Author: dieck
## Version: 0.1
## Version: 20200701
## SavedVariables: Prio3DB


Expand Down
50 changes: 33 additions & 17 deletions core.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Prio3 = LibStub("AceAddon-3.0"):NewAddon("Prio3", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0","AceComm-3.0", "AceSerializer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Prio3", true)
local commPrefix = "Prio3-1.0-"
local versionString = "v20200626"
local versionString = "v20200701"

local defaults = {
profile = {
Expand Down Expand Up @@ -29,6 +29,8 @@ local onetimenotifications = {}
local addon_id = 0;

GET_ITEM_INFO_RECEIVED_TodoList = {}
GET_ITEM_INFO_RECEIVED_NotYetReady = {}
GET_ITEM_INFO_RECEIVED_IgnoreIDs = {}
-- format: { { needed_itemids={}, vars={}, todo=function(itemids,vars) }, ... }

GET_ITEM_INFO_Timer = nil
Expand Down Expand Up @@ -881,21 +883,30 @@ function Prio3:GET_ITEM_INFO_RECEIVED(event, itemID, success)

-- don't fire on Every event. Give it 2 seconds to catch up
if GET_ITEM_INFO_Timer == nil then
GET_ITEM_INFO_Timer = self:ScheduleTimer("GET_ITEM_INFO_RECEIVED_DelayedHandler", 2)
GET_ITEM_INFO_Timer = self:ScheduleTimer("GET_ITEM_INFO_RECEIVED_DelayedHandler", 2, event, itemID, success)
end
end


function Prio3:GET_ITEM_INFO_RECEIVED_DelayedHandler()
function Prio3:GET_ITEM_INFO_RECEIVED_DelayedHandler(event, itemID, success)
-- reset marker, so new GET_ITEM_INFO_RECEIVED will fire this up again (with 2 seconds delay)
GET_ITEM_INFO_Timer = nil

-- don't fire on Every event. Give it 2 seconds to catch up

t = time()

-- ignore items after a time of 10sec
for id,start in pairs(GET_ITEM_INFO_RECEIVED_NotYetReady) do
if t > start+10 then
Prio3:Print(L["Waited 10sec for itemID id to be resolved. Giving up on this item."](id))
GET_ITEM_INFO_RECEIVED_NotYetReady[id] = nil
GET_ITEM_INFO_RECEIVED_IgnoreIDs[id] = t
end
end

-- this event gets a lot of calls, so debug is very chatty here
-- only configurable in code therefore

local debug = false

for todoid,todo in pairs(GET_ITEM_INFO_RECEIVED_TodoList) do

if debug then Prio3:Print("GET_ITEM_INFO_RECEIVED for " .. itemID); end
Expand All @@ -906,17 +917,22 @@ function Prio3:GET_ITEM_INFO_RECEIVED_DelayedHandler()

-- search for all needed IDs
for dummy,looking_for_id in pairs(todo["needed_itemids"]) do
if tonumber(looking_for_id) > 0 then
if debug then Prio3:Print("Tying to get ID " .. looking_for_id); end
local itemName, itemLink = GetItemInfo(looking_for_id)
if itemLink then
if debug then Prio3:Print("Found " .. looking_for_id .. " as " .. itemLink); end
table.insert(itemlinks, itemLink)
else
if debug then Prio3:Print("Not yet ready: " .. looking_for_id); end
foundAllIDs = false
end
end
if GET_ITEM_INFO_RECEIVED_IgnoreIDs[looking_for_id] == nil then

if tonumber(looking_for_id) > 0 then
if debug then Prio3:Print("Tying to get ID " .. looking_for_id); end
local itemName, itemLink = GetItemInfo(looking_for_id)
if itemLink then
if debug then Prio3:Print("Found " .. looking_for_id .. " as " .. itemLink); end
table.insert(itemlinks, itemLink)
else
if debug then Prio3:Print("Not yet ready: " .. looking_for_id); end
if GET_ITEM_INFO_RECEIVED_NotYetReady[looking_for_id] == nil then GET_ITEM_INFO_RECEIVED_NotYetReady[looking_for_id] = t end
foundAllIDs = false
end
end -- tonumber

end -- ignore
end

if (foundAllIDs) then
Expand Down
1 change: 1 addition & 0 deletions locale-deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ L["Enters Debug mode. Addon will have advanced output, and work outside of Raid"
L["You will need to /roll when item is up."] = "Du wirst darum /würfeln müssen wenn das Item verteilt wird."
L["itemlink dropped. You have this on priority x."] = function (itemLink, prio) return itemLink .. " ist gedroppt. Du hast das auf Priorät " .. prio .. "." end
L["Priorities of username: list"] = function(username,itemLinks) return "Prioritäten für " .. username .. ": " .. itemLinks end
L["Waited 10sec for itemID id to be resolved. Giving up on this item."] = function(id) return "Habe 10sek gewartet auf itemID " .. id .. ". Gebe es jetzt auf." end

L["Query own priority"] = "Suche eigene Priorität"
L["Allows to query own priority. Whisper prio."] = "Erlaubt die Abfrage eigener Prioritäten. Flüstere prio."
Expand Down
1 change: 1 addition & 0 deletions locale-enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ L["Enters Debug mode. Addon will have advanced output, and work outside of Raid"
L["You will need to /roll when item is up."] = "You will need to /roll when item is up."
L["itemlink dropped. You have this on priority x."] = function (itemLink, prio) return itemLink .. " dropped. You have this on priority " .. prio .. "." end
L["Priorities of username: list"] = function(username,itemLinks) return "Priorities of " .. username .. ": " .. itemLinks end
L["Waited 10sec for itemID id to be resolved. Giving up on this item."] = function(id) return "Waited 10sec for itemID " .. id .. " to be resolved. Giving up on this item." end

L["Query own priority"] = "Query own priority"
L["Allows to query own priority. Whisper prio."] = "Allows to query own priority. Whisper prio."
Expand Down
149 changes: 98 additions & 51 deletions loot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,43 @@ function Prio3:createPriorityFrame()
lbPlayerName:SetRelativeWidth(0.24)
s:AddChild(lbPlayerName)


if tonumber(prios[1]) > 0 then
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(prios[1])

local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage(itemTexture)
lbIcon:SetImageSize(15,15)
lbIcon:SetCallback("OnEnter", function(widget)
GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
GameTooltip:SetHyperlink(itemLink)
GameTooltip:Show()
end)
lbIcon:SetCallback("OnLeave", function(widget)
GameTooltip:Hide()
end)
s:AddChild(lbIcon)
if itemLink then
local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage(itemTexture)
lbIcon:SetImageSize(15,15)
lbIcon:SetCallback("OnEnter", function(widget)
GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
GameTooltip:SetHyperlink(itemLink)
GameTooltip:Show()
end)
lbIcon:SetCallback("OnLeave", function(widget)
GameTooltip:Hide()
end)
s:AddChild(lbIcon)

local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText(itemLink)
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)
local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText(itemLink)
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)
else

local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage("Interface\\Icons\\ability_vanish")
lbIcon:SetImageSize(15,15)
s:AddChild(lbIcon)

local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText("-ERROR: ID-")
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)

end
else
local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
Expand All @@ -127,24 +143,40 @@ function Prio3:createPriorityFrame()
if tonumber(prios[2]) > 0 then
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(prios[2])

local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage(itemTexture)
lbIcon:SetImageSize(15,15)
lbIcon:SetCallback("OnEnter", function(widget)
GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
GameTooltip:SetHyperlink(itemLink)
GameTooltip:Show()
end)
lbIcon:SetCallback("OnLeave", function(widget)
GameTooltip:Hide()
end)
s:AddChild(lbIcon)
if itemLink then
local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage(itemTexture)
lbIcon:SetImageSize(15,15)
lbIcon:SetCallback("OnEnter", function(widget)
GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
GameTooltip:SetHyperlink(itemLink)
GameTooltip:Show()
end)
lbIcon:SetCallback("OnLeave", function(widget)
GameTooltip:Hide()
end)
s:AddChild(lbIcon)

local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText(itemLink)
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)
else

local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage("Interface\\Icons\\ability_vanish")
lbIcon:SetImageSize(15,15)
s:AddChild(lbIcon)

local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText("-ERROR: ID-")
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)

end

local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText(itemLink)
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)
else
local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
Expand All @@ -162,24 +194,39 @@ function Prio3:createPriorityFrame()

local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(prios[3])

local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage(itemTexture)
lbIcon:SetImageSize(15,15)
lbIcon:SetCallback("OnEnter", function(widget)
GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
GameTooltip:SetHyperlink(itemLink)
GameTooltip:Show()
end)
lbIcon:SetCallback("OnLeave", function(widget)
GameTooltip:Hide()
end)
s:AddChild(lbIcon)
if itemLink then
local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage(itemTexture)
lbIcon:SetImageSize(15,15)
lbIcon:SetCallback("OnEnter", function(widget)
GameTooltip:SetOwner(widget.frame, "ANCHOR_TOPRIGHT")
GameTooltip:SetHyperlink(itemLink)
GameTooltip:Show()
end)
lbIcon:SetCallback("OnLeave", function(widget)
GameTooltip:Hide()
end)
s:AddChild(lbIcon)

local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText(itemLink)
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)
local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText(itemLink)
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)
else

local lbIcon = AceGUI:Create("Icon")
lbIcon:SetRelativeWidth(0.04)
lbIcon:SetImage("Interface\\Icons\\ability_vanish")
lbIcon:SetImageSize(15,15)
s:AddChild(lbIcon)

local lbPrio = AceGUI:Create("InteractiveLabel")
lbPrio:SetText("-ERROR: ID-")
lbPrio:SetRelativeWidth(0.20)
s:AddChild(lbPrio)

end

else
local lbIcon = AceGUI:Create("Icon")
Expand Down

0 comments on commit bebf8d0

Please sign in to comment.