Add Flight Finder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-12 14:47:59 +00:00
parent e2f18f5fd6
commit 0a810dc451
9 changed files with 720 additions and 2 deletions

73
FlightFinder/Data.lua Normal file
View file

@ -0,0 +1,73 @@
-- Generated by tools/generate.py from TaxiNodes.db2. Do not edit.
-- [nodeID] = { instance, world x, world y, faction, name }
local _, ns = ...
ns.nodes = {
[2] = { 0, -8832.8, 478.6, "Alliance", "Stormwind, Elwynn" },
[4] = { 0, -10628.9, 1036.7, "Alliance", "Sentinel Hill, Westfall" },
[5] = { 0, -9429.1, -2231.4, "Alliance", "Lakeshire, Redridge" },
[6] = { 0, -4821.8, -1155.4, "Alliance", "Ironforge, Dun Morogh" },
[7] = { 0, -3792.3, -783.3, "Alliance", "Menethil Harbor, Wetlands" },
[8] = { 0, -5421.9, -2930.0, "Alliance", "Thelsamar, Loch Modan" },
[10] = { 0, 478.9, 1536.6, "Horde", "The Sepulcher, Silverpine Forest" },
[11] = { 0, 1568.6, 268.0, "Horde", "Undercity, Tirisfal" },
[12] = { 0, -10515.5, -1261.7, "Alliance", "Darkshire, Duskwood" },
[13] = { 0, -0.1, -859.9, "Horde", "Tarren Mill, Hillsbrad" },
[14] = { 0, -711.5, -515.5, "Alliance", "Southshore, Hillsbrad" },
[16] = { 0, -1240.5, -2515.1, "Alliance", "Refuge Pointe, Arathi" },
[17] = { 0, -916.3, -3496.9, "Horde", "Hammerfall, Arathi" },
[18] = { 0, -14444.3, 509.6, "Horde", "Booty Bay, Stranglethorn" },
[19] = { 0, -14473.0, 464.1, "Alliance", "Booty Bay, Stranglethorn" },
[20] = { 0, -12414.2, 146.3, "Horde", "Grom'gol, Stranglethorn" },
[21] = { 0, -6634.0, -2180.1, "Horde", "Kargath, Badlands" },
[22] = { 1, -1197.2, 29.7, "Horde", "Thunder Bluff, Mulgore" },
[23] = { 1, 1677.6, -4315.7, "Horde", "Orgrimmar, Durotar" },
[25] = { 1, -441.8, -2596.1, "Horde", "Crossroads, The Barrens" },
[26] = { 1, 6341.4, 557.7, "Alliance", "Auberdine, Darkshore" },
[27] = { 1, 8643.6, 841.0, "Alliance", "Rut'theran Village, Teldrassil" },
[28] = { 1, 2827.3, -289.2, "Alliance", "Astranaar, Ashenvale" },
[29] = { 1, 966.6, 1040.3, "Horde", "Sun Rock Retreat, Stonetalon Mountains" },
[30] = { 1, -5407.7, -2414.3, "Horde", "Freewind Post, Thousand Needles" },
[31] = { 1, -4491.9, -775.9, "Alliance", "Thalanaar, Feralas" },
[32] = { 1, -3825.4, -4516.6, "Alliance", "Theramore, Dustwallow Marsh" },
[33] = { 1, 2681.1, 1461.7, "Alliance", "Stonetalon Peak, Stonetalon Mountains" },
[37] = { 1, 139.2, 1325.8, "Alliance", "Nijel's Point, Desolace" },
[38] = { 1, -1767.6, 3263.9, "Horde", "Shadowprey Village, Desolace" },
[39] = { 1, -7224.0, -3734.6, "Alliance", "Gadgetzan, Tanaris" },
[40] = { 1, -7048.9, -3780.4, "Horde", "Gadgetzan, Tanaris" },
[41] = { 1, -4373.8, 3338.6, "Alliance", "Feathermoon, Feralas" },
[42] = { 1, -4419.9, 199.3, "Horde", "Camp Mojache, Feralas" },
[43] = { 0, 283.7, -2002.8, "Alliance", "Aerie Peak, The Hinterlands" },
[44] = { 1, 3661.5, -4390.4, "Horde", "Valormok, Azshara" },
[45] = { 0, -11112.2, -3435.7, "Alliance", "Nethergarde Keep, Blasted Lands" },
[48] = { 1, 5068.4, -337.2, "Horde", "Bloodvenom Post, Felwood" },
[49] = { 1, 7458.5, -2487.2, "Alliance", "Moonglade" },
[52] = { 1, 6799.2, -4742.4, "Alliance", "Everlook, Winterspring" },
[53] = { 1, 6813.1, -4611.1, "Horde", "Everlook, Winterspring" },
[55] = { 1, -3147.4, -2842.2, "Horde", "Brackenwall Village, Dustwallow Marsh" },
[56] = { 0, -10457.0, -3279.2, "Horde", "Stonard, Swamp of Sorrows" },
[58] = { 1, 3374.7, 997.0, "Horde", "Zoram'gar Outpost, Ashenvale" },
[61] = { 1, 2302.4, -2524.6, "Horde", "Splintertree Post, Ashenvale" },
[64] = { 1, 2722.0, -3880.6, "Alliance", "Talrendis Point, Azshara" },
[65] = { 1, 6205.9, -1949.6, "Alliance", "Talonbranch Glade, Felwood" },
[66] = { 0, 931.3, -1430.1, "Alliance", "Chillwind Camp, Western Plaguelands" },
[67] = { 0, 2271.1, -5340.8, "Alliance", "Light's Hope Chapel, Eastern Plaguelands" },
[68] = { 0, 2327.4, -5286.9, "Horde", "Light's Hope Chapel, Eastern Plaguelands" },
[69] = { 1, 7470.4, -2123.4, "Horde", "Moonglade" },
[70] = { 0, -7504.0, -2187.5, "Horde", "Flame Crest, Burning Steppes" },
[71] = { 0, -8364.6, -2738.4, "Alliance", "Morgan's Vigil, Burning Steppes" },
[72] = { 1, -6811.4, 836.7, "Horde", "Cenarion Hold, Silithus" },
[73] = { 1, -6761.8, 772.0, "Alliance", "Cenarion Hold, Silithus" },
[74] = { 0, -6552.6, -1168.3, "Alliance", "Thorium Point, Searing Gorge" },
[75] = { 0, -6554.9, -1100.1, "Horde", "Thorium Point, Searing Gorge" },
[76] = { 0, -635.3, -4720.5, "Horde", "Revantusk Village, The Hinterlands" },
[77] = { 1, -2380.7, -1882.7, "Horde", "Camp Taurajo, The Barrens" },
[79] = { 1, -6113.8, -1142.7, "Neutral", "Marshal's Refuge, Un'Goro Crater" },
[80] = { 1, -894.6, -3773.0, "Neutral", "Ratchet, The Barrens" },
[559] = { 1, 5283.2, -3306.7, "Neutral", "Summit of Eternity, Mount Hyjal" },
[3203] = { 0, -7923.7, -4783.0, "Horde", "Rog'mar, Riverglades" },
[3242] = { 1, 4393.5, -2836.4, "Neutral", "Tainted Foothills, Mount Hyjal" },
[3274] = { 0, -8157.2, -5724.7, "Neutral", "Powderfuse Port, Riverglades" },
[3275] = { 0, -8180.0, -5616.3, "Neutral", "Powderfuse Port, Riverglades" },
[3276] = { 0, -9104.1, -4830.5, "Alliance", "Farholde Keep, Riverglades" },
}

