Query completed quests from the server instead of keeping a database
Adrian L Lange [02-05-12 - 14:50]
Query completed quests from the server instead of keeping a database
diff --git a/Monomyth.lua b/Monomyth.lua
index 6a8555a..e8abdfe 100644
--- a/Monomyth.lua
+++ b/Monomyth.lua
@@ -142,19 +142,27 @@ Monomyth:Register('BANKFRAME_CLOSED', function()
atBank = false
end)
+local completedQuests = {}
+Monomyth:Register('QUEST_QUERY_COMPLETE', function()
+ GetQuestsCompleted(completedQuests)
+
+ for index = 0, 4 do
+ Monomyth.BAG_UPDATE(index)
+ end
+end)
+
Monomyth:Register('BAG_UPDATE', function(bag)
if(bag < 0) then return end
if(atBank) then return end
- QuestCompletedDB = QuestCompletedDB or {}
-
for slot = 1, GetContainerNumSlots(bag) do
local _, id, active = GetContainerItemQuestInfo(bag, slot)
- if(id and not active and not QuestCompletedDB[id]) then
- UseContainerItem(bag, slot)
-
- -- This is a temporary solution to the spam and bugs with some items
- QuestCompletedDB[id] = true
+ if(id and not active) then
+ if(not next(completedQuests)) then
+ QueryQuestsCompleted()
+ elseif(not completedQuests[id]) then
+ UseContainerItem(bag, slot)
+ end
end
end
end)
diff --git a/Monomyth.toc b/Monomyth.toc
index fdc9241..9993454 100644
--- a/Monomyth.toc
+++ b/Monomyth.toc
@@ -3,6 +3,5 @@
## Version: Alpha
## Title: Monomyth
## Notes: Questing enhancements
-## SavedVariablesPerCharacter: QuestCompletedDB
Monomyth.lua