From 9804bb4f52365cf08a5209163b62dedcd41ac709 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Sat, 30 Apr 2011 19:20:24 +0100 Subject: [PATCH] Fail gracefully when coordinate information can't be found --- TomTom_POIIntegration.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/TomTom_POIIntegration.lua b/TomTom_POIIntegration.lua index 61ba948..ba5e239 100644 --- a/TomTom_POIIntegration.lua +++ b/TomTom_POIIntegration.lua @@ -8,6 +8,7 @@ local modTbl = { S = IsShiftKeyDown, } +local L = TomTomLocals local astrolabe = DongleStub("TTAstrolabe-1.0") -- This function and the related events/hooks are used to automatically @@ -160,12 +161,18 @@ local function poi_OnClick(self, button) local m, f = GetCurrentMapAreaID() local questIndex = self.quest and self.quest.questLogIndex - if not questIndex and self.index then - questIndex = GetQuestIndexForWatch(self.index) + if not questIndex and self.questId then + -- Lookup the questIndex for the given questId + for idx = 1, GetNumQuestLogEntries(), 1 do + local qid = select(9, GetQuestLogTitle(idx)) + if qid == self.questId then + questIndex = idx + end + end end - if not questIndex then - return + if not questIndex and self.index then + questIndex = GetQuestIndexForWatch(self.index) end local title = GetQuestLogTitle(questIndex) @@ -175,6 +182,13 @@ local function poi_OnClick(self, button) title = "Turn in: " .. title end + if not x or not y then + -- No coordinate information for this quest/objective + local header = "|cFF33FF99TomTom|r" + print(L["%s: No coordinate information found for '%s' at this map level"]:format(header, title)) + return + end + local key = TomTom:GetKeyArgs(m, f, x, y, title) local alreadySet = false -- 1.7.9.5