View file

@ -0,0 +1,355 @@
-- Flight Finder: marks the flight masters you haven't discovered yet on zone and continent
-- maps. Flight master positions are in Data.lua (generated from the client's TaxiNodes.db2).
--
-- A flight point counts as discovered when Blizzard's map API lists it as discovered for its
-- zone, or when a flight master's taxi map showed it as a destination. Both are remembered
-- per character, so continent maps and zones you haven't opened yet stay right.
local addonName, ns = ...
local PREFIX = "|cff66bbffFlight Finder|r: "
local TEMPLATE = "FlightFinderPinTemplate"
local GLYPH = "Interface\\Minimap\\Tracking\\FlightMaster"
local COLORS = {
Alliance = { 0.35, 0.62, 1.00 },
Horde = { 1.00, 0.32, 0.24 },
Neutral = { 1.00, 0.82, 0.25 },
}
local SAME_PLACE = 400 -- yards: flight masters with one name this close count as one place
local db, known
local function Visible(id)
local f = ns.nodes[id][4]
return f == "Neutral" or f == UnitFactionGroup("player")
end
---------------------------------------------------------------------------
-- Groups: one marker per place, discovered if any of its flight masters is
---------------------------------------------------------------------------
local groups, byName = {}, {}
for id, n in pairs(ns.nodes) do
byName[n[5]] = byName[n[5]] or {}
table.insert(byName[n[5]], id)
end
for _, ids in pairs(byName) do
table.sort(ids)
for _, a in ipairs(ids) do
local g = {}
for _, b in ipairs(ids) do
local na, nb = ns.nodes[a], ns.nodes[b]
if na[1] == nb[1] and math.sqrt((na[2] - nb[2]) ^ 2 + (na[3] - nb[3]) ^ 2) <= SAME_PLACE then
g[#g + 1] = b
end
end
groups[a] = g
end
end
ns.groups, ns.byName = groups, byName
local function Discovered(id)
for _, other in ipairs(groups[id]) do
if known[other] and Visible(other) then
return true
end
end
return false
end
-- the marker for a place goes on its lowest visible node
local function Leader(id)
for _, other in ipairs(groups[id]) do
if Visible(other) then
return other == id
end
end
return false
end
---------------------------------------------------------------------------
-- Projection: world position -> position on a uiMap, and which maps a node sits in
---------------------------------------------------------------------------
local rects = {}
local function Rect(uiMapID)
local cached = rects[uiMapID]
if cached ~= nil then
return cached or nil
end
local r = false
local inst, topLeft = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0, 0))
local _, mid = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0.5, 0.5))
if inst and topLeft and mid then
local top, left = topLeft:GetXY()
local midTop, midLeft = mid:GetXY()
local height, width = (top - midTop) * 2, (left - midLeft) * 2
if height ~= 0 and width ~= 0 then
r = { inst = inst, top = top, left = left, height = height, width = width }
end
end
rects[uiMapID] = r
return r or nil
end
local function Project(uiMapID, id)
local r, n = Rect(uiMapID), ns.nodes[id]
if not r or r.inst ~= n[1] then
return nil
end
local u, v = (r.left - n[3]) / r.width, (r.top - n[2]) / r.height
if u < 0 or u > 1 or v < 0 or v > 1 then
return nil
end
return u, v
end
ns.Project = Project
-- the map the client places a node on, plus every map above it
local chains = {}
local function Chain(id)
local c = chains[id]
if c then
return c
end
local n = ns.nodes[id]
c = { maps = {} }
local ok, mapID = pcall(C_Map.GetMapPosFromWorldPos, n[1], CreateVector2D(n[2], n[3]))
for _ = 1, 10 do
if not ok or not mapID or mapID == 0 or c.maps[mapID] then
break
end
local info = C_Map.GetMapInfo(mapID)
if not info then
break
end
c.maps[mapID] = true
c.found = true
if not c.zone and info.mapType == Enum.UIMapType.Zone then
c.zone = mapID
end
mapID = info.parentMapID
end
chains[id] = c
return c
end
-- whether node id belongs on uiMapID, and where
local function Place(uiMapID, mapType, id)
local c = Chain(id)
if c.found then
if not c.maps[uiMapID] then
return nil
end
elseif mapType ~= Enum.UIMapType.Continent then
return nil -- client can't say which zone it's in: only trust the continent map
end
return Project(uiMapID, id)
end
---------------------------------------------------------------------------
-- Learning which flight points the character has
---------------------------------------------------------------------------
-- Blizzard's own map list for a zone; learns its discovered nodes
local function LearnZone(uiMapID)
if not (C_TaxiMap and C_TaxiMap.GetTaxiNodesForMap) then
return
end
local ok, list = pcall(C_TaxiMap.GetTaxiNodesForMap, uiMapID)
if ok and type(list) == "table" then
for _, info in ipairs(list) do
if info.nodeID and not info.isUndiscovered then
known[info.nodeID] = true
end
end
end
end
-- a flight master's taxi map lists every node on the continent; "NONE" ones aren't known yet
local function LearnTaxiMap()
if not (NumTaxiNodes and TaxiNodeName and TaxiNodeGetType) then
return
end
for i = 1, NumTaxiNodes() do
if TaxiNodeGetType(i) ~= "NONE" then
for _, id in ipairs(byName[TaxiNodeName(i)] or {}) do
if Visible(id) then
known[id] = true
end
end
end
end
end
ns.LearnTaxiMap = LearnTaxiMap
---------------------------------------------------------------------------
-- Map data provider
---------------------------------------------------------------------------
local SHOWN_ON = {
[Enum.UIMapType.Continent] = true,
[Enum.UIMapType.Zone] = true,
[Enum.UIMapType.Micro or 5] = true,
}
local provider = CreateFromMixins(MapCanvasDataProviderMixin)
ns.provider = provider
function provider:RemoveAllData()
self:GetMap():RemoveAllPinsByTemplate(TEMPLATE)
end
function provider:RefreshAllData()
self:RemoveAllData()
if db.hidden then
return
end
local map = self:GetMap()
local mapID = map:GetMapID()
local info = mapID and C_Map.GetMapInfo(mapID)
if not info or not SHOWN_ON[info.mapType] then
return
end
local learned = {}
for id in pairs(ns.nodes) do
if Visible(id) and Leader(id) then
local u, v = Place(mapID, info.mapType, id)
if u then
local zone = Chain(id).zone
if zone and not learned[zone] then
learned[zone] = true
LearnZone(zone)
end
if not Discovered(id) then
map:AcquirePin(TEMPLATE, id):SetPosition(u, v)
end
end
end
end
end
function provider:OnShow()
self:RegisterEvent("TAXI_NODE_STATUS_CHANGED")
end
function provider:OnHide()
self:UnregisterEvent("TAXI_NODE_STATUS_CHANGED")
end
function provider:OnEvent()
self:RefreshAllData()
end
---------------------------------------------------------------------------
-- Pins
---------------------------------------------------------------------------
FlightFinderPinMixin = CreateFromMixins(MapCanvasPinMixin)
function FlightFinderPinMixin:OnLoad()
self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
self:SetScalingLimits(1, 1.0, 1.25)
end
function FlightFinderPinMixin:OnAcquired(id)
self.nodeID = id
local c = COLORS[ns.nodes[id][4]]
self.Disc:SetVertexColor(0.06, 0.06, 0.08, 0.9)
self.Ring:SetVertexColor(c[1], c[2], c[3], 1)
self.Glyph:SetTexture(GLYPH)
self:CheckMouseButtonPassthrough("RightButton")
end
-- where a waypoint for the node goes: its zone map, since continents don't take waypoints
local function WaypointPoint(id, mapID)
if not (C_Map.CanSetUserWaypointOnMap and C_Map.SetUserWaypoint and UiMapPoint) then
return nil
end
for _, m in ipairs({ Chain(id).zone or mapID, mapID }) do
local u, v = Project(m, id)
if u and C_Map.CanSetUserWaypointOnMap(m) then
return UiMapPoint.CreateFromCoordinates(m, u, v)
end
end
end
function FlightFinderPinMixin:OnMouseEnter()
local n = ns.nodes[self.nodeID]
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:AddLine(n[5], 1, 1, 1)
local c = COLORS[n[4]]
GameTooltip:AddLine(n[4] == "Neutral" and "Undiscovered flight point" or ("Undiscovered " .. n[4] .. " flight point"), c[1], c[2], c[3])
if WaypointPoint(self.nodeID, self:GetMap():GetMapID()) then
GameTooltip:AddLine("Click to set a waypoint", 0.6, 0.6, 0.6)
end
GameTooltip:Show()
end
function FlightFinderPinMixin:OnMouseLeave()
GameTooltip:Hide()
end
function FlightFinderPinMixin:OnMouseClickAction(button)
if button ~= "LeftButton" then
return
end
local point = WaypointPoint(self.nodeID, self:GetMap():GetMapID())
if point then
C_Map.SetUserWaypoint(point)
if C_SuperTrack and C_SuperTrack.SetSuperTrackedUserWaypoint then
C_SuperTrack.SetSuperTrackedUserWaypoint(true)
end
end
end
---------------------------------------------------------------------------
-- Setup and slash command
---------------------------------------------------------------------------
local function Refresh()
if provider:GetMap() then
provider:RefreshAllData()
end
end
local attached = false
local function Attach()
if not attached and WorldMapFrame and WorldMapFrame.AddDataProvider then
attached = true
WorldMapFrame:AddDataProvider(provider)
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("TAXIMAP_OPENED")
frame:SetScript("OnEvent", function(_, event, name)
if event == "TAXIMAP_OPENED" then
LearnTaxiMap()
Refresh()
elseif name == addonName then
FlightFinderDB = FlightFinderDB or {}
FlightFinderCharDB = FlightFinderCharDB or {}
FlightFinderCharDB.known = FlightFinderCharDB.known or {}
db, known = FlightFinderDB, FlightFinderCharDB.known
Attach()
elseif name == "Blizzard_WorldMap" then
Attach()
end
end)
SLASH_FLIGHTFINDER1 = "/ff"
SlashCmdList.FLIGHTFINDER = function()
db.hidden = not db.hidden
local total, have = 0, 0
for id in pairs(ns.nodes) do
if Visible(id) and Leader(id) then
total = total + 1
if Discovered(id) then
have = have + 1
end
end
end
print(PREFIX .. (db.hidden and "hidden. " or "shown. ") .. string.format("%d / %d flight points known.", have, total))
Refresh()
end

