Quantcast

Possible fix to the disconnects

Adrian L Lange [05-17-11 - 22:36]
Possible fix to the disconnects
Filename
Monomyth.lua
diff --git a/Monomyth.lua b/Monomyth.lua
index 3579042..d234d8a 100644
--- a/Monomyth.lua
+++ b/Monomyth.lua
@@ -1,6 +1,7 @@
 local addon = CreateFrame('Frame')
 addon:SetScript('OnEvent', function(self, event, ...) self[event](...) end)

+local CURRENT
 local COMPLETE = [=[Interface\GossipFrame\ActiveQuestIcon]=]

 function addon:Register(event, func)
@@ -51,6 +52,10 @@ addon:Register('QUEST_DETAIL', function()
 	else
 		QuestFrame_OnEvent(nil, 'QUEST_DETAIL')
 		AcceptQuest()
+
+		if(GetQuestID() == CURRENT) then
+			addon:RegisterEvent('BAG_UPDATE')
+		end
 	end
 end)

@@ -104,9 +109,9 @@ addon:Register('BAG_UPDATE', function(bag)
 	for slot = 1, GetContainerNumSlots(bag) do
 		local _, id, active = GetContainerItemQuestInfo(bag, slot)
 		if(id and not active) then
-			-- We should check if the item is cached yet
-			-- The negative result of this is a disconnect
+			CURRENT = id
 			UseContainerItem(bag, slot)
+			addon:UnregisterEvent('BAG_UPDATE')
 		end
 	end
 end)