@@ -3,12 +3,37 @@ local _, br = ...
33br .engines .questTracker = br .engines .questTracker or {}
44local questTracker = br .engines .questTracker
55questTracker .cache = questTracker .cache or {}
6+ questTracker .objectCheckCache = questTracker .objectCheckCache or {} -- Cache for already-checked objects
67
78-- Quest stuff
89-- local questPlateTooltip = CreateFrame('GameTooltip', 'QuestPlateTooltip', nil, 'GameTooltipTemplate')
910local questTooltipScanQuest = br ._G .CreateFrame (" GameTooltip" , " QuestPlateTooltipScanQuest" , nil , " GameTooltipTemplate" )
1011local ScannedQuestTextCache = {}
1112
13+ -- Helper function to add name variations to cache (called during cache build)
14+ local function addNameVariations (name , cache )
15+ if not name or # name < 3 then return end
16+
17+ -- Add the original name
18+ cache [name ] = true
19+
20+ -- Add plural variation (add 's')
21+ cache [name .. " s" ] = true
22+
23+ -- Add plural variation (add 'es')
24+ cache [name .. " es" ] = true
25+
26+ -- If name ends in 's', add singular
27+ if name :sub (- 1 ) == " s" then
28+ cache [name :sub (1 , - 2 )] = true
29+ end
30+
31+ -- If name ends in 'es', add singular
32+ if name :sub (- 2 ) == " es" then
33+ cache [name :sub (1 , - 3 )] = true
34+ end
35+ end
36+
1237function questTracker :isQuestUnit (Pointer )
1338 local guid
1439 if not br ._G [" lb" ] then
@@ -77,8 +102,9 @@ local QuestCacheUpdate = function()
77102 [57008 ] = true , -- Assault The Warring Clans
78103 [57728 ] = true , --- Assault: The Endless Swarm
79104 }
80- -- clear the quest cache
105+ -- clear the quest cache and object check cache
81106 br ._G .wipe (br .engines .questTracker .cache )
107+ br ._G .wipe (br .engines .questTracker .objectCheckCache )
82108
83109 -- do not update if is inside an instance
84110 local isInInstance = br ._G .IsInInstance ()
@@ -95,21 +121,74 @@ local QuestCacheUpdate = function()
95121 -- local title = questInfo["title"]
96122 -- local questId = questInfo["questID"]
97123 if (type (questId ) == " number" and questId > 0 and ignoreQuest [questId ] == nil ) then -- and not isComplete
98- br .engines .questTracker .cache [title ] = true
124+ -- Cache the quest title with variations
125+ addNameVariations (title , br .engines .questTracker .cache )
126+
127+ -- Also cache quest objectives (units/objects to kill/collect)
128+ local numObjectives = br ._G .GetNumQuestLeaderBoards (questIdx )
129+ if numObjectives and numObjectives > 0 then
130+ for objIdx = 1 , numObjectives do
131+ local objectiveText , objectiveType , finished = br ._G .GetQuestLogLeaderBoard (objIdx , questIdx )
132+ if objectiveText and not finished then
133+ -- Debug: Print the full objective text to see what we're working with
134+ -- br._G.print("[QuestTracker] Objective: " .. tostring(objectiveText))
135+
136+ -- Extract the objective name from text like "Kill Murlocs: 5/10" or "Collect Apples: 3/5"
137+ -- Pattern matches: "ObjectiveName: number/number" or "ObjectiveName slain: number/number"
138+ local objectiveName = objectiveText :match (" ^(.-):%s*%d" ) or objectiveText :match (" ^(.-)%s+slain:%s*%d" )
139+ if objectiveName then
140+ -- Clean up the name and cache it with variations
141+ objectiveName = br ._G .strtrim (objectiveName )
142+ addNameVariations (objectiveName , br .engines .questTracker .cache )
143+ -- br._G.print("[QuestTracker] Cached objective name: " .. tostring(objectiveName))
144+ else
145+ -- If no pattern matched, try to cache the whole text minus progress numbers
146+ local simpleName = objectiveText :match (" ^(.-)%s*:%s*%d" ) or objectiveText :match (" ^(.-)%s+%d+/%d+" )
147+ if simpleName then
148+ simpleName = br ._G .strtrim (simpleName )
149+ addNameVariations (simpleName , br .engines .questTracker .cache )
150+ -- br._G.print("[QuestTracker] Cached simple name: " .. tostring(simpleName))
151+ end
152+ end
153+ end
154+ end
155+ end
99156 end
100157 end
101158
102159 local mapId = br ._G .C_Map .GetBestMapForUnit (" player" )
103160 if (mapId ) then
104- local worldQuests = br ._G .C_TaskQuest .GetQuestsOnMap (mapId )
161+ -- Try new API first, fallback to old API for compatibility
162+ local worldQuests = br ._G .C_TaskQuest .GetQuestsForPlayerOnMap and
163+ br ._G .C_TaskQuest .GetQuestsForPlayerOnMap (mapId ) or
164+ br ._G .C_TaskQuest .GetQuestsOnMap (mapId )
105165 if (type (worldQuests ) == " table" ) then
106166 for _ , questTable in ipairs (worldQuests ) do
107167 local questId = questTable .questId
108168 if (type (questId ) == " number" and questId > 0 and ignoreQuest [questId ] == nil ) then
109169 local questName = br ._G .C_TaskQuest .GetQuestInfoByQuestID (questId )
110- br ._G .print (" Quest Name: " .. tostring (questName ))
170+ -- Remove debug print to avoid spam
171+ -- br._G.print("Quest Name: " .. tostring(questName))
111172 if (questName ) then
112- br .engines .questTracker .cache [questName ] = true
173+ addNameVariations (questName , br .engines .questTracker .cache )
174+ end
175+
176+ -- Try to get world quest objectives
177+ local questInfo = br ._G .C_TaskQuest .GetQuestInfoByQuestID (questId )
178+ if questInfo then
179+ -- World quests might have objectives we can parse similarly
180+ local objectives = br ._G .C_QuestLog .GetQuestObjectives (questId )
181+ if objectives then
182+ for _ , objective in ipairs (objectives ) do
183+ if objective .text and not objective .finished then
184+ local objectiveName = objective .text :match (" ^(.-):%s*%d" ) or objective .text :match (" ^(.-)%s+slain:%s*%d" )
185+ if objectiveName then
186+ objectiveName = br ._G .strtrim (objectiveName )
187+ br .engines .questTracker .cache [objectiveName ] = true
188+ end
189+ end
190+ end
191+ end
113192 end
114193 end
115194 end
@@ -124,6 +203,17 @@ local function FunctionQuestLogUpdate() --private
124203 br .engines .questTracker .cacheThrottle = br ._G .C_Timer .NewTimer (2 , QuestCacheUpdate )
125204end
126205
206+ -- Debug function to print cache contents
207+ function questTracker :printCache ()
208+ br ._G .print (" === Quest Tracker Cache Contents ===" )
209+ local count = 0
210+ for name , _ in pairs (br .engines .questTracker .cache ) do
211+ count = count + 1
212+ br ._G .print (count .. " . " .. tostring (name ))
213+ end
214+ br ._G .print (" === Total cached items: " .. count .. " ===" )
215+ end
216+
127217function questTracker :isQuestObject (object ) -- Ty Ssateneth
128218 local objectID = br ._G .ObjectID (object )
129219 local ignoreObjects = {
@@ -132,6 +222,8 @@ function questTracker:isQuestObject(object) --Ty Ssateneth
132222 if ignoreObjects [objectID ] ~= nil then
133223 return false
134224 end
225+
226+ -- Check hardcoded quest object IDs (specific expansions)
135227 if objectID == 325958 or objectID == 325962 or objectID == 325963 or objectID == 325959 or objectID == 335703 or
136228 objectID == 152692 or objectID == 163757 or objectID == 290542 or objectID == 113768 or objectID == 113771 or
137229 objectID == 113769 or objectID == 113770 or objectID == 153290 or
@@ -145,10 +237,31 @@ function questTracker:isQuestObject(object) --Ty Ssateneth
145237 -- mechagon chests
146238 objectID == 151166 -- algan units
147239 then return true end
148- local glow = br .functions .misc :getItemGlow (object ) -- or select(2, CanLootUnit(object)) or questObj == 12
240+
241+ -- Check if object has quest glow
242+ local glow = br .functions .misc :getItemGlow (object )
149243 if glow then
150244 return true
151245 end
246+
247+ -- Check if object name matches any quest in cache
248+ -- This is more reliable for objects than tooltip scanning
249+ local objectName = br ._G .ObjectName (object )
250+ if objectName then
251+ -- Check result cache first (avoids repeated lookups for same objects)
252+ if br .engines .questTracker .objectCheckCache [objectName ] ~= nil then
253+ return br .engines .questTracker .objectCheckCache [objectName ]
254+ end
255+
256+ -- Direct lookup (variations are already pre-cached during QuestCacheUpdate)
257+ local result = br .engines .questTracker .cache [objectName ] or false
258+
259+ -- Cache the result for next time
260+ br .engines .questTracker .objectCheckCache [objectName ] = result
261+
262+ return result
263+ end
264+
152265 return false
153266end
154267
0 commit comments