View file

@ -0,0 +1,10 @@
## Interface: 16001
## Title: Flight Finder
## Notes: Marks the flight masters you haven't discovered yet on zone and continent maps.
## Version: 1.0
## SavedVariables: FlightFinderDB
## SavedVariablesPerCharacter: FlightFinderCharDB
Data.lua
FlightFinder.lua
FlightFinder.xml

View file

@ -0,0 +1,24 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Frame name="FlightFinderPinTemplate" mixin="FlightFinderPinMixin" enableMouse="true" virtual="true">
<Size x="20" y="20"/>
<Layers>
<Layer level="BACKGROUND">
<Texture parentKey="Disc" file="Interface\AddOns\FlightFinder\Icons\disc" setAllPoints="true"/>
</Layer>
<Layer level="BORDER">
<Texture parentKey="Ring" file="Interface\AddOns\FlightFinder\Icons\ring" setAllPoints="true"/>
</Layer>
<Layer level="ARTWORK">
<Texture parentKey="Glyph">
<Anchors>
<Anchor point="TOPLEFT" x="3" y="-3"/>
<Anchor point="BOTTOMRIGHT" x="-3" y="3"/>
</Anchors>
</Texture>
</Layer>
</Layers>
<Scripts>
<OnLoad method="OnLoad"/>
</Scripts>
</Frame>
</Ui>

