diff --git a/Development/QHBuild.sh b/Development/QHBuild.sh index 8b62bb5..04d857d 100755 --- a/Development/QHBuild.sh +++ b/Development/QHBuild.sh @@ -103,7 +103,7 @@ then fi sub="s/\\\$svnversion\\\$/${release_string}/g" -sub2='s/4\.0\.1/4\.3\.0/' +sub2='s/4\.0\.1/5\.0\.5/' for toc in `find . -iname "*.toc"` do echo Replacing version tag in ${toc}. @@ -128,7 +128,7 @@ done echo ${release_string} -zip -qdgds 1m -r QuestHelper-4.3.0.${release_string}.zip QuestHelper/ QHData-* +zip -qdgds 1m -r QuestHelper-5.0.5.${release_string}.zip QuestHelper/ QHData-* echo Moving the package up one directory level. mv -v *.zip .. diff --git a/QHData-base/QHData-base.toc b/QHData-base/QHData-base.toc index fe25ede..f592fee 100644 --- a/QHData-base/QHData-base.toc +++ b/QHData-base/QHData-base.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (Base) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-deDE/QHData-deDE.toc b/QHData-deDE/QHData-deDE.toc index 26de381..d3b994c 100644 --- a/QHData-deDE/QHData-deDE.toc +++ b/QHData-deDE/QHData-deDE.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (deDE) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-enUS/QHData-enUS.toc b/QHData-enUS/QHData-enUS.toc index 0e90092..9d9d8b9 100644 --- a/QHData-enUS/QHData-enUS.toc +++ b/QHData-enUS/QHData-enUS.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (enUS) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-esES/QHData-esES.toc b/QHData-esES/QHData-esES.toc index 9ed8f45..7475440 100644 --- a/QHData-esES/QHData-esES.toc +++ b/QHData-esES/QHData-esES.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (esES) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-esMX/QHData-esMX.toc b/QHData-esMX/QHData-esMX.toc index 19ca4da..d6c45a4 100644 --- a/QHData-esMX/QHData-esMX.toc +++ b/QHData-esMX/QHData-esMX.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (esMX) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-frFR/QHData-frFR.toc b/QHData-frFR/QHData-frFR.toc index bd11c11..2476378 100644 --- a/QHData-frFR/QHData-frFR.toc +++ b/QHData-frFR/QHData-frFR.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (frFR) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-koKR/QHData-koKR.toc b/QHData-koKR/QHData-koKR.toc index 296e1a5..df1ef71 100644 --- a/QHData-koKR/QHData-koKR.toc +++ b/QHData-koKR/QHData-koKR.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (koKR) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-ruRU/QHData-ruRU.toc b/QHData-ruRU/QHData-ruRU.toc index c753b8e..b5adaf3 100644 --- a/QHData-ruRU/QHData-ruRU.toc +++ b/QHData-ruRU/QHData-ruRU.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (ruRU) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-zhCN/QHData-zhCN.toc b/QHData-zhCN/QHData-zhCN.toc index 89e4efa..236f553 100644 --- a/QHData-zhCN/QHData-zhCN.toc +++ b/QHData-zhCN/QHData-zhCN.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (zhCN) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QHData-zhTW/QHData-zhTW.toc b/QHData-zhTW/QHData-zhTW.toc index 392876e..7e450e8 100644 --- a/QHData-zhTW/QHData-zhTW.toc +++ b/QHData-zhTW/QHData-zhTW.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper Data (zhTW) ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Contains the data needed by QuestHelper diff --git a/QuestHelper/LibMapDataInit.lua b/QuestHelper/LibMapDataInit.lua new file mode 100644 index 0000000..eecfaea --- /dev/null +++ b/QuestHelper/LibMapDataInit.lua @@ -0,0 +1,3 @@ +assert(QuestHelper and type(QuestHelper) == "table", "Ooops, can't load right now.") + +QuestHelper.LibMapData = LibStub("LibMapData-1.0") diff --git a/QuestHelper/QuestHelper.toc b/QuestHelper/QuestHelper.toc index 69b82cd..e6e4dcd 100644 --- a/QuestHelper/QuestHelper.toc +++ b/QuestHelper/QuestHelper.toc @@ -1,4 +1,4 @@ -## Interface: 40300 +## Interface: 50001 ## Title: QuestHelper ## Author: zorbathut, smariot, vipersniper, nesher, nconantj ## Notes: Calculates an optimal route for you to follow while questing. @@ -62,13 +62,20 @@ libs\AceConfig-3.0\AceConfig-3.0.xml bst_astrolabe.lua libs\AstrolabeQH\Load.xml +#MapMonitor.lua +#AstroLabeToLibMapDataConversionStub.lua bst_ctl.lua libs\ChatThrottleLib\ChatThrottleLib.xml bst_range.lua -libs\LibRangeCheck-2.0\CallbackHandler-1.0\CallbackHandler-1.0.xml -libs\LibRangeCheck-2.0\LibRangeCheck-2.0.lua +#-libs\LibRangeCheck-2.0\CallbackHandler-1.0\CallbackHandler-1.0.xml +#-libs\LibRangeCheck-2.0\LibRangeCheck-2.0.lua + +bst_mapdata.lua +libs\LibMapData-1.0\Libs\CallbackHandler-1.0 +libs\LibMapData-1.0\library.lua +LibMapDataInit.lua changes.lua @@ -107,7 +114,7 @@ recycle.lua pattern.lua # Database module. Depends on nothing, calls no external functions. -db_get.lua +#-db_get.lua # Timeslice module. Depends on nothing, calls no external functions besides a few basic system-API things. timeslice.lua @@ -122,30 +129,30 @@ manager_achievement.lua manager_completed.lua # Graph module. Depends on nothing, calls no external functions. -graph_core.lua -graph_flightpath.lua +#-graph_core.lua +#-graph_flightpath.lua # Routing module. Depends on Timeslice and Filters, calls almost no external functions (handles its own get-player-position stuff via RetrieveRawLocation, but that's it.) -routing_debug.lua -routing_loc.lua -routing_route.lua -routing_core.lua -routing_controller.lua +#-routing_debug.lua +#-routing_loc.lua +#-routing_route.lua +#-routing_core.lua +#-routing_controller.lua # this segment uses the menu system as well -routing_hidden.lua +#-routing_hidden.lua # Filters. Pays attention to QH_pref but not a lot more. -filter_core.lua -filter_base.lua +#-filter_core.lua +#-filter_base.lua # New tooltip system. Depends on nothing, calls nothing besides WoW UI. tooltip.lua # Directors # Quest module. Depends on Database, Routing, Patterns, Tooltip, and Event Manager, interfaces with WoW UI. -director_quest.lua -director_achievement.lua -director_find.lua +#-director_quest.lua +#-director_achievement.lua +#-director_find.lua # Map and minimap dodads. Old code. Depends on nothing, interfaces with WoW UI. dodads.lua @@ -160,21 +167,21 @@ core.lua radar.lua -upgrade.lua +#-upgrade.lua main.lua objective.lua quest.lua teleport.lua -pathfinding.lua +#-pathfinding.lua routing.lua custom.lua menu.lua nag.lua comm.lua -mapbutton.lua +#-mapbutton.lua flightpath.lua -tracker.lua +#-tracker.lua objtips.lua textviewer.lua help.lua diff --git a/QuestHelper/arrow.lua b/QuestHelper/arrow.lua index c49649c..f142380 100644 --- a/QuestHelper/arrow.lua +++ b/QuestHelper/arrow.lua @@ -198,6 +198,7 @@ OnUpdate = function() self:Show() local dist, dx, dy = QuestHelper.Astrolabe:ComputeDistance(QuestHelper.collect_rc, QuestHelper.collect_rz, QuestHelper.collect_rx, QuestHelper.collect_ry, active_point.c, active_point.z, active_point.x, active_point.y) + --print(QuestHelper.collect_rc, QuestHelper.collect_rz, QuestHelper.collect_rx, QuestHelper.collect_ry, active_point.c, active_point.z, active_point.x, active_point.y) local text = "" diff --git a/QuestHelper/collect.lua b/QuestHelper/collect.lua index fc313e0..bf73784 100644 --- a/QuestHelper/collect.lua +++ b/QuestHelper/collect.lua @@ -4,8 +4,8 @@ local GetTime = QuestHelper_GetTime QuestHelper_File["collect.lua"] = "4.0.1.$svnversion$" QuestHelper_Loadtime["collect.lua"] = GetTime() -local --[[ static ]] MINSVNVERSION = 185 -local --[[ static ]] PURGEDEV = false +local --[[ static ]] MINSVNVERSION = 255 +local --[[ static ]] PURGEDEV = true local debug_output = false if QuestHelper_File["collect.lua"] == "Development Version" then debug_output = true end diff --git a/QuestHelper/collect_equip.lua b/QuestHelper/collect_equip.lua index d94b246..a947543 100644 --- a/QuestHelper/collect_equip.lua +++ b/QuestHelper/collect_equip.lua @@ -34,11 +34,11 @@ local invloc_lookup_proto = { INVTYPE_2HWEAPON = {"MainHandSlot"}, INVTYPE_WEAPONMAINHAND = {"MainHandSlot"}, INVTYPE_WEAPONOFFHAND = {"SecondaryHandSlot"}, - INVTYPE_HOLDABLE = {"RangedSlot"}, - INVTYPE_RANGED = {"RangedSlot"}, - INVTYPE_THROWN = {"RangedSlot"}, - INVTYPE_RANGEDRIGHT = {"RangedSlot"}, - INVTYPE_RELIC = {"RangedSlot"}, + --INVTYPE_HOLDABLE = {"RangedSlot"}, + --INVTYPE_RANGED = {"RangedSlot"}, + --INVTYPE_THROWN = {"RangedSlot"}, + --INVTYPE_RANGEDRIGHT = {"RangedSlot"}, + --INVTYPE_RELIC = {"RangedSlot"}, } local invloc_lookup = {} diff --git a/QuestHelper/collect_location.lua b/QuestHelper/collect_location.lua index bc966b4..853b063 100644 --- a/QuestHelper/collect_location.lua +++ b/QuestHelper/collect_location.lua @@ -13,11 +13,63 @@ local function signed(c) --return strchar(c) end +local dec2hex = {[0] = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"} + +local hex2dec = {} + +for k, v in pairs(dec2hex) do hex2dec[v] = k end + +local function tohex(c) + return dec2hex[c] +end + +local function lgToDec(c, pos) + if not c or c == "" then return 0 end + + local ret = 0 + + pos = pos or 0 + + if pos == 0 then c = string.reverse(c) end + + ret = todec(string.sub(c,1,1)) * math.pow(16, pos) + lgToDec(string.sub(c, 2), pos + 1) + + return ret +end + +local function lgToHex(c, pos) + local ret, rem, hex + + pos = pos or 0 + c = c or 0 + local minVal = math.pow(16, pos) + local maxVal = math.pow(16, pos+1) - 1 + + if c > maxVal then + rem, hex = lgToHex(c, pos + 1) + else + rem, hex = c, "" + end + + local mult = 0 + + while rem >= minVal do + mult = mult + 1 + rem = rem - minVal + end + + return rem, hex .. tohex(mult) +end + +local function todec(c) + return hex2dec[c] +end + local function float(c) -- if not c then c = -128 end -- QuestHelper: Assert( c >= -128, string.format("c is too small. It is %s.", tostring(c))) -- QuestHelper: Assert( c < 128, string.format("c is too big. It is %s.", tostring(c))) - local ret = tostring(c):gsub(",",".") -- eliminate issues with locales that use a comma as the decimal separator. + local ret = tohex(math.floor(128 * c)) return ret end @@ -26,9 +78,10 @@ local function BolusizeLocation(delayed, c, z, x, y, dl, mid, mf, f) -- x and y are floating-point values, generally between 0 and 1. We'll dedicate 24 bits to the fractional part, largely because we can. -- Overall we're using a weird 11 bytes on this. Meh. -- Also, any nil values are being turned into MIN_WHATEVER. - local float_x = float(x) - local float_y = float(y) + local float_x = x + local float_y = y local loc = {} + --local locStr = (delayed and 1 or 0) .. lgToHex(mid) .. tohex(dl) .. float(x) .. float(y) loc["delayed"] = (delayed and 1 or 0) loc["c"] = c loc["z"] = z diff --git a/QuestHelper/collect_loot.lua b/QuestHelper/collect_loot.lua index d78844a..0009025 100644 --- a/QuestHelper/collect_loot.lua +++ b/QuestHelper/collect_loot.lua @@ -36,7 +36,7 @@ local function MembersUpdate() --QuestHelper:TextOut("MU start") members = {} -- we burn a table every time this updates, but whatever members_count = 0 - if GetNumRaidMembers() > 0 then + if IsInRaid() then -- we is in a raid for i = 1, 40 do local ite = string.format("raid%d", i) @@ -47,7 +47,7 @@ local function MembersUpdate() --QuestHelper:TextOut(string.format("raid member %s added", UnitName(ite))) end end - elseif GetNumPartyMembers() > 0 then + elseif GetNumGroupMembers() > 0 then -- we is in a party for i = 1, 4 do local ite = string.format("party%d", i) @@ -531,9 +531,7 @@ local function LootOpened() for i = 1, GetNumLootItems() do tex, name, quant, qual, locked = GetLootSlotInfo(i) link = GetLootSlotLink(i) - local curr = LootSlotIsCurrency(i) - local coin = LootSlotIsCoin(i) - local itm = LootSlotIsItem(i) + local slotType = GetLootSlotType(i) if quant == 0 then -- moneys @@ -544,7 +542,7 @@ local function LootOpened() tot = (tonumber(gold) or 0) * 10000 + (tonumber(silver) or 0) * 100 + (tonumber(copper) or 0) * 1 items[PseudoIDs["gold"]] = tot else - if curr then + if slotType == LOOT_SLOT_CURRENCY then if not QHC.PseudoIDs[name] then QHC.PseudoIDsMin = QHC.PseudoIDsMin - 1 QHC.PseudoIDs[name] = QHC.PseudoIDsMin @@ -553,9 +551,9 @@ local function LootOpened() else if not link and not name then local msg = "Texture is " .. tostring(tex) .. " with a quantity of " .. tostring(quant) .. ", a quality of " .. qual .. "." - if coin then + if slotType == LOOT_SLOT_MONEY then QuestHelper:Assert(false, "Loot slot " .. tostring(i) .. " is coin. " .. msg) - elseif itm then + elseif slotType == LOOT_SLOT_ITEM then QuestHelper:Assert(false, "Loot slot " .. tostring(i) .. " is item. " .. msg) else QuestHelper_ErrorCatcher_ExplicitError(false, "Loot slot " .. tostring(i) .. " is ???. " .. msg) diff --git a/QuestHelper/collect_spec.lua b/QuestHelper/collect_spec.lua index 625d4f4..4eee07b 100644 --- a/QuestHelper/collect_spec.lua +++ b/QuestHelper/collect_spec.lua @@ -16,7 +16,8 @@ local classlookup = { ["ROGUE"] = "R", ["SHAMAN"] = "S", ["WARLOCK"] = "L", - ["WARRIOR"] = "W" + ["WARRIOR"] = "W", + ["MONK"] = "O" }; local racelookup = { @@ -32,7 +33,8 @@ local racelookup = { ["Tauren"] = "N", ["Undead"] = "U", ["BloodElf"] = "B", - ["Goblin"] = "L" + ["Goblin"] = "L", + ["Pandaren"] = "P" -- lol i spelled nub } @@ -46,7 +48,7 @@ local function GetSpecBolus() --local bso = Bitstream.Output(8) local talents = {} - local points = (GetUnspentTalentPoints() or 0) + --local points = (GetUnspentTalentPoints() or 0) local talents_learned = false for t = 1, GetNumTalentTabs() do -- come on. Is this ever not going to be 3? Seriously? Perhaps someday, but not as of Cat. local _, tab, _, _, p, _, _, yn = GetTalentTabInfo(t) diff --git a/QuestHelper/core.lua b/QuestHelper/core.lua index 71354d2..1c785b7 100644 --- a/QuestHelper/core.lua +++ b/QuestHelper/core.lua @@ -9,6 +9,6 @@ QuestHelper.Astrolabe = QH_Astrolabe_Ready and DongleStub("Astrolabe-0.4-QuestHe local walker = QuestHelper:CreateWorldMapWalker() QuestHelper.minimap_marker = QuestHelper:CreateMipmapDodad() -QH_Route_RegisterNotification(function (route) walker:RouteChanged(route) end) -QH_Route_RegisterNotification(function (route) QH_Tracker_UpdateRoute(route) end) -QH_Route_RegisterNotification(function (route) QuestHelper.minimap_marker:SetObjective(route[2]) end) +--QH_Route_RegisterNotification(function (route) walker:RouteChanged(route) end) +--QH_Route_RegisterNotification(function (route) QH_Tracker_UpdateRoute(route) end) +--QH_Route_RegisterNotification(function (route) QuestHelper.minimap_marker:SetObjective(route[2]) end) diff --git a/QuestHelper/custom.lua b/QuestHelper/custom.lua index b96dfca..06296a2 100644 --- a/QuestHelper/custom.lua +++ b/QuestHelper/custom.lua @@ -308,8 +308,8 @@ local elders = { ["Silvervein"] = "Loch Modan 33 46", ["Ironband"] = "Searing Gorge 21 79", ["Obsidian"] = "Silverpine Forest 45 41", - ["Starglade"] = "Stranglethorn Vale 63 22", -- Jungle 71 34 - ["Winterhoof"] = "Stranglethorn Vale 37 79", -- Cape 39 72 + ["Starglade"] = "Northern Stranglethorn 71 34", + ["Winterhoof"] = "The Cape of Stranglethorn 39 72", -- Cape 39 72 ["Graveborn"] = "Tirisfal Glades 61 53", ["Moonstrike"] = "Western Plaguelands 69 73", ["Meadowrun"] = "Western Plaguelands 63 36", @@ -334,7 +334,18 @@ local elders = { ["Muraco"] = "Storm Peaks 64 51", ["Stonebeard"] = "Storm Peaks 31 38", ["Tauros"] = "Zul'Drak 59 56" - } + }, + ["Cataclysm"] = { + ["Moonlance"] = "Shimmering Expanse 57, 86", -- Biel'aran Ridge, Shimmering Expanse + ["Windsong"] = "Mount Hyjal 27 62", -- Sanctuary of Malorne, Hyjal + ["Evershade"] = "Mount Hyjal 63 23", -- Nordrassil, Hyjal + ["Stonebrand"] = "Deepholm 50 55", -- Temple of Earth, Deepholm + ["Deepforge"] = "Deepholm 28 69", -- Stonehearth, Deepholm + ["Menkhaf"] = "Uldum 66 19", -- Khartut's Tomb, Uldum + ["Sekhemi"] = "Uldum 32 63", -- Ruins of Ammon, Uldum + ["Firebeard"] = "Twilight Highlands 51 71", -- Dunward Town Square, Dunward Ruins, Twilight Highlands + ["Darkfeather"] = "Twilight Highlands 52 33" -- Thundermar Ruins, Twilight Highlands + }, } local function searchItem(input, yield_countdown, yield_countdown_max) diff --git a/QuestHelper/db_get.lua b/QuestHelper/db_get.lua index dfb35af..4147ba3 100644 --- a/QuestHelper/db_get.lua +++ b/QuestHelper/db_get.lua @@ -122,6 +122,12 @@ end function DB_HasItem(group, id) QuestHelper: Assert(initted) + + if group == "quest" then + if type(id) == "number" and id > 0 then return true + else return false + end + end for _, db in ipairs(QHDB) do if db[group] then @@ -137,6 +143,159 @@ function DB_HasItem(group, id) return false end +local function GetBlizzardQuestInfoFrameMainLoop(qid) + local POIFrame, questFrame + QuestMapUpdateAllQuests() + QuestPOIUpdateIcons() + WorldMapFrame_UpdateQuests() + + for i = 1, MAX_NUM_QUESTS do + questFrame = _G["WorldMapQuestFrame" .. i] + if questFrame then + if questFrame.questId == qid then + POIFrame = questFrame.poiIcon + break + end + end + end + + return questFrame, POIFrame +end + +local function GetBlizzardQuestInfoFrame(qid, map) + if map then SetMapByID(map) end + QuestMapUpdateAllQuests() + QuestPOIUpdateIcons() + WorldMapFrame_UpdateQuests() + + local POIFrame + local questFrame + local dLvl + + if map and GetNumDungeonMapLevels() > 0 then -- Suspicion is that each dungeon level has to be iterated. + for i = 1, GetNumDungeonMapLevels() do + SetDungeonMapLevel(i) + questFrame, POIFrame = GetBlizzardQuestInfoFrameMainLoop(qid) + if POIFrame then + dLvl = i + break + end + end + else -- Only need to call once + questFrame, POIFrame = GetBlizzardQuestInfoFrameMainLoop(qid) + end + + return questFrame, POIFrame, dLvl or 0 +end + +local function GetBlizzardQuestInfo(qid) + local questFrame, POIFrame, qdLvl = GetBlizzardQuestInfoFrame(qid) + local mapId = GetCurrentMapAreaID() + local c, z + local dLvl = false + local qMapId + + if GetNumDungeonMapLevels() > 0 then dLvl = GetCurrentMapDungeonLevel() end + + if not POIFrame then + -- Iterate over all maps to try and find it (we are of course assuming that the player has the quest, otherwise we will be SOL. + local maps = QuestHelper.LibMapData:GetAllMapIDs() + for _, map in pairs(maps) do + if map >= 0 and not QuestHelper.LibMapData:IsContinentMap(map) then + + questFrame, POIFrame, qdLvl = GetBlizzardQuestInfoFrame(qid, map) + + if POIFrame then + qMapId = map + break + end + end + end + c, z = GetCurrentMapContinent(), GetCurrentMapZone() + SetMapByID(mapId) + if not POIFrame then return nil end -- At this point we either have the quest or we are SOL. + else + qMapId = mapId + c, z = GetCurrentMapContinent(), GetCurrentMapZone() + end + + local _, _, _, x, y = POIFrame:GetPoint() + + if not x or not y then return nil end + + local frame = WorldMapDetailFrame + local width, height = frame:GetWidth(), frame:GetHeight() + local wm_scale, poi_scale = frame:GetScale(), POIFrame:GetScale() + + -- Convert from yards to % + local cx = ((x / (wm_scale / poi_scale)) / width) + local cy = ((-y / (wm_scale / poi_scale)) / height) + + + if cx < 0 or cx > 1 or cy < 0 or cy > 1 then return nil end + + -- Now we want to convert to proper format for QH. + -- Look at WoWPro:findBlizzCoords(qid) for remainder + local _, contX, contY = QuestHelper.Astrolabe:GetAbsoluteContinentPosition(c, z, cx, cy) + --contX, contY = contX / QuestHelper.Astrolabe:GetZoneWidth(c, 0), contY / QuestHelper.Astrolabe:GetZoneHeight(c, 0) + + local solid = { ["continent"] = c, contX - 10, contY - 10, contX + 10, contY - 10, contX + 10, contY + 10, contX - 10, contY + 10 } + local ret = {} + + ret.solid = solid + ret.criteria = {} + + local questIdx = GetQuestLogIndexByID(qid) + local numCrit = GetNumQuestLeaderBoards(questIdx) + local loc = { ["loc"] = { { ["p"] = qMapId, ["x"] = contX, ["y"] = contY} } } + for i = 1, numCrit do + table.insert(ret.criteria, loc) + end + + ret.name = GetQuestLogTitle(questIdx) + ret.Blizzard = true + return ret +end + +local function GetLightHeadedQuestInfo(qid) + if not LightHeaded or type(LightHeaded) ~= "table" then return nil end -- LH not loaded + + local npcid, npcname, stype + local coords = {} + + _, _, _, _, _, _, _, stype, npcname, npcid = LightHeaded:GetQuestInfo(qid) + + -- Note: If we want the quest giver, we need fields 5, 6 and 7 above, rather than what we have gotten. + -- + if stype == "npc" then + local data = LightHeaded:LoadNPCData(tonumber(npcid)) + if not data then return end -- LightHeaded has no clue about the given NPC, despite giving us the id. + for zid,x,y in data:gmatch("([^,]+),([^,]+),([^:]+):") do + table.insert(coords, {["p"] = zid, ["x"] = x, ["y"] = y}) + end + end + + --can't return coordinates until we know more about what we are getting and then convert accordingly. + for k, v in pairs(coords) do for k1, v1 in pairs(v) do print(k, k1, v1) end end + --return coords + return nil +end + +local function GetSelfQuestInfo(qid) + return nil +end + +-- Returns x and y in yards relative to something... Continent? +local function GetQuestInfo(qid) + assert(type(qid) == "number") + local coords = GetSelfQuestInfo(qid) + --if not coords then coords = GetLightHeadedQuestInfo(qid) end + if not coords then + coords = GetBlizzardQuestInfo(qid) + end + + return coords -- Might still be nil, but if we don't have anything from Blizz, prolly nothing can be done. +end function DB_GetItem(group, id, silent, register) QuestHelper: Assert(initted) @@ -145,6 +304,15 @@ function DB_GetItem(group, id, silent, register) QuestHelper: Assert(id, string.format("%s %s", tostring(group), tostring(id))) local ite = DBC_Get(group, id) + if not ite and group == "flightpaths" then return nil end + + if not ite and group == "quest" then + -- Loop over zones AND floors + -- see QuestRouterLite.lua for specific calls. + -- In the end, the item returned MUST be "formatted" the same as a true QHDB item. + ite = GetQuestInfo(id) + end + if not ite then if type(id) == "string" then QuestHelper: Assert(not id:match("__.*")) end @@ -232,7 +400,9 @@ function DB_ReleaseItem(ite) if frequencies[ite] == 0 then --print("incinerating", freq_group[ite], freq_id[ite]) - cache[freq_group[ite]][freq_id[ite]] = nil + if cache[freq_group[ite]] then + cache[freq_group[ite]][freq_id[ite]] = nil + end freq_group[ite] = nil freq_id[ite] = nil diff --git a/QuestHelper/director_achievement.lua b/QuestHelper/director_achievement.lua index 3603938..6bb579d 100644 --- a/QuestHelper/director_achievement.lua +++ b/QuestHelper/director_achievement.lua @@ -289,20 +289,12 @@ function GetAchievementMetaObjective(achievement) if data.chunk then ttx.solid = horribledupe(data.chunk.solid) if data.chunk.loc then for _, v in ipairs(data.chunk.loc) do --- Ugly database hack - if v.p == 26 then v.p = 48 end - if v.p == 38 then v.p = 168 end --- end hack table.insert(ttx, {loc = {x = v.x, y = v.y, c = QuestHelper_ParentLookup[v.p], p = v.p}}) end end end if data.loc then ttx.solid = data.solid --- Ugly database hack - if data.loc.p == 26 then data.loc.p = 48 end - if data.loc.p == 38 then data.loc.p = 168 end --- end hack table.insert(ttx, {loc = {x = data.loc.x, y = data.loc.y, c = QuestHelper_ParentLookup[data.loc.p], p = data.loc.p}}) end diff --git a/QuestHelper/director_find.lua b/QuestHelper/director_find.lua index 5473cd0..3ed6576 100644 --- a/QuestHelper/director_find.lua +++ b/QuestHelper/director_find.lua @@ -71,10 +71,6 @@ local function generate_objective(dbi) for _, v in ipairs(dbi.loc) do QuestHelper: Assert(QuestHelper_ParentLookup) QuestHelper: Assert(QuestHelper_ParentLookup[v.p], v.p) --- Ugly database hack - if v.p == 26 then v.p = 48 end - if v.p == 38 then v.p = 168 end --- end hack table.insert(clooster, {loc = {x = v.x, y = v.y, c = QuestHelper_ParentLookup[v.p], p = v.p}, cluster = clooster, tracker_hidden = true, why = why, map_desc = {QuestHelper:HighlightText(dbi.name)}, tracker_desc = dbi.name, map_suppress_ignore = true, map_custom_menu = function (menu) QuestHelper:CreateMenuItem(menu, QHText("FIND_REMOVE")):SetFunction(function () QH_Route_ClusterRemove(clooster) end) end}) end @@ -140,124 +136,214 @@ local function QH_FindLoc(locd) end local elders = { - ["Alliance"] = { - ["Bladeswift"] = {21, 39, 32}, --"Darnassus 39 32", - ["Bronzebeard"] = {25, 29, 16}, --"Ironforge 29 16", - ["Hammershout"] = {37, 2, 10}, --"Elwynn Forest 34 50" + ["Alliance"] = { -- Achievement 915 + ["Bladeswift"] = {381, 39, 32, 8718, 1999}, --"Darnassus 39 32", + ["Bronzebeard"] = {341, 29, 16, 8866, 1997}, --"Ironforge 29 16", + ["Hammershout"] = { 30, 2, 10, 8646, 1998}, --"Elwynn Forest 34 50" }, - ["Horde"] = { - ["Darkhorn"] = {1, 52, 60}, --"Orgrimmar 52 60", - ["Wheathoof"] = {23, 73.0, 23.3}, --"Thunder Bluff 73.0 23.3", - ["Darkcore"] = {45, 67, 38}, --"Undercity 67 38" + ["Horde"] = { -- Achievement 914 + ["Darkhorn"] = {321, 52, 60, 8677, 1991}, --"Orgrimmar 52 60", + ["Wheathoof"] = {362, 73.0, 23.3, 8678, 1993}, --"Thunder Bluff 73.0 23.3", + ["Darkcore"] = {382, 67, 38, 8648, 1992}, --"Undercity 67 38" }, - ["Kalimdor"] = { - ["Riversong"] = {2, 35.5, 48.9}, --"Ashenvale 35.5 48.9", - ["Skygleam"] = {15, 64.8, 79.3}, --"Azshara 64.8 79.3", - ["High Mountain"] = {203, 41.5, 47.5}, --"Southern Barrens 41.5 47.5", - ["Moonwarden"] = {11, 48.5, 59.2}, --"Northern Barrens 48.5 59.2", - ["Windtotem"] = {11, 68.4, 70}, --"Northern Barrens 68.4 70", - ["Starweave"] = {16, 49.5, 19.0}, --"Darkshore 49.5 19.0", NOTE TO SELF -- CONVERTING TO LOOKUP VALUES DON'T FORGET TO CHANGE THE FUNCTION!!!!!!! - ["Runetotem"] = {7, 53.2, 43.6}, --"Durotar 53.2 43.6", - ["Nightwind"] = {13, 38.3, 52.9}, --"Felwood 38.3 52.9", - ["Grimtotem"] = {17, 76.7, 37.9}, --"Feralas 76.7 37.9", - ["Mistwalker"] = {17, 62.6, 31.1}, --"Feralas 62.6 31.1", - ["Bloodhoof"] = {22, 48, 53}, --"Mulgore 48 53", - ["Bladesing"] = {5, 53, 35}, --"Silithus 53 35", - ["Primestone"] = {5, 30.7, 13.3}, --"Silithus 30.7 13.3", - ["Dreamseer"] = {8, 50, 28}, --"Tanaris 50 28", - ["Ragetotem"] = {8, 36, 80}, --"Tanaris 36 80", - ["Bladeleaf"] = {24, 56.8, 53.1}, --"Teldrassil 56.8 53.1", - ["Skyseer"] = {14, 46.3, 51.0}, --"Thousand Needles 46.3 51.0", - ["Morningdew"] = {14, 77.0, 75.6}, --"Thousand Needles 77.0 75.6", - ["Thunderhorn"] = {18, 51, 75}, --"Un'Goro Crater 51 75", - ["Brightspear"] = {19, 53.0, 56.7}, --"Winterspring 53.0 56.7", - ["Stonespire"] = {19, 60.0, 50.0}, --"Winterspring 60.0 50.0", + ["Kalimdor"] = { -- Achievement 911 + ["Bladeleaf"] = { 41, 56.8, 53.1, 8715, 1951}, --"Teldrassil 56.8 53.1", + ["Bladesing"] = {261, 53, 35, 8719, 1966}, --"Silithus 53 35", + ["Bloodhoof"] = { 9, 48, 53, 8673, 1953}, --"Mulgore 48 53", + ["Brightspear"] = {281, 53.0, 56.7, 8726, 1963}, --"Winterspring 53.0 56.7", + ["Dreamseer"] = {161, 50, 28, 8684, 1961}, --"Tanaris 50 28", + ["Grimtotem"] = {121, 76.7, 37.9, 8679, 1955}, --"Feralas 76.7 37.9", + ["High Mountain"] = {607, 41.5, 47.5, 8686, 1919}, --"Southern Barrens 41.5 47.5", + ["Mistwalker"] = {121, 62.6, 31.1, 8685, 1956}, --"Feralas 62.6 31.1", + ["Moonwarden"] = { 11, 48.5, 59.2, 8717, 1918}, --"Northern Barrens 48.5 59.2", + ["Morningdew"] = { 61, 77.0, 75.6, 8724, 1959}, --"Thousand Needles 77.0 75.6", + ["Nightwind"] = {182, 38.3, 52.9, 8723, 1957}, --"Felwood 38.3 52.9", + ["Primestone"] = {261, 30.7, 13.3, 8654, 1965}, --"Silithus 30.7 13.3", + ["Ragetotem"] = {161, 36, 80, 8671, 1960}, --"Tanaris 36 80", + ["Riversong"] = { 43, 35.5, 48.9, 8725, 1954}, --"Ashenvale 35.5 48.9", + ["Runetotem"] = { 4, 53.2, 43.6, 8670, 1916}, --"Durotar 53.2 43.6", + ["Skygleam"] = {181, 64.8, 79.3, 8720, 1917}, --"Azshara 64.8 79.3", + ["Skyseer"] = { 61, 46.3, 51.0, 8682, 1958}, --"Thousand Needles 46.3 51.0", + ["Starweave"] = { 42, 49.5, 19.0, 8721, 1952}, --"Darkshore 49.5 19.0", + ["Stonespire"] = {281, 60.0, 50.0, 8672, 1964}, --"Winterspring 60.0 50.0", + ["Thunderhorn"] = {201, 51, 75, 8681, 1962}, --"Un'Goro Crater 51 75", + ["Windtotem"] = { 11, 68.4, 70, 8680, 1920}, --"Northern Barrens 68.4 70", }, - ["Eastern Kingdoms"] = { - ["Bellowrage"] = {33, 54, 49}, --"Blasted Lands 54 49", - ["Rumblerock"] = {40, 70, 45}, --"Burning Steppes 70 45", - ["Dawnstrider"] = {40, 53, 24}, --"Burning Steppes 53 24", - ["Goldwell"] = {28, 53.9, 49.9}, --"Dun Morogh 53 49", - ["Windrun"] = {34, 35.6, 68.8}, --"Eastern Plaguelands 35 68", - ["Snowcrown"] = {34, 75.7, 54.5}, --"Eastern Plaguelands 75.7 54.5", - ["Stormbrow"] = {37, 40, 63}, --"Elwynn Forest 40 63", - ["Highpeak"] = {42, 50, 48}, --"Hinterlands 50 48", - ["Silvervein"] = {29, 33, 46}, --"Loch Modan 33 46", - ["Ironband"] = {32, 21, 79}, --"Searing Gorge 21 79", - ["Obsidian"] = {35, 45, 41}, --"Silverpine Forest 45 41", - ["Starglade"] = {38, 63, 22}, --"Stranglethorn Vale 63 22", -- Jungle 71 34 - ["Winterhoof"] = {38, 37, 39}, --"Stranglethorn Vale 37 79", -- Cape 39 72 - ["Graveborn"] = {43, 61, 53}, --"Tirisfal Glades 61 53", - ["Moonstrike"] = {50, 69, 73}, --"Western Plaguelands 69 73", - ["Meadowrun"] = {50, 63.5, 36.2}, --"Western Plaguelands 63 36", - ["Skychaser"] = {49, 56, 47}, --"Westfall 56 47" + ["Eastern Kingdoms"] = { -- Achievement 912 + ["Bellowrage"] = {19, 54, 49, 8647}, --"Blasted Lands 54 49", + ["Rumblerock"] = {29, 70, 45, 8636}, --"Burning Steppes 70 45", + ["Dawnstrider"] = {29, 53, 24, 8683}, --"Burning Steppes 53 24", + ["Goldwell"] = {27, 53.9, 49.9, 8653}, --"Dun Morogh 53 49", + ["Windrun"] = {23, 35.6, 68.8, 8688}, --"Eastern Plaguelands 35 68", + ["Snowcrown"] = {23, 75.7, 54.5, 8650}, --"Eastern Plaguelands 75.7 54.5", + ["Stormbrow"] = {30, 40, 63, 8649}, --"Elwynn Forest 40 63", + ["Highpeak"] = {26, 50, 48, 8643}, --"Hinterlands 50 48", + ["Silvervein"] = {35, 33, 46, 8642}, --"Loch Modan 33 46", + ["Ironband"] = {28, 21, 79, 8651}, --"Searing Gorge 21 79", + ["Obsidian"] = {21, 45, 41, 8645}, --"Silverpine Forest 45 41", + ["Starglade"] = {37, 71, 34, 8716}, --"Northern Stranglethorn 71 34" + ["Winterhoof"] = {673, 39, 72, 8674}, --"The Cape of Stranglethorn 39 72" + ["Graveborn"] = {20, 61, 53, 8652}, --"Tirisfal Glades 61 53", + ["Moonstrike"] = {22, 69, 73, 8714}, --"Western Plaguelands 69 73", + ["Meadowrun"] = {22, 63.5, 36.2, 8722}, --"Western Plaguelands 63 36", + ["Skychaser"] = {39, 56, 47, 8675}, --"Westfall 56 47" }, - ["Northrend"] = { - ["Arp"] = {65, 57, 44}, --"Borean Tundra 57 44", - ["Northal"] = {65, 34, 34}, --"Borean Tundra 34 34", - ["Pamuya"] = {65, 43, 50}, --"Borean Tundra 43 50", - ["Sardis"] = {65, 59, 66}, --"Borean Tundra 59 66", - ["Morthie"] = {68, 30, 56}, --"Dragonblight 30 56", - ["Skywarden"] = {68, 35, 48}, --"Dragonblight 35 48", - ["Thoim"] = {68, 49, 78}, --"Dragonblight 49 78", - ["Beldak"] = {69, 61, 28}, --"Grizzly Hills 61 28", - ["Lunaro"] = {69, 81, 37}, --"Grizzly Hills 81 37", - ["Whurain"] = {69, 64, 47}, --"Grizzly Hills 64 47", - ["Bluewolf"] = {74, 49, 14}, --"Wintergrasp 49 14", - ["Sandrene"] = {72, 50, 64}, --"Sholazar Basin 50 64", - ["Wanikaya"] = {72, 64, 49}, --"Sholazar Basin 64 49", - ["Fargal"] = {73, 29, 74}, --"Storm Peaks 29 74", - ["Graymane"] = {73, 41, 85}, --"Storm Peaks 41 85", - ["Muraco"] = {73, 64, 51}, --"Storm Peaks 64 51", - ["Stonebeard"] = {73, 31, 38}, --"Storm Peaks 31 38", - ["Tauros"] = {75, 59, 56}, --"Zul'Drak 59 56" + ["Northrend"] = { -- Achievement 1396 + ["Arp"] = {486, 57, 44, 13033, 5145}, --"Borean Tundra 57 44", + ["Northal"] = {486, 34, 34, 13016, 5146}, --"Borean Tundra 34 34", + ["Pamuya"] = {486, 43, 50, 13029, 5157}, --"Borean Tundra 43 50", + ["Sardis"] = {486, 59, 66, 13012, 5141}, --"Borean Tundra 59 66", + ["Morthie"] = {488, 30, 56, 13014, 5143}, --"Dragonblight 30 56", + ["Skywarden"] = {488, 35, 48, 13031, 5159}, --"Dragonblight 35 48", + ["Thoim"] = {488, 49, 78, 13019, 5154}, --"Dragonblight 49 78", + ["Beldak"] = {490, 61, 28, 13013, 5142}, --"Grizzly Hills 61 28", + ["Lunaro"] = {490, 81, 37, 13025, 5149}, --"Grizzly Hills 81 37", + ["Whurain"] = {490, 64, 47, 13030, 5158}, --"Grizzly Hills 64 47", + ["Bluewolf"] = {501, 49, 14, 13026, 5150}, --"Wintergrasp 49 14", + ["Sandrene"] = {493, 50, 64, 13018, 5147}, --"Sholazar Basin 50 64", + ["Wanikaya"] = {493, 64, 49, 13024, 5148}, --"Sholazar Basin 64 49", + ["Fargal"] = {495, 29, 74, 13015, 5144}, --"Storm Peaks 29 74", + ["Graymane"] = {495, 41, 85, 13028, 5155}, --"Storm Peaks 41 85", + ["Muraco"] = {495, 64, 51, 13032, 5160}, --"Storm Peaks 64 51", + ["Stonebeard"] = {495, 31, 38, 13020, 5156}, --"Storm Peaks 31 38", + ["Tauros"] = {496, 59, 56, 13027, 5151}, --"Zul'Drak 59 56" + }, + ["Cataclysm"] = { -- Achievement 6006 + ["Moonlance"] = {615, 57, 86, 29738, 18154}, -- Biel'aran Ridge, Shimmering Expanse + ["Windsong"] = {606, 27, 62, 29739, 18156}, -- Sanctuary of Malorne, Hyjal + ["Evershade"] = {606, 63, 23, 29740, 18155}, -- Nordrassil, Hyjal + ["Stonebrand"] = {640, 50, 55, 29735, 18157}, -- Temple of Earth, Deepholm + ["Deepforge"] = {640, 28, 69, 29734, 18158}, -- Stonehearth, Deepholm + ["Menkhaf"] = {720, 66, 19, 29742, 18159}, -- Khartut's Tomb, Uldum + ["Sekhemi"] = {720, 32, 63, 29741, 18160}, -- Ruins of Ammon, Uldum + ["Firebeard"] = {700, 51, 71, 29737, 18161}, -- Dunward Town Square, Dunward Ruins, Twilight Highlands + ["Darkfeather"] = {700, 52, 33, 29736, 18162} -- Thundermar Ruins, Twilight Highlands + }, + --[===[ Placeholder for Elders of the Dungeons. If enabled prior to 2013, stored coordinates should be the map ID of the zone where the instance is located and the coordinates of the entrance. With any luck, by 2013 dungeons will be mapable. Coordinates listed in comment after each elder need to have floor numbers determined, where necessary, ASAP. + ["Dungeons"] = { -- Achievement 910 + ["Wildmane"] = {,,,8676, 1910}, -- Zul'Farrak 34.52 39.35 + ["Splitrock"] = {,,,8635, 1912}, -- Maraudon 51.47, 93.7 + ["Morndeep"] = {,,,8619, 1914}, -- Blackrock Depths 50.52 62.97 + ["Jarten"] = {,,,13017, 5259}, -- Utgarde Keep 47.4, 69.54 + ["Nurgen"] = {,,,13022, 5261}, -- Azjol-Nerub 21.78 43.62 + ["Ohanzee"] = {,,,13065, 5263}, -- Gundrak 45.7 61.55 + ["Chogan'gada"] = {,,,13067, 5265}, -- Utgarde Pinnacle 47.71 22.99 + ["Starsong"] = {,,,8713, 1911}, -- Sunken Temple 62.92 34.46 + ["Stonefort"] = {,,,8644, 1913}, -- Blackrock Spire 61.82 40 + ["Farwhisper"] = {,,,8727, 1915}, -- Stratholme 78.62 22.14 + ["Igasho"] = {,,,13021, 5260}, -- The Nexus 55.18 64.74 + ["Kilias"] = {,,,13023, 5262}, -- Drak'tharon Keep 68.85 79.17 + ["Yurauk"] = {,,,13066, 5264} -- Halls of Stone 29.39 62.03 } + --]===] } -local function QH_FindElders(elder_or_achievement, all_elders) +trackedElders = {} + +local function UpdateElders() + local elder, elderinfo + local qid = GetQuestID() + for elder, elderinfo in pairs(trackedElders) do + local z, x, y, id = unpack(elderinfo) + if id == qid then + QH_FindCoord(x, y, z, elder) + trackedElders[elder] = nil + return + end + end +end + +QH_Event("QUEST_COMPLETE", UpdateElders) + +local function QH_FindElders(elder_or_achievement, all_elders, forAchievement) + if elder_or_achievement == "CLEAR" then + for elder, elderinfo in pairs(trackedElders) do + local z, x, y = unpack(elderinfo) + QH_FindCoord(x, y, z, elder) + end + + trackedElders = {} + return + end + local achievement_match, elder_match = false, false + + local elderCount = 0 + for achievement, eldrs in pairs(elders) do if not all_elders then if elder_or_achievement == string.upper(achievement) then achievement_match = true end end - for elder, elder_loc in pairs(eldrs) do - if not all_elders then - if achievement_match then -- just add it - local locz, locx, locy = unpack(elder_loc) + for elder, elder_info in pairs(eldrs) do + local locz, locx, locy, qid, aid = unpack(elder_info) + local okToAdd = true + if forAchievement then + if aid then + local _, _, completed = GetAchievementCriteriaInfo(aid) + if completed then okToAdd = false end + end + elseif qid and QHQuestsCompleted and QHQuestsCompleted[qid] then + okToAdd = false + end + if okToAdd then + + if not all_elders then + if achievement_match then -- just add it + QH_FindCoord(locx, locy, locz, elder) + if trackedElders[elder] then trackedElders[elder] = nil + else + trackedElders[elder] = elder_info + elderCount = elderCount + 1 + end + elseif elder_or_achievement == string.upper(elder) then -- We have input and it's not an achievement, so it must be an elder. + elder_match = true + QH_FindCoord(locx, locy, locz, elder) + if trackedElders[elder] then trackedElders[elder] = nil + else + trackedElders[elder] = elder_info + elderCount = elderCount + 1 + end + + break -- We've found him or her. + end -- No need for else here. We alread know we don't need everything so we either have an achievement or we have an elder. + else -- We came in without an input, therefore we add all. QH_FindCoord(locx, locy, locz, elder) - elseif elder_or_achievement == string.upper(elder) then -- We have input and it's not an achievement, so it must be an elder. - elder_match = true - local locz, locx, locy = unpack(elder_loc) - QH_FindCoord(locx, locy, locz, elder) - break -- We've found him or her. - end -- No need for else here. We alread know we don't need everything so we either have an achievement or we have an elder. - else -- We came in without an input, therefore we add all. - local locz, locx, locy = unpack(elder_loc) - QH_FindCoord(locx, locy, locz, elder) + if trackedElders[elder] then trackedElders[elder] = nil + else + trackedElders[elder] = elder_info + elderCount = elderCount + 1 + end + end end end if achievement_match or elder_match then break end -- We've done our match. end + + if elderCount == 0 then QuestHelper:TextOut("No elders were added.") end end function QH_FindName(name) local locd = name:match("^loc (.+)") - local elder_loc + local forAchievement = false, elder_loc, temp if not locd then if name:find("^elders?") then - elder_loc = name:match("elders? (.+)") - if not elder_loc then elder_loc = true end + if name:find("^elders? achievement") then + forAchievement = true + elder_loc = name:match("elders? achievement (.+)") + else + elder_loc = name:match("elders? (.+)") + end end end if locd then QH_FindLoc(locd) elseif elder_loc then - if elder_loc == true then QH_FindElders(nil, true) - else QH_FindElders(string.upper(elder_loc)) + if elder_loc == true then QH_FindElders(nil, true, forAchievement) + else QH_FindElders(string.upper(elder_loc), false, forAchievement) end else if not DB_Ready() then @@ -286,10 +372,6 @@ function QH_FindName(name) --[[ assert(dbi) ]] if dbi.loc then --- Ugly database hack - if dbi.loc.p == 26 then dbi.loc.p = 48 end - if dbi.loc.p == 38 then dbi.loc.p = 168 end --- end hack table.insert(found_db, dbi) if has_name[dbi.name] then needs_postfix[dbi.name] = true end diff --git a/QuestHelper/director_quest.lua b/QuestHelper/director_quest.lua index 600091a..8ef125b 100644 --- a/QuestHelper/director_quest.lua +++ b/QuestHelper/director_quest.lua @@ -48,10 +48,6 @@ local function AppendObjlinks(target, source, tooltips, icon, last_name, map_lin for m, v in ipairs(source.loc) do QuestHelper: Assert(target) QuestHelper: Assert(QuestHelper_ParentLookup) --- Ugly database hack - if v.p == 26 then v.p = 48 end -- Alterac Mountains merged to Hillsbrad Foothills - if v.p == 38 then v.p = 168 end -- Ditto Stranglethorn --- end hack QuestHelper: Assert(QuestHelper_ParentLookup[v.p], v.p) table.insert(target, {loc = {x = v.x, y = v.y, c = QuestHelper_ParentLookup[v.p], p = v.p}, path_desc = copy(map_lines), icon_id = icon or 6}) end @@ -121,6 +117,7 @@ local function GetQuestMetaobjective(questid, lbcount, qindex) if not quest_list[questid] then local q = DB_GetItem("quest", questid, true, true) + --[==[ if not lbcount then QuestHelper: TextOut("Missing lbcount, guessing wildly") if q and q.criteria then @@ -132,16 +129,19 @@ local function GetQuestMetaobjective(questid, lbcount, qindex) lbcount = 0 -- heh end end + --]==] -- just doublechecking here if not QuestCriteriaWarningBroadcast and q and q.criteria then for k, v in pairs(q.criteria) do if type(k) == "number" and k > lbcount then - --QuestHelper:TextOut(string.format("Too many stored objectives for this quest, please report on the Questhelper homepage (%s %s %s)", questid, lbcount, k)) -- we're just going to hide this for now + QuestHelper:TextOut(string.format("Too many stored objectives for this quest, please report on the Questhelper homepage (%s %s %s)", questid, lbcount, k)) -- we're just going to hide this for now + --[==[ if qindex then QuestHelper_ErrorCatcher_ExplicitError(false, string.format("Too many stored objectives (%s %s %s %s)", questid, lbcount, k, select(1, GetQuestLogTitle(qindex)))) else QuestHelper_ErrorCatcher_ExplicitError(false, string.format("Too many stored objectives (%s %s %s %s)", questid, lbcount, k, v)) end + --]==] QuestCriteriaWarningBroadcast = true end end end @@ -159,13 +159,6 @@ local function GetQuestMetaobjective(questid, lbcount, qindex) if qindex < 0 or (desc and typ ~= "log") then -- Ignore if no description. --QuestHelper:TextOut(string.format("critty %d %d", k, c.loc and #c.loc or -1)) ---[[ - if done then - print(string.format("Quest %s, Objective %s('%s') is done.", qindex, i, desc)) - else - print(string.format("Quest %s, Objective %s('%s') is not done.", qindex, i, desc)) - end -]] ttx.tooltip_canned = {} if q and q.criteria and q.criteria[i] then @@ -181,7 +174,7 @@ local function GetQuestMetaobjective(questid, lbcount, qindex) end if #ttx == 0 then - table.insert(ttx, {loc = {x = 5000, y = 5000, c = 0, p = 2}, icon_id = 7, type_quest_unknown = true, map_desc = {"Unknown"}}) -- this is Ashenvale, for no particularly good reason + table.insert(ttx, {loc = {x = 5000, y = 5000, c = 0, p = 43}, icon_id = 7, type_quest_unknown = true, map_desc = {"Unknown"}}) -- this is Ashenvale, for no particularly good reason ttx.type_quest_unknown = true end @@ -201,32 +194,29 @@ local function GetQuestMetaobjective(questid, lbcount, qindex) end do - local ttx = {type_quest_finish = true} - --QuestHelper:TextOut(string.format("finny %d", q.finish.loc and #q.finish.loc or -1)) - if q and q.finish and q.finish.loc then - ttx.solid = horribledupe(q.finish.solid) - for m, v in ipairs(q.finish.loc) do - --print(v.rc, v.rz) - --print(QuestHelper_IndexLookup[v.rc]) - --print(QuestHelper_IndexLookup[v.rc][v.rz]) --- Ugly database hack - if v.p == 26 then v.p = 48 end - if v.p == 38 then v.p = 168 end --- end hack - table.insert(ttx, {desc = "Turn in quest", why = ite, loc = {x = v.x, y = v.y, c = QuestHelper_ParentLookup[v.p], p = v.p}, tracker_hidden = true, cluster = ttx, icon_id = 7, type_quest = ite.type_quest}) + if q and q.finish and q.loc then + local ttx = {type_quest_finish = true} + --QuestHelper:TextOut(string.format("finny %d", q.finish.loc and #q.finish.loc or -1)) + if q and q.finish and q.finish.loc then + ttx.solid = horribledupe(q.finish.solid) + for m, v in ipairs(q.finish.loc) do + --print(v.rc, v.rz) + --print(QuestHelper_IndexLookup[v.rc]) + --print(QuestHelper_IndexLookup[v.rc][v.rz]) + table.insert(ttx, {desc = "Turn in quest", why = ite, loc = {x = v.x, y = v.y, c = QuestHelper_ParentLookup[v.p], p = v.p}, tracker_hidden = true, cluster = ttx, icon_id = 7, type_quest = ite.type_quest}) + end end - end - if #ttx == 0 then - table.insert(ttx, {desc = "Turn in quest", why = ite, loc = {x = 5000, y = 5000, c = 0, p = 2}, tracker_hidden = true, cluster = ttx, icon_id = 7, type_quest = ite.type_quest, type_quest_unknown = true}) -- this is Ashenvale, for no particularly good reason - ttx.type_quest_unknown = true - end + if #ttx == 0 then + table.insert(ttx, {desc = "Turn in quest", why = ite, loc = {x = 5000, y = 5000, c = 0, p = 43}, tracker_hidden = true, cluster = ttx, icon_id = 7, type_quest = ite.type_quest, type_quest_unknown = true}) -- this is Ashenvale, for no particularly good reason + ttx.type_quest_unknown = true + end - ite.finish = ttx + ite.finish = ttx + end end quest_list[questid] = ite - if q then DB_ReleaseItem(q) end end @@ -812,7 +802,9 @@ function QH_UpdateQuests(force) end end - db.finish.tooltip_defer_questname = title -- we're using this as our fallback right now + if db.finish then + db.finish.tooltip_defer_questname = title -- we're using this as our fallback right now + end next_chunks[id] = chunk diff --git a/QuestHelper/dodads.lua b/QuestHelper/dodads.lua index 5898d8d..0ad4957 100644 --- a/QuestHelper/dodads.lua +++ b/QuestHelper/dodads.lua @@ -427,6 +427,26 @@ local function rightclick_menu(obj) end end +function QuestHelper:PlaceIconOnWorldMap( worldMapFrame, icon, map, dLvl, xPos, yPos ) + assert(type(worldMapFrame) == "table") + assert(worldMapFrame.GetWidth and worldmapFrame.GetHeight) + assert(type(icon) == "table") + assert(icon.SetPoint and icon.ClearAllPoints) + assert(type(map) == "number") + assert(type(dLvl) == "number" or dLvl == nil) + assert(type(xPos) == "number") + assert(type(yPos) == "number") + + if dLvl == nil then dLvl = 0 end + if map == -1 then return end -- Can't do anything without continent knowledge + + local nMap, nFloor = GetCurrentMapAreaID(), GetCurrentMapDungeonLevel() or 0 + + local nCont + + if nMap == -1 then cont = GetCurrentMapContinent() end +end + function QuestHelper:CreateWorldMapDodad(objective, nxt) local icon = CreateFrame("Button", nil, QuestHelper.map_overlay) icon:SetFrameStrata("FULLSCREEN") diff --git a/QuestHelper/graph_core.lua b/QuestHelper/graph_core.lua index 9400c74..7958496 100644 --- a/QuestHelper/graph_core.lua +++ b/QuestHelper/graph_core.lua @@ -151,17 +151,8 @@ function QH_Graph_Pathmultifind(st, nda, reverse, make_path) --stats.dests_complex = 0 --stats.dests_total = 0 --- Ugly database hack - if st.p == 26 then st.p = 48 end -- Alterac Mountains merged to Hillsbrad Foothills - if st.p == 38 then st.p = 168 end -- Ditto Stranglethorn --- end hack - for k, v in ipairs(nda) do QuestHelper: Assert(v.x and v.y and v.p) --- Ugly database hack pt. 2 - if v.p == 26 then v.p = 48 end -- Alterac Mountains merged to Hillsbrad Foothills - if v.p == 38 then v.p = 168 end -- Ditto Stranglethorn --- end hack local cpvp = canoplane(v.p) if plane[cpvp] then --print("Destination plane insertion") diff --git a/QuestHelper/libs/AstrolabeQH/Astrolabe.lua b/QuestHelper/libs/AstrolabeQH/Astrolabe.lua index 5d6bfac..012d6b3 100644 --- a/QuestHelper/libs/AstrolabeQH/Astrolabe.lua +++ b/QuestHelper/libs/AstrolabeQH/Astrolabe.lua @@ -194,7 +194,6 @@ function Astrolabe:GetMapVirtualZones(zone) return {[1] = k} end end - local curMapID = GetCurrentMapAreaID() local zones = {GetMapZones(zone)} @@ -290,6 +289,8 @@ function Astrolabe:ComputeDistance( c1, z1, x1, y1, c2, z2, x2, y2 ) return dist, xDelta, yDelta; end +local yards + function Astrolabe:TranslateWorldMapPosition( C, Z, xPos, yPos, nC, nZ ) --[[ argcheck(C, 2, "number"); @@ -326,7 +327,7 @@ function Astrolabe:TranslateWorldMapPosition( C, Z, xPos, yPos, nC, nZ ) zoneData = WorldMapSize[C]; local parentContinent = zoneData.parentContinent; xPos, yPos = getContPosition(zoneData, Z, xPos, yPos); - if not xPos or not yPos then return end -- there is no such zone. why are you asking me such silly things? you are a terrible person. leave me in my despair. + if not xPos or not yPos then return end -- there is no such zone. why are you asking me such silly things? you are a terrible person. leave me in my despair. if ( C ~= parentContinent ) then -- translate up to world map if we aren't there already xPos = xPos + zoneData.xOffset; @@ -380,6 +381,14 @@ function Astrolabe:GetZoneWidth(c, z) end end +function Astrolabe:GetZoneHeight(c, z) + if z ~= 0 then + return WorldMapSize[c][z].height + else + return WorldMapSize[c].height + end +end + --***************************************************************************** -- This function will do its utmost to retrieve some sort of valid position -- for the specified unit, including changing the current map zoom (if needed). @@ -1197,8 +1206,8 @@ WorldMapSize = { AhnQirajTheFallenKingdom = { height = 2700.0, width = 4049.99983215332, - xOffset = 0, - yOffset = 0, + xOffset = -3891.6665, + yOffset = -8033.333, mapID = 772 }, Ashenvale = { @@ -1223,8 +1232,8 @@ WorldMapSize = { mapID = 3524, }, Barrens = { - height = 6756.202067150937, - width = 10133.44343943073, + height = 3831.24987792969, + width = 5745.83332824707, xOffset = 14443.84117394525, yOffset = 11187.32013604393, mapID = 17, @@ -1288,15 +1297,15 @@ WorldMapSize = { Hyjal = { height = 2831.24975585938, width = 4245.83337402344, - xOffset = 0, - yOffset = 0, + xOffset = 929.167, + yOffset = 6195.833, mapID = 606 }, Hyjal_terrain1 = { height = 2831.24975585938, width = 4245.83337402344, - xOffset = 0, - yOffset = 0, + xOffset = 929.167, + yOffset = 6195.833, mapID = 683 }, Moonglade = { @@ -1330,8 +1339,8 @@ WorldMapSize = { SouthernBarrens = { height = 4941.66665649414, width = 7412.5, - xOffset = 0, - yOffset = 0, + xOffset = -1356.25, + yOffset = 204.167, mapID = 607 }, StonetalonMountains = { @@ -1379,8 +1388,8 @@ WorldMapSize = { Uldum = { height = 4129.16650390625, width = 6193.74975585938, - xOffset = 0, - yOffset = 0, + xOffset = -2441.667, + yOffset = -8029.1665, mapID = 720 }, UngoroCrater = { @@ -1520,17 +1529,17 @@ WorldMapSize = { mapID = 44, }, RuinsofGilneas = { - height = 889.583251953125, - width = 593.749877929688, - xOffset = 0, - yOffset = 0, + height = 2097.916668701172, + width = 3145.83325195312, + xOffset = -3439.583, + yOffset = -533.333, mapID = 611 }, RuinsofGilneasCity = { height = 889.583251953125, width = 593.749877929688, - xOffset = 0, - yOffset = 0, + xOffset = -1933.333, + yOffset = -1306.25, mapID = 685 }, SearingGorge = { @@ -1562,8 +1571,8 @@ WorldMapSize = { mapID = 1519, }, StranglethornVale = { -- Split to Vale, Jungle and Cape - height = 4254.18312444072, - width = 6381.248484543122, + height = 4368.75, + width = 6552.0830078125, xOffset = 15951.13375783437, yOffset = 22345.18258706305, mapID = 33, @@ -1571,8 +1580,8 @@ WorldMapSize = { StranglethornJungle = { height = 2733.3330078125, width = 4099.99987792969, - xOffset = 0, - yOffset = 0, + xOffset = -1743.750, + yOffset = -11016.666, mapID = 37 }, Sunwell = { @@ -1592,8 +1601,8 @@ WorldMapSize = { TheCapeOfStranglethorn = { height = 2631.25, width = 3945.83312988281, - xOffset = 0, - yOffset = 0, + xOffset = -2108.333, + yOffset = -12516.666, mapID = 673 }, Tirisfal = { @@ -1606,29 +1615,29 @@ WorldMapSize = { TolBarad = { height = 1343.75, width = 2014.58329248428, - xOffset = 0, - yOffset = 0, + xOffset = -2010.417, + yOffset = -560.417, mapID = 708 }, TolBaradDailyArea = { height = 1224.99993896484, width = 1837.5, - xOffset = 0, - yOffset = 0, + xOffset = -2412.5, + yOffset = 377.083, mapID = 709 }, TwilightHighlands = { height = 3514.5830078125, width = 5270.8330078125, - xOffset = 0, - yOffset = 0, + xOffset = 2437.5, + yOffset = -2156.25, mapID = 700 }, TwilightHighlands_terrain1 = { height = 3514.5830078125, width = 5270.8330078125, - xOffset = 0, - yOffset = 0, + xOffset = 2437.5, + yOffset = -2156.25, mapID = 770 }, Undercity = { @@ -1641,29 +1650,29 @@ WorldMapSize = { Vashjir = { height = 4631.24975585938, width = 6945.83276367188, - xOffset = 0, - yOffset = 0, + xOffset = -8754.166, + yOffset = -3720.833, mapID = 613 }, VashjirDepths = { height = 2716.66650390625, width = 4075.0, - xOffset = 0, - yOffset = 0, + xOffset = -8233.333, + yOffset = -4906.25, mapID = 614 }, VashjirKelpForest = { height = 1868.75024414062, width = 2802.0830078125, - xOffset = 0, - yOffset = 0, + xOffset = -5070.833, + yOffset = -4018.75, mapID = 610 }, VashjirRuins = { height = 3233.3330078125, width = 4849.99963378906, - xOffset = 0, - yOffset = 0, + xOffset = -6681.25, + yOffset = -4756.25, mapID = 615 }, WesternPlaguelands = { @@ -1841,10 +1850,10 @@ WorldMapSize = { mapID = 66, }, HrothgarsLanding = { - height = 2452.7, - width = 2452.7*1.5, - xOffset = 23967.599 - 17549.182, - yOffset = 1027.392 - 1215.431, + height = 2452.083984375, + width = 3677.08312988281, + xOffset = 6418.417, + yOffset = -188.039, } }, }, @@ -1856,12 +1865,12 @@ WorldMapSize = { xOffset = 0.0, yOffset = 0.0, zoneData = { - Deepholm = { height = 3399.999877929688, width = 5099.9987792969, xOffset = 0, yOffset = 0, mapID = 640 }, - Kezan = { height = 900.00048828125, width = 1352.08319091797, xOffset = 0, yOffset = 0, mapID = 605 }, - TheLostIsles = { height = 3010.41665649414, width = 4514.5830078125, xOffset = 0, yOffset = 0, mapID = 544 }, - TheLostIsles_terrain1 = { height = 3010.41665649414, width = 4514.5830078125, xOffset = 0, yOffset = 0, mapID = 681 }, - TheLostIsles_terrain2 = { height = 3010.41665649414, width = 4514.5830078125, xOffset = 0, yOffset = 0, mapID = 682 }, - TheMaelstrom = { height = 1033.33325195312, width = 1550.0, xOffset = 0, yOffset = 0, mapID = 737 } + Deepholm = { height = 3399.999877929688, width = 5099.9987792969, xOffset = -3052.083, yOffset = 2795.833, mapID = 640 }, + Kezan = { height = 900.00048828125, width = 1352.08319091797, xOffset = -2129.167, yOffset = -7731.25, mapID = 605 }, + TheLostIsles = { height = 3010.41665649414, width = 4514.5830078125, xOffset = -4383.333, yOffset = 2881.25, mapID = 544 }, + TheLostIsles_terrain1 = { height = 3010.41665649414, width = 4514.5830078125, xOffset = -4383.333, yOffset = 2881.25, mapID = 681 }, + TheLostIsles_terrain2 = { height = 3010.41665649414, width = 4514.5830078125, xOffset = -4383.333, yOffset = 2881.25, mapID = 682 }, + TheMaelstrom = { height = 1033.33325195312, width = 1550.0, xOffset = -1556.25, yOffset = 1370.833, mapID = 737 } } } } @@ -1947,65 +1956,65 @@ VContinent(-118, "PitofSaron", 1022.3) VirtualContinentIndexes = { -- Don't change values here, since programs might want to store them ["ScarletEnclave"] = -77, - ["GilneasCity"] = -78, - ["GilneasZone"] = -79, +-- ["GilneasCity"] = -78, +-- ["GilneasZone"] = -79, - ["UtgardeKeep1"] = -80, - ["UtgardeKeep2"] = -81, - ["UtgardeKeep3"] = -82, +-- ["UtgardeKeep1"] = -80, +-- ["UtgardeKeep2"] = -81, +-- ["UtgardeKeep3"] = -82, - ["TheNexus"] = -83, +-- ["TheNexus"] = -83, - ["AzjolNerub1"] = -84, - ["AzjolNerub2"] = -85, - ["AzjolNerub3"] = -86, +-- ["AzjolNerub1"] = -84, +-- ["AzjolNerub2"] = -85, +-- ["AzjolNerub3"] = -86, - ["Ahnkahet"] = -87, +-- ["Ahnkahet"] = -87, - ["DrakTharonKeep1"] = -88, - ["DrakTharonKeep2"] = -89, +-- ["DrakTharonKeep1"] = -88, +-- ["DrakTharonKeep2"] = -89, - ["VioletHold"] = -90, +-- ["VioletHold"] = -90, - ["Gundrak"] = -91, +-- ["Gundrak"] = -91, - ["Ulduar77"] = -92, -- Halls of Stone +-- ["Ulduar77"] = -92, -- Halls of Stone - ["HallsofLightning1"] = -93, - ["HallsofLightning2"] = -94, +-- ["HallsofLightning1"] = -93, +-- ["HallsofLightning2"] = -94, - ["Nexus801"] = -95, -- Oculus - ["Nexus802"] = -96, - ["Nexus803"] = -97, - ["Nexus804"] = -98, +-- ["Nexus801"] = -95, -- Oculus +-- ["Nexus802"] = -96, +-- ["Nexus803"] = -97, +-- ["Nexus804"] = -98, - ["CoTStratholme1"] = -99, - ["CoTStratholme2"] = -100, +-- ["CoTStratholme1"] = -99, +-- ["CoTStratholme2"] = -100, - ["UtgardePinnacle1"] = -101, -- hey they spelled it right - ["UtgardePinnacle2"] = -102, +-- ["UtgardePinnacle1"] = -101, -- hey they spelled it right +-- ["UtgardePinnacle2"] = -102, - ["VaultofArchavon"] = -103, -- Weirdly, Emalon is actually within the "Vault of Archavon" +-- ["VaultofArchavon"] = -103, -- Weirdly, Emalon is actually within the "Vault of Archavon" - ["Naxxramas1"] = -104, - ["Naxxramas2"] = -105, - ["Naxxramas3"] = -106, - ["Naxxramas4"] = -107, - ["Naxxramas5"] = -108, - ["Naxxramas6"] = -109, +-- ["Naxxramas1"] = -104, +-- ["Naxxramas2"] = -105, +-- ["Naxxramas3"] = -106, +-- ["Naxxramas4"] = -107, +-- ["Naxxramas5"] = -108, +-- ["Naxxramas6"] = -109, - ["TheObsidianSanctum"] = -110, +-- ["TheObsidianSanctum"] = -110, - ["TheEyeOfEternity"] = -111, +-- ["TheEyeOfEternity"] = -111, - ["Ulduar"] = -112, - ["Ulduar1"] = -113, - ["Ulduar2"] = -114, - ["Ulduar3"] = -115, - ["Ulduar4"] = -116, +-- ["Ulduar"] = -112, +-- ["Ulduar1"] = -113, +-- ["Ulduar2"] = -114, +-- ["Ulduar3"] = -115, +-- ["Ulduar4"] = -116, - ["TheForgeofSouls"] = -117, - ["PitofSaron"] = -118 +-- ["TheForgeofSouls"] = -117, +-- ["PitofSaron"] = -118 --[[ ["AbyssalMaw"] = -120, ["ThroneOfTheTides"] = -130, diff --git a/QuestHelper/libs/LibMapData-1.0/Changelog-LibMapData-1.0-0.21-release.txt b/QuestHelper/libs/LibMapData-1.0/Changelog-LibMapData-1.0-0.21-release.txt new file mode 100644 index 0000000..80783cb --- /dev/null +++ b/QuestHelper/libs/LibMapData-1.0/Changelog-LibMapData-1.0-0.21-release.txt @@ -0,0 +1,25 @@ +------------------------------------------------------------------------ +r100 | kagaro | 2011-12-02 00:28:58 +0000 (Fri, 02 Dec 2011) | 1 line +Changed paths: + A /tags/0.21-release (from /trunk:99) + +Tagging as 0.21-release +------------------------------------------------------------------------ +r99 | kagaro | 2011-12-02 00:27:41 +0000 (Fri, 02 Dec 2011) | 1 line +Changed paths: + M /trunk/library.lua + +Updated lib from forum tests that shows game data incorrect +------------------------------------------------------------------------ +r97 | kagaro | 2011-11-29 12:06:46 +0000 (Tue, 29 Nov 2011) | 1 line +Changed paths: + M /trunk/LibMapData-1.0.toc + +toc bump +------------------------------------------------------------------------ +r96 | kagaro | 2011-11-28 13:01:19 +0000 (Mon, 28 Nov 2011) | 1 line +Changed paths: + M /trunk/library.lua + +Adding 4.3 zone data +------------------------------------------------------------------------ diff --git a/QuestHelper/libs/LibMapData-1.0/LibMapData-1.0.toc b/QuestHelper/libs/LibMapData-1.0/LibMapData-1.0.toc new file mode 100644 index 0000000..a15d536 --- /dev/null +++ b/QuestHelper/libs/LibMapData-1.0/LibMapData-1.0.toc @@ -0,0 +1,14 @@ +## Interface: 40300 +## Title: Lib: MapData-1.0 +## Notes: Static library of wow map data +## Version: 1.0.99 +## Author: kagaro +## X-Category: Library +## X-Curse-Packaged-Version: 0.21-release +## X-Curse-Project-Name: LibMapData-1.0 +## X-Curse-Project-ID: libmapdata-1-0 +## X-Curse-Repository-ID: wow/libmapdata-1-0/mainline + +library.lua +Libs/LibStub/LibStub.lua +Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml diff --git a/QuestHelper/libs/LibMapData-1.0/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua b/QuestHelper/libs/LibMapData-1.0/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua new file mode 100644 index 0000000..e0fe1af --- /dev/null +++ b/QuestHelper/libs/LibMapData-1.0/Libs/CallbackHandler-1.0/CallbackHandler-1.0.lua @@ -0,0 +1,240 @@ +--[[ $Id: CallbackHandler-1.0.lua 14 2010-08-09 00:43:38Z mikk $ ]] +local MAJOR, MINOR = "CallbackHandler-1.0", 6 +local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) + +if not CallbackHandler then return end -- No upgrade needed + +local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end} + +-- Lua APIs +local tconcat = table.concat +local assert, error, loadstring = assert, error, loadstring +local setmetatable, rawset, rawget = setmetatable, rawset, rawget +local next, select, pairs, type, tostring = next, select, pairs, type, tostring + +-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded +-- List them here for Mikk's FindGlobals script +-- GLOBALS: geterrorhandler + +local xpcall = xpcall + +local function errorhandler(err) + return geterrorhandler()(err) +end + +local function CreateDispatcher(argCount) + local code = [[ + local next, xpcall, eh = ... + + local method, ARGS + local function call() method(ARGS) end + + local function dispatch(handlers, ...) + local index + index, method = next(handlers) + if not method then return end + local OLD_ARGS = ARGS + ARGS = ... + repeat + xpcall(call, eh) + index, method = next(handlers, index) + until not method + ARGS = OLD_ARGS + end + + return dispatch + ]] + + local ARGS, OLD_ARGS = {}, {} + for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end + code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", ")) + return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler) +end + +local Dispatchers = setmetatable({}, {__index=function(self, argCount) + local dispatcher = CreateDispatcher(argCount) + rawset(self, argCount, dispatcher) + return dispatcher +end}) + +-------------------------------------------------------------------------- +-- CallbackHandler:New +-- +-- target - target object to embed public APIs in +-- RegisterName - name of the callback registration API, default "RegisterCallback" +-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback" +-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API. + +function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused) + -- TODO: Remove this after beta has gone out + assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused") + + RegisterName = RegisterName or "RegisterCallback" + UnregisterName = UnregisterName or "UnregisterCallback" + if UnregisterAllName==nil then -- false is used to indicate "don't want this method" + UnregisterAllName = "UnregisterAllCallbacks" + end + + -- we declare all objects and exported APIs inside this closure to quickly gain access + -- to e.g. function names, the "target" parameter, etc + + + -- Create the registry object + local events = setmetatable({}, meta) + local registry = { recurse=0, events=events } + + -- registry:Fire() - fires the given event/message into the registry + function registry:Fire(eventname, ...) + if not rawget(events, eventname) or not next(events[eventname]) then return end + local oldrecurse = registry.recurse + registry.recurse = oldrecurse + 1 + + Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...) + + registry.recurse = oldrecurse + + if registry.insertQueue and oldrecurse==0 then + -- Something in one of our callbacks wanted to register more callbacks; they got queued + for eventname,callbacks in pairs(registry.insertQueue) do + local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten. + for self,func in pairs(callbacks) do + events[eventname][self] = func + -- fire OnUsed callback? + if first and registry.OnUsed then + registry.OnUsed(registry, target, eventname) + first = nil + end + end + end + registry.insertQueue = nil + end + end + + -- Registration of a callback, handles: + -- self["method"], leads to self["method"](self, ...) + -- self with function ref, leads to functionref(...) + -- "addonId" (instead of self) with function ref, leads to functionref(...) + -- all with an optional arg, which, if present, gets passed as first argument (after self if present) + target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]]) + if type(eventname) ~= "string" then + error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2) + end + + method = method or eventname + + local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten. + + if type(method) ~= "string" and type(method) ~= "function" then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2) + end + + local regfunc + + if type(method) == "string" then + -- self["method"] calling style + if type(self) ~= "table" then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2) + elseif self==target then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2) + elseif type(self[method]) ~= "function" then + error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2) + end + + if select("#",...)>=1 then -- this is not the same as testing for arg==nil! + local arg=select(1,...) + regfunc = function(...) self[method](self,arg,...) end + else + regfunc = function(...) self[method](self,...) end + end + else + -- function ref with self=object or self="addonId" or self=thread + if type(self)~="table" and type(self)~="string" and type(self)~="thread" then + error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2) + end + + if select("#",...)>=1 then -- this is not the same as testing for arg==nil! + local arg=select(1,...) + regfunc = function(...) method(arg,...) end + else + regfunc = method + end + end + + + if events[eventname][self] or registry.recurse<1 then + -- if registry.recurse<1 then + -- we're overwriting an existing entry, or not currently recursing. just set it. + events[eventname][self] = regfunc + -- fire OnUsed callback? + if registry.OnUsed and first then + registry.OnUsed(registry, target, eventname) + end + else + -- we're currently processing a callback in this registry, so delay the registration of this new entry! + -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency + registry.insertQueue = registry.insertQueue or setmetatable({},meta) + registry.insertQueue[eventname][self] = regfunc + end + end + + -- Unregister a callback + target[UnregisterName] = function(self, eventname) + if not self or self==target then + error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2) + end + if type(eventname) ~= "string" then + error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2) + end + if rawget(events, eventname) and events[eventname][self] then + events[eventname][self] = nil + -- Fire OnUnused callback? + if registry.OnUnused and not next(events[eventname]) then + registry.OnUnused(registry, target, eventname) + end + end + if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then + registry.insertQueue[eventname][self] = nil + end + end + + -- OPTIONAL: Unregister all callbacks for given selfs/addonIds + if UnregisterAllName then + target[UnregisterAllName] = function(...) + if select("#",...)<1 then + error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2) + end + if select("#",...)==1 and ...==target then + error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2) + end + + + for i=1,select("#",...) do + local self = select(i,...) + if registry.insertQueue then + for eventname, callbacks in pairs(registry.insertQueue) do + if callbacks[self] then + callbacks[self] = nil + end + end + end + for eventname, callbacks in pairs(events) do + if callbacks[self] then + callbacks[self] = nil + -- Fire OnUnused callback? + if registry.OnUnused and not next(callbacks) then + registry.OnUnused(registry, target, eventname) + end + end + end + end + end + end + + return registry +end + + +-- CallbackHandler purposefully does NOT do explicit embedding. Nor does it +-- try to upgrade old implicit embeds since the system is selfcontained and +-- relies on closures to work. + diff --git a/QuestHelper/libs/LibMapData-1.0/Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml b/QuestHelper/libs/LibMapData-1.0/Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml new file mode 100644 index 0000000..1aad3a2 --- /dev/null +++ b/QuestHelper/libs/LibMapData-1.0/Libs/CallbackHandler-1.0/CallbackHandler-1.0.xml @@ -0,0 +1,4 @@ + +