BIN
FlightFinder/Icons/disc.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
FlightFinder/Icons/ring.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1,39 @@
"""Builds FlightFinder/Data.lua from the client's TaxiNodes.db2 (FileDataID 1068100).
usage: python3 generate.py <TaxiNodes.db2> <Data.lua>
A node counts as a flight master when it has a CharacterBitNumber (the bit that records
it as learned) and isn't a placeholder (old "zz" nodes, the zeppelin world target).
Faction comes from the Flags field: 0x1 shows on the Alliance map, 0x2 on the Horde map;
both or neither means neutral.
"""
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "ShipRoutes", "tools"))
from wdc5 import read, f32, string
F_NAME, F_POS, F_ID, F_INST, F_BIT, F_FLAGS = 0, 1, 4, 5, 7, 8
HIDDEN = 0x80 # "don't show in the world map UI"
SKIP = ("zz", "Generic,", "Transport,", "Quest Path") # placeholders that still carry a bit
rows, finfo = read(sys.argv[1])
assert len(finfo) == 15, "TaxiNodes layout changed: %d fields" % len(finfo)
out = []
for r in sorted(rows, key=lambda r: r["id"]):
v = r["fields"]
name = string(r, finfo, F_NAME)
flags = v[F_FLAGS]
if v[F_BIT] == 0 or name.startswith(SKIP) or flags & HIDDEN:
continue
x, y = f32(v[F_POS][0]), f32(v[F_POS][1])
faction = {1: "Alliance", 2: "Horde"}.get(flags & 3, "Neutral")
out.append(' [%d] = { %d, %.1f, %.1f, "%s", "%s" },' % (
r["id"], v[F_INST], x, y, faction, name.replace("\\", "\\\\").replace('"', '\\"')))
with open(sys.argv[2], "w") as f:
f.write("-- Generated by tools/generate.py from TaxiNodes.db2. Do not edit.\n")
f.write("-- [nodeID] = { instance, world x, world y, faction, name }\n")
f.write("local _, ns = ...\n\nns.nodes = {\n")
f.write("\n".join(out))
f.write("\n}\n")
print(len(out), "flight masters", file=sys.stderr)

View file

@ -1,6 +1,6 @@
# WoW Forever addons
Seven small quality-of-life addons for WoW Forever (client 1.60.1, Interface 16001).
Eight small quality-of-life addons for WoW Forever (client 1.60.1, Interface 16001).
| Addon | What it does | Check command |
| --- | --- | --- |
@ -10,11 +10,12 @@ Seven small quality-of-life addons for WoW Forever (client 1.60.1, Interface 160
| Quest Shopping List | A panel beside the auction house listing items your quests still need, with cost against the quest's reward. Click to search. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/qsl` |
| Dungeon Pre-Quest | Marks dungeon quests and quests whose chain leads to one, in the quest log, NPC quest lists and the quest offer window, with a purple "!" on the minimap for ones you can pick up now. | `/dpq <questID>` |
| Ship Routes | Draws every boat, zeppelin and airship route on the world map, coloured by faction. Hover a dock marker to see where it sails and light up its route, click it to open the destination's map. On a continent or zone map, a route that sails off it ends in a marker at the edge naming where it goes. | `/routes`, `/routes mine`, `/routes all` |
| Flight Finder | Marks the flight masters you haven't discovered yet on zone and continent maps, coloured by faction. Click one to set a waypoint. | `/ff` toggles and counts |
| Fish Key | While you fish, the key you cast Fishing with clicks the bobber instead. It casts Fishing again once the fish is looted and the key is released. For the cast it turns the Interact Key setting on and press and hold casting off, then puts both back. | `/fish`, `/fish on`, `/fish off` |
## Install
Copy the seven addon folders into `World of Warcraft/_forever_/Interface/AddOns/`, then type `/reload` in game.
Copy the eight addon folders into `World of Warcraft/_forever_/Interface/AddOns/`, then type `/reload` in game.
Each addon works on its own, so copy only the ones you want. Vendor Flag and Quest Shopping List stay disabled unless Auctionator is installed.
## Known limits
@ -26,6 +27,7 @@ Each addon works on its own, so copy only the ones you want. Vendor Flag and Que
- Its minimap markers skip quests started by an item, and quests with profession or reputation requirements.
- Quest Shopping List's prices are Auctionator's last-seen prices, so run "Search all" for current ones. Rewards count gold plus item value, not XP.
- Ship Routes' dock names and the list of which paths are transports are curated by hand in `ShipRoutes/tools/generate.py`, because the client doesn't record which ship sails which path. Lanes between continents follow hand-placed sea waypoints there too, since the ships teleport mid-ocean. The Zephras Isle airships have no line, since the island isn't on the world map, and they have no known faction, so they show in neutral gold.
- Flight Finder learns which flight points you have from the map and from flight masters' taxi maps. If a zone's map doesn't list them, open any flight master once and the rest fill in.
- Fish Key finds Fishing on Blizzard's action bars, `CLICK` bindings to addon buttons, and spell or macro bindings. It doesn't see bar addons that bind keys through their own override bindings, such as Bartender. While you fish it raises the interact range to 30 yards, so a closer NPC or object can be picked over the bobber.
## Tests
@ -41,6 +43,7 @@ lua tests/test_dpq_minimap.lua DungeonPreQuest/Minimap.lua
lua tests/test_qsl.lua QuestShoppingList/QuestShoppingList.lua
lua tests/test_sr.lua ShipRoutes
lua tests/test_fk.lua FishKey/FishKey.lua
lua tests/test_ff.lua FlightFinder
```
## Regenerating Dungeon Pre-Quest's data
@ -65,6 +68,15 @@ python3 ShipRoutes/tools/generate.py out/1000437.db2 ShipRoutes/Data.lua
The generator stops if a route's stop isn't near a dock it knows, so a moved or new dock shows up as an error rather than a wrong name.
`ShipRoutes/tools/icons.py ShipRoutes/Icons` redraws the marker textures.
## Regenerating Flight Finder's data
`FlightFinder/Data.lua` comes from the client's `TaxiNodes.db2`, using Ship Routes' readers:
```
python3 ShipRoutes/tools/casc.py "<World of Warcraft dir>" wowf out 1068100
python3 FlightFinder/tools/generate.py out/1068100.db2 FlightFinder/Data.lua
```
## Credits and licence
Dungeon Pre-Quest's data is derived from [QuestieDB](https://github.com/Questie/QuestieDB) and

205
tests/test_ff.lua Normal file
View file

@ -0,0 +1,205 @@
-- Runs FlightFinder against a mock of the WoW map and taxi API.
-- arg[1] = addon folder (FlightFinder)
local dir = arg[1] or "FlightFinder"
local failures = 0
local function check(cond, msg)
if not cond then
failures = failures + 1
io.write("FAIL: ", msg, "\n")
end
end
-- Map rects: top/bottom are world X, left/right world Y.
local RECTS = {
[1415] = { inst = 0, top = 7467, bottom = -16000, left = 16000, right = -19200, type = 2, parent = 947 },
[1414] = { inst = 1, top = 12800, bottom = -11733, left = 17067, right = -19733, type = 2, parent = 947 },
[1437] = { inst = 0, top = -1500, bottom = -4800, left = 200, right = -4800, type = 3, parent = 1415 }, -- Wetlands
[1432] = { inst = 0, top = -4500, bottom = -6300, left = -1700, right = -4500, type = 3, parent = 1415 }, -- Loch Modan
[1426] = { inst = 0, top = -3400, bottom = -6600, left = 1500, right = -2500, type = 3, parent = 1415 }, -- Dun Morogh
[1455] = { inst = 0, top = -4500, bottom = -5200, left = -700, right = -1500, type = 3, parent = 1426 }, -- Ironforge
[1434] = { inst = 0, top = -11000, bottom = -15000, left = 2000, right = -2000, type = 3, parent = 1415 }, -- Stranglethorn
}
-- which zone the client puts a world point in: first matching rect among these, smallest first
local ZONES = { 1455, 1437, 1432, 1426, 1434 }
Enum = { UIMapType = { Cosmic = 0, World = 1, Continent = 2, Zone = 3, Dungeon = 4, Micro = 5 } }
function CreateVector2D(x, y)
return { x = x, y = y, GetXY = function(self) return self.x, self.y end }
end
local waypoint
UiMapPoint = { CreateFromCoordinates = function(m, u, v) return { m = m, u = u, v = v } end }
C_Map = {
GetMapInfo = function(id)
if id == 947 then return { mapID = 947, mapType = 1, parentMapID = 0 } end
local r = RECTS[id]
return r and { mapID = id, mapType = r.type, parentMapID = r.parent }
end,
GetWorldPosFromMapPos = function(id, v)
local r = RECTS[id]
if not r then return nil end
return r.inst, CreateVector2D(r.top + (r.bottom - r.top) * v.y, r.left + (r.right - r.left) * v.x)
end,
GetMapPosFromWorldPos = function(inst, pos)
for _, id in ipairs(ZONES) do
local r = RECTS[id]
if r.inst == inst and pos.x <= r.top and pos.x >= r.bottom and pos.y <= r.left and pos.y >= r.right then
return id, CreateVector2D(0, 0)
end
end
return inst == 0 and 1415 or 1414, CreateVector2D(0, 0)
end,
CanSetUserWaypointOnMap = function(id) return RECTS[id].type == 3 end,
SetUserWaypoint = function(p) waypoint = p end,
}
C_SuperTrack = { SetSuperTrackedUserWaypoint = function() end }
local apiKnown = {} -- nodeIDs GetTaxiNodesForMap reports as discovered, by zone
C_TaxiMap = {
GetTaxiNodesForMap = function(id)
local out = {}
for _, nodeID in ipairs(apiKnown[id] or {}) do
out[#out + 1] = { nodeID = nodeID, isUndiscovered = false }
end
return out
end,
}
local taxi = {}
function NumTaxiNodes() return #taxi end
function TaxiNodeName(i) return taxi[i][1] end
function TaxiNodeGetType(i) return taxi[i][2] end
local faction = "Alliance"
function UnitFactionGroup() return faction end
function CreateFromMixins(...)
local t = {}
for i = 1, select("#", ...) do
for k, v in pairs((select(i, ...))) do t[k] = v end
end
return t
end
MapCanvasDataProviderMixin = {
OnAdded = function(self, map) self.owningMap = map end,
GetMap = function(self) return self.owningMap end,
RegisterEvent = function() end,
UnregisterEvent = function() end,
}
MapCanvasPinMixin = {
UseFrameLevelType = function() end,
SetScalingLimits = function() end,
CheckMouseButtonPassthrough = function() end,
GetMap = function() return WorldMapFrame end,
}
local function texture()
return { SetVertexColor = function() end, SetTexture = function() end }
end
local eventFrame
function CreateFrame()
local f = { scripts = {} }
function f:RegisterEvent() end
function f:SetScript(name, fn) self.scripts[name] = fn end
eventFrame = f
return f
end
local pins = {}
local mapID = 1437
WorldMapFrame = {
AddDataProvider = function(self, p) p:OnAdded(self) end,
GetMapID = function() return mapID end,
RemoveAllPinsByTemplate = function() pins = {} end,
AcquirePin = function(self, template, id)
local pin = CreateFromMixins(FlightFinderPinMixin)
pin.Disc, pin.Ring, pin.Glyph = texture(), texture(), texture()
pin:OnLoad()
pin:OnAcquired(id)
function pin:SetPosition(u, v) self.u, self.v = u, v end
pins[#pins + 1] = pin
return pin
end,
}
local printed
function print(s) printed = s end
SlashCmdList = {}
local ns = {}
for _, file in ipairs({ "Data.lua", "FlightFinder.lua" }) do
assert(loadfile(dir .. "/" .. file))("FlightFinder", ns)
end
eventFrame.scripts.OnEvent(eventFrame, "ADDON_LOADED", "FlightFinder")
local function show(id)
mapID = id
ns.provider:RefreshAllData()
local ids = {}
for _, p in ipairs(pins) do
ids[p.nodeID] = p
end
return ids
end
-- Wetlands: Menethil (7) is undiscovered and sits inside the map
local p = show(1437)[7]
check(p, "Menethil marked on Wetlands")
check(p and p.u > 0 and p.u < 1 and p.v > 0 and p.v < 1, "Menethil inside the Wetlands map")
-- Thelsamar (8) is in Loch Modan, not on the Wetlands map
check(not show(1437)[8], "Loch Modan's flight point stays off Wetlands")
check(show(1432)[8], "Thelsamar on Loch Modan")
-- Horde flight points never show for Alliance
check(not show(1434)[18], "Horde Booty Bay hidden for Alliance")
check(show(1434)[19], "Alliance Booty Bay shown")
-- the map API knows Menethil: no marker, and it's remembered for the continent map
apiKnown[1437] = { 7 }
check(not show(1437)[7], "known Menethil not marked")
apiKnown[1437] = nil
check(not show(1415)[7], "Menethil stays known on the continent map")
check(show(1415)[8], "Thelsamar still marked on the continent map")
-- city node shows on its zone (Ironforge sits in Dun Morogh)
check(show(1426)[6], "Ironforge marked on Dun Morogh")
-- taxi map: Thelsamar reachable, Ironforge not yet discovered
taxi = { { "Thelsamar, Loch Modan", "REACHABLE" }, { "Ironforge, Dun Morogh", "NONE" } }
eventFrame.scripts.OnEvent(eventFrame, "TAXIMAP_OPENED")
check(not show(1432)[8], "taxi map taught Thelsamar")
check(show(1426)[6], "NONE taxi node stays undiscovered")
-- same-named flight masters next to each other: one marker, known if either is
faction = "Horde"
local grp = ns.groups[3274]
check(grp and #grp == 2, "Powderfuse Port's two nodes form one place")
FlightFinderCharDB.known[3275] = true
local function powderfuse()
local ids, n = show(1415), 0
if ids[3274] then n = n + 1 end
if ids[3275] then n = n + 1 end
return n
end
check(powderfuse() == 0, "Powderfuse known through its twin")
FlightFinderCharDB.known[3275] = nil
check(powderfuse() == 1, "one Powderfuse marker")
-- clicking a continent marker sets the waypoint on its zone map
faction = "Alliance"
FlightFinderCharDB.known[8] = nil
local loch = show(1415)[8]
check(loch, "Thelsamar back after forgetting")
waypoint = nil
loch:OnMouseClickAction("LeftButton")
check(waypoint and waypoint.m == 1432, "waypoint set on Loch Modan, got " .. tostring(waypoint and waypoint.m))
-- slash toggles and counts
SlashCmdList.FLIGHTFINDER("")
check(printed and printed:find("hidden") and printed:find("%d+ / %d+"), "slash prints hidden + count: " .. tostring(printed))
check(next(show(1437)) == nil, "hidden shows nothing")
SlashCmdList.FLIGHTFINDER("")
check(show(1432)[8], "shown again")
if failures == 0 then
print = io.write
io.write("ok\n")
else
os.exit(1)
end