Ship Routes: solid sea lanes around the continents, labelled edge markers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-11 15:33:04 +00:00
parent 63eebfc8bd
commit 216e6f90b8
6 changed files with 555 additions and 301 deletions

View file

@ -9,7 +9,7 @@ Six small quality-of-life addons for WoW Forever (client 1.60.1, Interface 16001
| Vendor Flag | Marks items for 10 minutes after Auctionator warns they would earn more at a vendor. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/vf` | | Vendor Flag | Marks items for 10 minutes after Auctionator warns they would earn more at a vendor. Requires [Auctionator](https://www.curseforge.com/wow/addons/auctionator). | `/vf` |
| 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` | | 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>` | | 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. | `/routes`, `/routes mine`, `/routes all` | | 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` |
## Install ## Install
@ -24,7 +24,7 @@ Each addon works on its own, so copy only the ones you want. Vendor Flag and Que
- Dungeon Pre-Quest misses chains that QuestieDB has no links for, which includes many quests new to Forever. - Dungeon Pre-Quest misses chains that QuestieDB has no links for, which includes many quests new to Forever.
- Its minimap markers skip quests started by an item, and quests with profession or reputation requirements. - 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. - 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. The Zephras Isle airships have no known faction, so they show in neutral gold. - 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.
## Tests ## Tests

View file

@ -1,125 +1,118 @@
-- Generated by tools/generate.py from TaxiPathNode.db2. Do not edit by hand. -- Generated by tools/generate.py from TaxiPathNode.db2. Do not edit by hand.
-- stops: { name, instance, worldX, worldY } -- stops: { name, instance, worldX, worldY }
-- parts: sailed in order; a gap between parts is a teleport or a change of map. -- legs: from / to stop index, then points as (instance, worldX, worldY) triples;
-- next: index of the first stop reached after the part ends. -- instance -1 is a point on the Azeroth world map (u, v). smooth legs are drawn as a curve.
local _, ns = ... local _, ns = ...
ns.routes = { ns.routes = {
{ path = 241, noun = "Boat", kind = "boat", faction = "Neutral", closed = false, { path = 241, noun = "Boat", kind = "boat", faction = "Neutral",
stops = { stops = {
{ "Booty Bay", 0, -14277.7, 582.9 },
{ "Ratchet", 1, -1005.6, -3841.6 }, { "Ratchet", 1, -1005.6, -3841.6 },
{ "Booty Bay", 0, -14277.7, 582.9 },
}, },
parts = { legs = {
{ m = 0, next = 2, -14336, 1558, -14343, 1511, -14353, 1444, -14362, 1370, -14367, 1302, -14359, 1226, -14346, 1153, -14338, 1081, -14345, 1006, -14358, 932, -14367, 867, -14361, 793, -14351, 734, -14343, 635, -14278, 583, -14172, 578, -14088, 626, -14053, 732, -14071, 798, -14123, 853, -14175, 866, -14245, 868, -14352, 865, -14431, 862, -14530, 857, -14638, 852, -14746, 845, -14842, 839, -14918, 833, -15039, 819, -15090, 808 }, { from = 1, to = 2, smooth = true, 1, -1006, -3842, -1, 0.3441, 0.5711, -1, 0.4562, 0.6055, -1, 0.5682, 0.6202, -1, 0.6407, 0.7282, -1, 0.6737, 0.7870, 0, -14278, 583 },
{ m = 1, next = 1, -2032, -4966, -1969, -4933, -1921, -4906, -1859, -4871, -1793, -4832, -1734, -4794, -1669, -4746, -1611, -4697, -1559, -4642, -1524, -4592, -1494, -4537, -1466, -4482, -1442, -4432, -1405, -4344, -1370, -4267, -1316, -4200, -1265, -4140, -1236, -4080, -1213, -4020, -1183, -3950, -1154, -3888, -1106, -3824, -1058, -3819, -1006, -3842, -956, -3877, -935, -3918, -950, -3981, -1027, -4049, -1092, -4125, -1115, -4181, -1139, -4250, -1161, -4321, -1177, -4389, -1190, -4460, -1209, -4534, -1231, -4594, -1255, -4659, -1283, -4722, -1312, -4778, -1353, -4841, -1397, -4895, -1449, -4948, -1495, -4990, -1546, -5032, -1599, -5072, -1653, -5107, -1731, -5146, -1811, -5176, -1867, -5197 },
}, },
}, },
{ path = 292, noun = "Boat", kind = "boat", faction = "Alliance", closed = false, { path = 292, noun = "Boat", kind = "boat", faction = "Alliance",
stops = { stops = {
{ "Theramore Isle", 1, -4016.4, -4740.6 },
{ "Menethil Harbor", 0, -3905.2, -585.8 }, { "Menethil Harbor", 0, -3905.2, -585.8 },
{ "Theramore Isle", 1, -4016.4, -4740.6 },
}, },
parts = { legs = {
{ m = 1, next = 2, -4301, -5732, -4298, -5627, -4297, -5557, -4295, -5463, -4293, -5356, -4290, -5247, -4288, -5148, -4285, -5067, -4281, -4981, -4277, -4917, -4272, -4867, -4264, -4823, -4237, -4757, -4201, -4719, -4101, -4692, -4016, -4741, -3953, -4814, -3927, -4890, -3919, -4959, -3903, -5033, -3868, -5096, -3817, -5148, -3749, -5183, -3669, -5205, -3610, -5208, -3547, -5206, -3476, -5209, -3411, -5219, -3337, -5234, -3267, -5250, -3214, -5262, -3157, -5280 }, { from = 1, to = 2, smooth = true, 0, -3905, -586, -1, 0.6935, 0.4730, -1, 0.5221, 0.5417, -1, 0.3441, 0.6202, 1, -4016, -4741 },
{ m = 0, next = 1, -3609, 309, -3653, 276, -3716, 229, -3788, 178, -3848, 140, -3916, 100, -3983, 58, -4037, 16, -4088, -42, -4123, -103, -4151, -166, -4176, -235, -4193, -306, -4200, -372, -4182, -460, -4151, -531, -4089, -599, -3996, -611, -3905, -586, -3831, -529, -3790, -422, -3785, -368, -3788, -305, -3809, -232, -3839, -183, -3881, -131, -3927, -75, -3969, -16, -3999, 44, -4015, 110, -4023, 182, -4026, 255, -4026, 321, -4026, 376, -4019, 467, -4008, 516 },
}, },
}, },
{ path = 293, noun = "Boat", kind = "boat", faction = "Alliance", closed = true, { path = 293, noun = "Boat", kind = "boat", faction = "Alliance",
stops = { stops = {
{ "Rut'theran Village", 1, 8532.0, 1023.7 }, { "Rut'theran Village", 1, 8532.0, 1023.7 },
{ "Auberdine", 1, 6594.4, 759.8 }, { "Auberdine", 1, 6594.4, 759.8 },
}, },
parts = { legs = {
{ m = 1, next = 1, 7685, 1347, 7740, 1346, 7818, 1344, 7913, 1340, 7970, 1339, 8036, 1338, 8107, 1337, 8177, 1334, 8241, 1331, 8294, 1324, 8392, 1294, 8452, 1251, 8499, 1195, 8526, 1134, 8532, 1024, 8505, 932, 8448, 851, 8348, 803, 8287, 789, 8213, 775, 8138, 765, 8069, 758, 7998, 755, 7918, 753, 7862, 753, 7802, 754, 7739, 756, 7675, 754, 7612, 747, 7551, 733, 7491, 714, 7430, 692, 7368, 670, 7304, 650, 7237, 633, 7166, 617, 7095, 602, 7028, 588, 6968, 578, 6888, 568, 6821, 564, 6766, 564, 6655, 589, 6593, 672, 6594, 760, 6639, 841, 6716, 913, 6770, 952, 6834, 992, 6901, 1032, 6983, 1077, 7038, 1106, 7099, 1138, 7163, 1171, 7226, 1200, 7287, 1227, 7349, 1253, 7410, 1276, 7467, 1296, 7543, 1318, 7614, 1335, 7666, 1346 }, { from = 1, to = 2, smooth = false, 1, 8532, 1024, 1, 8505, 932, 1, 8448, 851, 1, 8348, 803, 1, 8251, 782, 1, 8138, 765, 1, 8034, 757, 1, 7918, 753, 1, 7822, 754, 1, 7717, 755, 1, 7612, 747, 1, 7511, 721, 1, 7409, 684, 1, 7304, 650, 1, 7190, 622, 1, 7072, 597, 1, 6968, 578, 1, 6853, 565, 1, 6766, 564, 1, 6655, 589, 1, 6593, 672, 1, 6594, 760 },
}, },
}, },
{ path = 303, noun = "Boat", kind = "boat", faction = "Alliance", closed = true, { path = 303, noun = "Boat", kind = "boat", faction = "Alliance",
stops = { stops = {
{ "Feathermoon Stronghold", 1, -4197.3, 3286.6 }, { "Feathermoon Stronghold", 1, -4197.3, 3286.6 },
{ "The Forgotten Coast", 1, -4347.8, 2444.4 }, { "The Forgotten Coast", 1, -4347.8, 2444.4 },
}, },
parts = { legs = {
{ m = 1, next = 1, -4196, 3467, -4196, 3451, -4197, 3371, -4197, 3287, -4197, 3214, -4196, 3138, -4196, 3067, -4196, 2989, -4200, 2900, -4205, 2844, -4213, 2776, -4222, 2705, -4230, 2639, -4238, 2588, -4267, 2484, -4348, 2444, -4448, 2476, -4497, 2502, -4555, 2535, -4624, 2580, -4675, 2613, -4735, 2653, -4797, 2695, -4856, 2737, -4906, 2778, -4954, 2826, -4993, 2873, -5025, 2921, -5054, 2971, -5084, 3038, -5106, 3108, -5121, 3186, -5129, 3254, -5133, 3328, -5133, 3402, -5130, 3471, -5122, 3557, -5108, 3636, -5089, 3706, -5055, 3789, -5010, 3853, -4952, 3904, -4880, 3940, -4825, 3955, -4764, 3963, -4693, 3962, -4629, 3955, -4557, 3942, -4485, 3925, -4417, 3904, -4353, 3883, -4290, 3860, -4235, 3829, -4196, 3783, -4182, 3730, -4180, 3664, -4185, 3593, -4192, 3524, -4196, 3467, -4196, 3398, -4197, 3345, -4197, 3287, -4197, 3193, -4197, 3096, -4196, 3067, -4196, 3104, -4196, 3176, -4196, 3264, -4196, 3353, -4196, 3426 }, { from = 1, to = 2, smooth = false, 1, -4197, 3287, 1, -4197, 3187, 1, -4196, 3067, 1, -4196, 2989, 1, -4200, 2900, 1, -4210, 2799, 1, -4224, 2682, 1, -4238, 2588, 1, -4267, 2484, 1, -4348, 2444 },
}, },
}, },
{ path = 11167, noun = "Boat", kind = "boat", faction = "Alliance", closed = false, { path = 11167, noun = "Boat", kind = "boat", faction = "Alliance",
stops = { stops = {
{ "Auberdine", 1, 6406.2, 823.1 },
{ "Menethil Harbor", 0, -3709.5, -575.1 }, { "Menethil Harbor", 0, -3709.5, -575.1 },
{ "Southshore", 0, -1102.6, -554.7 }, { "Southshore", 0, -1102.6, -554.7 },
{ "Auberdine", 1, 6406.2, 823.1 },
}, },
parts = { legs = {
{ m = 1, next = 2, 5808, 1312, 5808, 1241, 5818, 1184, 5837, 1116, 5868, 1038, 5904, 961, 5941, 897, 5982, 841, 6027, 789, 6077, 746, 6132, 719, 6190, 703, 6299, 698, 6376, 761, 6406, 823, 6417, 893, 6403, 987, 6339, 1072, 6240, 1136, 6177, 1158, 6113, 1173, 6010, 1179, 5933, 1179, 5869, 1179 }, { from = 1, to = 2, smooth = false, 0, -3709, -575, 0, -3740, -495, 0, -3725, -388, 0, -3628, -292, 0, -3474, -274, 0, -3383, -288, 0, -3275, -312, 0, -3179, -339, 0, -3078, -377, 0, -2988, -429, 0, -2920, -472, 0, -2850, -524, 0, -2778, -597, 0, -2712, -710, 0, -2643, -843, 0, -2544, -951, 0, -2394, -1019, 0, -2214, -1061, 0, -2041, -1075, 0, -1886, -1053, 0, -1738, -1004, 0, -1606, -952, 0, -1492, -903, 0, -1392, -851, 0, -1307, -802, 0, -1204, -737, 0, -1134, -676, 0, -1103, -555 },
{ m = 0, next = 1, -2963, -93, -2985, -141, -3038, -222, -3078, -268, -3130, -324, -3187, -383, -3241, -437, -3287, -482, -3363, -549, -3422, -588, -3524, -629, -3601, -644, -3663, -625, -3709, -575, -3740, -495, -3725, -388, -3686, -334, -3628, -292, -3564, -273, -3474, -274, -3423, -281, -3362, -293, -3297, -307, -3234, -323, -3179, -339, -3108, -364, -3049, -392, -2988, -429, -2937, -461, -2886, -496, -2833, -540, -2778, -597, -2744, -648, -2712, -710, -2679, -777, -2643, -843, -2599, -903, -2544, -951, -2475, -988, -2394, -1019, -2305, -1043, -2214, -1061, -2124, -1071, -2041, -1075, -1963, -1069, -1886, -1053, -1811, -1031, -1738, -1004, -1670, -977, -1606, -952, -1536, -923, -1471, -893, -1411, -861, -1357, -831, -1307, -802, -1235, -758, -1177, -717, -1134, -676, -1104, -621, -1103, -555, -1112, -485, -1131, -406, -1160, -341, -1218, -299, -1300, -266, -1353, -236, -1414, -201, -1477, -163, -1537, -125, -1595, -82, -1655, -35, -1707, 8, -1743, 38 }, { from = 2, to = 3, smooth = true, 0, -1103, -555, -1, 0.7264, 0.4092, -1, 0.6737, 0.4289, -1, 0.5221, 0.3258, -1, 0.3507, 0.1933, -1, 0.2584, 0.1639, -1, 0.1958, 0.2080, 1, 6406, 823 },
{ from = 3, to = 1, smooth = true, 1, 6406, 823, -1, 0.1958, 0.2080, -1, 0.2584, 0.1639, -1, 0.3507, 0.1933, -1, 0.5221, 0.3258, -1, 0.6935, 0.4534, 0, -3709, -575 },
}, },
}, },
{ path = 11616, noun = "Boat", kind = "boat", faction = "Alliance", closed = false, { path = 11616, noun = "Boat", kind = "boat", faction = "Alliance",
stops = { stops = {
{ "Stormwind Harbor", 0, -8654.5, 1344.4 },
{ "Auberdine", 1, 6548.3, 942.2 }, { "Auberdine", 1, 6548.3, 942.2 },
{ "Stormwind Harbor", 0, -8654.5, 1344.4 },
}, },
parts = { legs = {
{ m = 0, next = 2, -8951, 1780, -8953, 1721, -8954, 1639, -8948, 1564, -8921, 1485, -8883, 1423, -8839, 1375, -8794, 1343, -8711, 1328, -8654, 1344, -8612, 1373, -8579, 1424, -8545, 1494, -8522, 1547, -8496, 1605, -8467, 1672, -8444, 1724 }, { from = 1, to = 2, smooth = true, 1, 6548, 942, -1, 0.1958, 0.2080, -1, 0.2584, 0.1639, -1, 0.3507, 0.1933, -1, 0.5221, 0.4043, -1, 0.6539, 0.6104, 0, -8654, 1344 },
{ m = 1, next = 1, 7058, 1488, 7047, 1445, 7033, 1382, 7015, 1313, 6993, 1253, 6956, 1189, 6913, 1131, 6871, 1083, 6818, 1032, 6768, 996, 6672, 943, 6604, 932, 6548, 942, 6497, 972, 6448, 1023, 6405, 1116, 6395, 1181, 6397, 1272, 6403, 1324, 6413, 1385, 6424, 1450, 6436, 1515, 6446, 1573, 6457, 1643, 6468, 1712, 6478, 1772, 6485, 1814 },
}, },
}, },
{ path = 11391, noun = "Boat", kind = "boat", faction = "Neutral", closed = false, { path = 11391, noun = "Boat", kind = "boat", faction = "Neutral",
stops = { stops = {
{ "Riverglades", 0, -8232.3, -5800.8 },
{ "Steamwheedle Port", 1, -6932.6, -4950.8 }, { "Steamwheedle Port", 1, -6932.6, -4950.8 },
{ "Riverglades", 0, -8232.3, -5800.8 },
}, },
parts = { legs = {
{ m = 0, next = 2, -8230, -6340, -8222, -6276, -8231, -6195, -8226, -6110, -8181, -6006, -8159, -5918, -8176, -5843, -8232, -5801, -8280, -5781, -8343, -5783, -8419, -5809, -8478, -5834, -8571, -5877, -8629, -5905, -8690, -5941, -8750, -5986, -8806, -6039, -8853, -6103, -8886, -6155 }, { from = 1, to = 2, smooth = true, 1, -6933, -4951, -1, 0.4034, 0.7870, -1, 0.5880, 0.8459, -1, 0.7528, 0.8754, -1, 0.8187, 0.7870, -1, 0.8748, 0.6791, 0, -8232, -5801 },
{ m = 1, next = 1, -6607, -5618, -6632, -5506, -6642, -5452, -6654, -5384, -6667, -5310, -6681, -5240, -6696, -5183, -6735, -5091, -6775, -5031, -6849, -4966, -6933, -4951, -6991, -4953, -7046, -4972, -7127, -5056, -7157, -5108, -7185, -5165, -7215, -5222, -7244, -5276, -7298, -5355, -7330, -5420, -7340, -5490, -7341, -5563, -7341, -5640, -7341, -5746 },
}, },
}, },
{ path = 285, noun = "Zeppelin", kind = "air", faction = "Horde", closed = false, { path = 285, noun = "Zeppelin", kind = "air", faction = "Horde",
stops = { stops = {
{ "Orgrimmar", 1, 1360.9, -4631.3 },
{ "Grom'gol", 0, -12464.0, 231.6 }, { "Grom'gol", 0, -12464.0, 231.6 },
{ "Orgrimmar", 1, 1360.9, -4631.3 },
}, },
parts = { legs = {
{ m = 1, next = 2, 1132, -5493, 1133, -5401, 1143, -5345, 1157, -5276, 1167, -5201, 1170, -5137, 1170, -5067, 1169, -4998, 1165, -4935, 1155, -4870, 1140, -4813, 1130, -4751, 1123, -4673, 1119, -4591, 1127, -4527, 1223, -4465, 1299, -4508, 1328, -4565, 1361, -4631, 1419, -4691, 1469, -4756, 1475, -4836, 1465, -4919, 1460, -4992, 1453, -5065, 1447, -5151, 1443, -5231, 1441, -5332, 1447, -5433 }, { from = 1, to = 2, smooth = true, 0, -12464, 232, -1, 0.6357, 0.6177, -1, 0.5350, 0.5234, -1, 0.4223, 0.4675, 1, 1361, -4631 },
{ m = 0, next = 1, -12466, 1000, -12466, 931, -12461, 883, -12455, 822, -12449, 754, -12443, 686, -12437, 614, -12432, 537, -12428, 462, -12428, 397, -12439, 302, -12464, 232, -12510, 174, -12565, 142, -12678, 177, -12713, 229, -12730, 296, -12722, 377, -12703, 464, -12687, 542, -12668, 633, -12654, 698, -12639, 773, -12624, 846, -12613, 905, -12603, 1010 },
}, },
}, },
{ path = 301, noun = "Zeppelin", kind = "air", faction = "Horde", closed = false, { path = 301, noun = "Zeppelin", kind = "air", faction = "Horde",
stops = { stops = {
{ "Undercity", 0, 2062.6, 235.3 },
{ "Grom'gol", 0, -12406.9, 211.8 }, { "Grom'gol", 0, -12406.9, 211.8 },
{ "Undercity", 0, 2062.6, 235.3 },
}, },
parts = { legs = {
{ m = 0, next = 1, 2299, -1002, 2301, -944, 2301, -899, 2303, -821, 2304, -771, 2307, -710, 2309, -643, 2311, -575, 2311, -511, 2310, -447, 2309, -382, 2306, -319, 2303, -259, 2298, -207, 2281, -113, 2259, -39, 2231, 36, 2199, 102, 2165, 158, 2130, 201, 2063, 235, 1999, 229, 1955, 159, 1938, 87, 1919, -29, 1920, -83, 1922, -146, 1914, -217, 1896, -282, 1869, -356, 1841, -426, 1821, -479, 1798, -537, 96, -298, -2389, 55, -5266, 465, -8142, 875, -10627, 1226, -12327, 1461, -12333, 1354, -12327, 1288, -12318, 1209, -12312, 1121, -12311, 1067, -12310, 1010, -12310, 950, -12313, 887, -12318, 820, -12326, 757, -12337, 688, -12349, 616, -12361, 546, -12372, 481, -12381, 424, -12395, 339, -12405, 273, -12407, 212, -12399, 148, -12384, 88, -12366, 34, -12339, -26, -12302, -86, -12269, -141, -12230, -201, -12185, -257, -12135, -309, -12078, -356, -12008, -391, -11955, -402, -11894, -407, -11829, -409, -11765, -408, -11705, -408, -11631, -408, -11558, -406, -11491, -403, -11440, -401, -11373, -402 }, { from = 1, to = 2, smooth = true, 0, -12407, 212, -1, 0.7538, 0.6270, -1, 0.7634, 0.5056, -1, 0.7535, 0.3842, 0, 2063, 235 },
}, },
}, },
{ path = 302, noun = "Zeppelin", kind = "air", faction = "Horde", closed = false, { path = 302, noun = "Zeppelin", kind = "air", faction = "Horde",
stops = { stops = {
{ "Undercity", 0, 2062.4, 293.0 },
{ "Orgrimmar", 1, 1318.1, -4658.0 }, { "Orgrimmar", 1, 1318.1, -4658.0 },
{ "Undercity", 0, 2062.4, 293.0 },
}, },
parts = { legs = {
{ m = 0, next = 2, 3170, 1873, 3130, 1833, 3050, 1770, 3009, 1744, 2962, 1718, 2909, 1689, 2852, 1657, 2792, 1620, 2731, 1578, 2665, 1527, 2593, 1467, 2517, 1403, 2444, 1338, 2376, 1278, 2319, 1227, 2253, 1166, 2204, 1118, 2163, 1074, 2124, 1023, 2083, 964, 2047, 900, 2014, 837, 1989, 780, 1968, 713, 1957, 654, 1950, 600, 1943, 529, 1946, 465, 1962, 399, 1988, 343, 2062, 293, 2122, 286, 2201, 284, 2271, 279, 2352, 275, 2437, 271, 2505, 270, 2577, 271, 2648, 270, 2711, 265, 2782, 245, 2843, 219, 2907, 207, 2980, 218, 3055, 242, 3117, 269, 3179, 316, 3219, 362, 3248, 418 }, { from = 1, to = 2, smooth = true, 1, 1318, -4658, -1, 0.4157, 0.4617, -1, 0.5257, 0.4336, -1, 0.6281, 0.3674, 0, 2062, 293 },
{ m = 1, next = 1, 1321, -5756, 1335, -5686, 1345, -5625, 1357, -5546, 1363, -5460, 1361, -5391, 1355, -5316, 1347, -5240, 1337, -5170, 1322, -5106, 1304, -5044, 1287, -4987, 1277, -4935, 1283, -4843, 1298, -4773, 1310, -4707, 1318, -4658, 1312, -4599, 1295, -4556, 1263, -4536, 1224, -4564, 1219, -4625, 1239, -4700, 1248, -4762, 1256, -4831, 1263, -4894, 1268, -4962, 1270, -5045, 1269, -5140, 1265, -5217, 1260, -5299, 1257, -5370, 1258, -5447, 1260, -5494 },
}, },
}, },
{ path = 11398, noun = "Airship", kind = "air", faction = nil, closed = false, { path = 11398, noun = "Airship", kind = "air", faction = nil,
stops = { stops = {
{ "Zephras Isle", 2991, 1848.3, 569.1 },
{ "Dalaran", 0, 544.8, 424.2 }, { "Dalaran", 0, 544.8, 424.2 },
{ "Zephras Isle", 2991, 1848.3, 569.1 },
}, },
parts = { legs = {
{ m = 2991, next = 2, 1202, 482, 1286, 544, 1348, 589, 1413, 626, 1525, 624, 1576, 598, 1637, 562, 1696, 520, 1742, 480, 1781, 399, 1802, 327, 1882, 255, 1983, 254, 2028, 315, 2000, 370, 1926, 429, 1884, 500, 1848, 569, 1816, 618, 1822, 668, 1872, 774, 1827, 848, 1736, 849, 1633, 789, 1593, 757, 1543, 715, 1487, 668, 1431, 621, 1381, 578, 1343, 546, 1257, 477 }, { from = 1, to = 2, smooth = true, 0, 545, 424, 2991, 1848, 569 },
{ m = 0, next = 1, -1159, -364, -1108, -361, -1037, -357, -969, -354, -885, -352, -809, -352, -752, -350, -682, -351, -622, -353, -550, -357, -476, -361, -414, -364, -329, -370, -260, -376, -189, -382, -119, -385, -43, -387, 27, -384, 128, -348, 156, -288, 180, -219, 206, -171, 253, -117, 298, -77, 355, -30, 414, 18, 466, 64, 529, 117, 585, 169, 616, 225, 608, 291, 576, 361, 545, 424, 517, 499, 488, 559, 403, 640, 352, 652, 290, 660, 223, 675, 167, 694, 108, 718, 47, 746, -11, 779, -64, 818, -114, 864, -165, 912, -220, 960, -272, 1001, -330, 1046, -387, 1089, -437, 1127, -472, 1153 },
}, },
}, },
{ path = 11457, noun = "Airship", kind = "air", faction = nil, closed = false, { path = 11457, noun = "Airship", kind = "air", faction = nil,
stops = { stops = {
{ "Zephras Isle", 2991, 1952.5, 1019.1 },
{ "Thunder Bluff", 1, -802.0, 366.5 }, { "Thunder Bluff", 1, -802.0, 366.5 },
{ "Zephras Isle", 2991, 1952.5, 1019.1 },
}, },
parts = { legs = {
{ m = 2991, next = 2, 1123, 536, 1148, 549, 1179, 555, 1242, 567, 1332, 593, 1390, 619, 1456, 651, 1523, 685, 1582, 717, 1647, 753, 1704, 787, 1757, 823, 1812, 863, 1863, 906, 1903, 943, 1953, 1019, 1982, 1132, 2086, 1189, 2185, 1142, 2218, 1070, 2226, 986, 2191, 913, 2126, 852, 2065, 823, 1994, 802, 1928, 781, 1870, 760, 1780, 718, 1718, 686, 1639, 644, 1552, 598, 1465, 551, 1385, 509, 1321, 476, 1235, 433, 1179, 408, 1143, 392 }, { from = 1, to = 2, smooth = true, 1, -802, 367, 2991, 1953, 1019 },
{ m = 1, next = 1, -1724, -804, -1689, -814, -1593, -828, -1532, -837, -1454, -850, -1366, -864, -1276, -873, -1189, -872, -1114, -856, -1047, -825, -982, -784, -921, -733, -865, -672, -817, -604, -778, -528, -749, -437, -728, -328, -714, -211, -707, -95, -704, 11, -705, 98, -714, 193, -734, 262, -764, 316, -802, 367, -850, 421, -908, 471, -971, 507, -1034, 518, -1081, 505, -1125, 474, -1172, 432, -1226, 380, -1293, 323, -1366, 266, -1454, 195, -1549, 120, -1640, 46, -1718, -16, -1773, -60 },
}, },
}, },
} }

View file

@ -11,15 +11,19 @@ local COLORS = {
Horde = { 1.00, 0.32, 0.24 }, Horde = { 1.00, 0.32, 0.24 },
Neutral = { 1.00, 0.82, 0.25 }, Neutral = { 1.00, 0.82, 0.25 },
} }
-- dash and gap as a share of the canvas width; width in screen pixels -- line width in screen pixels, and opacity
local STYLE = { local STYLE = {
boat = { dash = 0.010, gap = 0.006, width = 3 }, boat = { width = 3, alpha = 0.95 },
air = { dash = 0.004, gap = 0.006, width = 2.5 }, air = { width = 2.5, alpha = 0.8 },
jump = { dash = 0.003, gap = 0.010 },
} }
-- the zone or continent map each instance is drawn from on the world map local DIMMED = 0.2 -- opacity of other routes while one is highlighted
local WORLD_MAP = 947 -- Azeroth: the shared space that legs between continents are drawn in
local WORLD = -1 -- instance marker in Data.lua for a point given on the world map
-- the zone or continent map each instance is placed on the world map by
local HOME_MAP = { [0] = 1415, [1] = 1414, [2991] = 2521 } local HOME_MAP = { [0] = 1415, [1] = 1414, [2991] = 2521 }
local NEARBY = 800 -- yards: other departures this close show in a dock's tooltip local NEARBY = 800 -- yards: other departures this close show in a dock's tooltip
local EXIT_INSET = 0.025 -- share of the map an edge marker sits inside the border
local EXIT_MERGE = 0.06 -- edge markers closer than this share of the map width merge
local db local db
@ -37,70 +41,156 @@ end
ns.Visible = Visible ns.Visible = Visible
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- Projection: world position -> normalized position on a uiMap -- Projection: (instance, world x, world y) or a world map point -> position on a uiMap
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local function DirectProjector(uiMapID) local function IsWorldMap(uiMapID)
local inst, topLeft = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0, 0)) local info = C_Map.GetMapInfo(uiMapID)
local _, mid = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0.5, 0.5)) return info and info.mapType and info.mapType <= Enum.UIMapType.World
if not inst or not topLeft or not mid then
return nil
end
local top, left = topLeft:GetXY()
local midTop, midLeft = mid:GetXY()
local height, width = (top - midTop) * 2, (left - midLeft) * 2
if height == 0 or width == 0 then
return nil
end
return function(m, x, y)
if m ~= inst then
return nil
end
return (left - y) / width, (top - x) / height
end
end end
local projectors = {} -- world position on a zone or continent map
local function GetProjector(uiMapID) local direct = {}
local cached = projectors[uiMapID] local function Direct(uiMapID)
local cached = direct[uiMapID]
if cached ~= nil then if cached ~= nil then
return cached or nil return cached or nil
end end
local proj local fn = false
local info = C_Map.GetMapInfo(uiMapID) if not IsWorldMap(uiMapID) then
if info and info.mapType and info.mapType <= Enum.UIMapType.World then local inst, topLeft = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0, 0))
-- world maps have no world position of their own: place each home map's rect on it local _, mid = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0.5, 0.5))
local rects = {} if inst and topLeft and mid then
for inst, home in pairs(HOME_MAP) do local top, left = topLeft:GetXY()
local minX, maxX, minY, maxY = C_Map.GetMapRectOnMap(home, uiMapID) local midTop, midLeft = mid:GetXY()
local direct = DirectProjector(home) local height, width = (top - midTop) * 2, (left - midLeft) * 2
if minX and direct and maxX ~= minX then if height ~= 0 and width ~= 0 then
rects[inst] = { direct, minX, maxX, minY, maxY } fn = function(m, x, y)
if m ~= inst then
return nil
end
return (left - y) / width, (top - x) / height
end
end end
end end
proj = function(m, x, y)
local r = rects[m]
if not r then
return nil
end
local u, v = r[1](m, x, y)
if not u then
return nil
end
return r[2] + u * (r[3] - r[2]), r[4] + v * (r[5] - r[4])
end
else
proj = DirectProjector(uiMapID)
end end
projectors[uiMapID] = proj or false direct[uiMapID] = fn
return proj return fn or nil
end end
ns.GetProjector = GetProjector
-- where a map sits on the world map: { minU, maxU, minV, maxV }
local rects = {}
local function Rect(uiMapID)
local cached = rects[uiMapID]
if cached ~= nil then
return cached or nil
end
local r = false
if uiMapID == WORLD_MAP then
r = { 0, 1, 0, 1 }
else
local minX, maxX, minY, maxY = C_Map.GetMapRectOnMap(uiMapID, WORLD_MAP)
if minX and maxX ~= minX and maxY ~= minY then
r = { minX, maxX, minY, maxY }
end
end
rects[uiMapID] = r
return r or nil
end
local function ToWorldMap(m, a, b)
if m == WORLD then
return a, b
end
local home = HOME_MAP[m]
local d, r = home and Direct(home), home and Rect(home)
if not d or not r then
return nil
end
local u, v = d(m, a, b)
if not u then
return nil
end
return r[1] + u * (r[2] - r[1]), r[3] + v * (r[4] - r[3])
end
local function Project(uiMapID, m, a, b)
if m ~= WORLD then
local d = Direct(uiMapID)
local u, v
if d then
u, v = d(m, a, b)
end
if u then
return u, v
end
end
local r = Rect(uiMapID)
if not r then
return nil
end
local wu, wv = ToWorldMap(m, a, b)
if not wu then
return nil
end
return (wu - r[1]) / (r[2] - r[1]), (wv - r[3]) / (r[4] - r[3])
end
ns.Project = Project
local function Inside(u, v) local function Inside(u, v)
return u and u >= 0 and u <= 1 and v >= 0 and v <= 1 return u and u >= 0 and u <= 1 and v >= 0 and v <= 1
end end
-- Catmull-Rom through flat canvas points, a step every ~12 units
local function Smooth(pts)
local n = #pts / 2
if n < 3 then
return pts
end
local out = {}
local function P(i)
i = math.max(1, math.min(n, i))
return pts[2 * i - 1], pts[2 * i]
end
for i = 1, n - 1 do
local x0, y0 = P(i - 1)
local x1, y1 = P(i)
local x2, y2 = P(i + 1)
local x3, y3 = P(i + 2)
local len = math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
local steps = math.max(2, math.min(24, math.floor(len / 12)))
for s = 0, steps - 1 do
local t = s / steps
local t2, t3 = t * t, t * t * t
out[#out + 1] = 0.5 * (2 * x1 + (-x0 + x2) * t + (2 * x0 - 5 * x1 + 4 * x2 - x3) * t2 + (-x0 + 3 * x1 - 3 * x2 + x3) * t3)
out[#out + 1] = 0.5 * (2 * y1 + (-y0 + y2) * t + (2 * y0 - 5 * y1 + 4 * y2 - y3) * t2 + (-y0 + 3 * y1 - 3 * y2 + y3) * t3)
end
end
out[#out + 1], out[#out + 2] = pts[#pts - 1], pts[#pts]
return out
end
-- walking from the start of a canvas polyline, where it first leaves the W x H box
local function ExitPoint(pts, W, H)
for i = 1, #pts - 3, 2 do
local ax, ay, bx, by = pts[i], pts[i + 1], pts[i + 2], pts[i + 3]
if bx < 0 or bx > W or by < 0 or by > H then
local t, edge = 1, nil
local function try(tt, e)
if tt >= 0 and tt < t then
t, edge = tt, e
end
end
if bx < 0 then try(ax / (ax - bx), "left") end
if bx > W then try((W - ax) / (bx - ax), "right") end
if by < 0 then try(ay / (ay - by), "top") end
if by > H then try((H - ay) / (by - ay), "bottom") end
return ax + (bx - ax) * t, ay + (by - ay) * t, math.atan2(-(by - ay), bx - ax), edge or "right"
end
end
return nil
end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- Text -- Text
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@ -142,10 +232,20 @@ local function Departures(stop, except)
return out return out
end end
-- an edge marker's line for one leg: where it leads, and how to say it
local function ExitText(e)
local route = e.route
local name = route.stops[e.far][1]
if #route.stops > 2 and e.far == e.leg.from then
return route.noun .. " from " .. name
end
return route.noun .. " to " .. name
end
local function FillTooltip(tip, pin) local function FillTooltip(tip, pin)
local route = pin.route
local c = Color(route)
if pin.kind == "dock" then if pin.kind == "dock" then
local route = pin.route
local c = Color(route)
local stop = route.stops[pin.index] local stop = route.stops[pin.index]
tip:SetText(stop[1], 1, 1, 1) tip:SetText(stop[1], 1, 1, 1)
tip:AddLine(RouteText(route, pin.index), c[1], c[2], c[3]) tip:AddLine(RouteText(route, pin.index), c[1], c[2], c[3])
@ -163,9 +263,15 @@ local function FillTooltip(tip, pin)
end end
tip:AddLine("Click: show " .. Destinations(route, pin.index)[1][1], 0.5, 0.5, 0.5) tip:AddLine("Click: show " .. Destinations(route, pin.index)[1][1], 0.5, 0.5, 0.5)
else else
local dest = route.stops[pin.index] local first = pin.exits[1]
tip:SetText(route.noun .. " to " .. dest[1], c[1], c[2], c[3]) local c = Color(first.route)
tip:AddLine("Click: show " .. dest[1], 0.5, 0.5, 0.5) tip:SetText(ExitText(first), c[1], c[2], c[3])
for k = 2, #pin.exits do
local e = pin.exits[k]
local ec = Color(e.route)
tip:AddLine(ExitText(e), ec[1], ec[2], ec[3])
end
tip:AddLine("Click: show " .. first.route.stops[first.far][1], 0.5, 0.5, 0.5)
end end
end end
ns.FillTooltip = FillTooltip ns.FillTooltip = FillTooltip
@ -177,11 +283,7 @@ local function ShowStop(map, stop)
return return
end end
local target = home local target = home
local proj = GetProjector(home) local u, v = Project(home, stop[2], stop[3], stop[4])
local u, v = nil, nil
if proj then
u, v = proj(stop[2], stop[3], stop[4])
end
if u then if u then
local info = C_Map.GetMapInfoAtPosition(home, u, v) local info = C_Map.GetMapInfoAtPosition(home, u, v)
if info and info.mapID then if info and info.mapID then
@ -192,7 +294,7 @@ local function ShowStop(map, stop)
end end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- Data provider: lines on an overlay, pins for docks and map exits -- Data provider: lines on an overlay, pins for docks and map edges
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local provider = CreateFromMixins(MapCanvasDataProviderMixin) local provider = CreateFromMixins(MapCanvasDataProviderMixin)
@ -230,7 +332,7 @@ end
function provider:Segment(x1, y1, x2, y2, c, alpha, px) function provider:Segment(x1, y1, x2, y2, c, alpha, px)
local scale = self:GetMap():GetCanvasScale() local scale = self:GetMap():GetCanvasScale()
for _, spec in ipairs({ { "BORDER", px + 2, 0, 0, 0, alpha * 0.6 }, { "ARTWORK", px, c[1], c[2], c[3], alpha } }) do for _, spec in ipairs({ { "BORDER", px + 2, 0, 0, 0, alpha * 0.55 }, { "ARTWORK", px, c[1], c[2], c[3], alpha } }) do
local line = self:Line(spec[1]) local line = self:Line(spec[1])
line.px = spec[2] line.px = spec[2]
line:SetThickness(spec[2] / scale) line:SetThickness(spec[2] / scale)
@ -240,72 +342,32 @@ function provider:Segment(x1, y1, x2, y2, c, alpha, px)
end end
end end
-- pts: flat canvas-unit list {x1, y1, x2, y2, ...}
function provider:Dashed(pts, dash, gap, W, H, c, alpha, px)
local on, left = true, dash
for i = 1, #pts - 3, 2 do
local ax, ay, bx, by = pts[i], pts[i + 1], pts[i + 2], pts[i + 3]
local dx, dy = bx - ax, by - ay
local len = math.sqrt(dx * dx + dy * dy)
local offscreen = (ax < 0 and bx < 0) or (ax > W and bx > W) or (ay < 0 and by < 0) or (ay > H and by > H)
local t = 0
while t < len do
local step = math.min(left, len - t)
if on and not offscreen then
local s, e = t / len, (t + step) / len
self:Segment(ax + dx * s, ay + dy * s, ax + dx * e, ay + dy * e, c, alpha, px)
end
t = t + step
left = left - step
if left <= 0 then
on = not on
left = on and dash or gap
end
end
end
end
function provider:DrawLines() function provider:DrawLines()
self:ClearLines() self:ClearLines()
local canvas = self:GetMap():GetCanvas() local canvas = self:GetMap():GetCanvas()
local W, H = canvas:GetWidth(), canvas:GetHeight() local W, H = canvas:GetWidth(), canvas:GetHeight()
if not W or W == 0 then local hl = self.highlight
return
end
for _, item in ipairs(self.drawn) do for _, item in ipairs(self.drawn) do
local route = item.route local route = item.route
local style = STYLE[route.kind] local style = STYLE[route.kind]
local c = Color(route) local c = Color(route)
local hl = self.highlight local alpha = (hl and not hl[route]) and DIMMED or style.alpha
local alpha = (hl and hl ~= route) and 0.25 or 0.95 local px = style.width + ((hl and hl[route]) and 1.5 or 0)
local px = style.width + (hl == route and 1.5 or 0) local pts = item.pts
local parts = item.parts for i = 1, #pts - 3, 2 do
for k, part in ipairs(parts) do local ax, ay, bx, by = pts[i], pts[i + 1], pts[i + 2], pts[i + 3]
if part then local offscreen = (ax < 0 and bx < 0) or (ax > W and bx > W) or (ay < 0 and by < 0) or (ay > H and by > H)
local pts = {} if not offscreen then
for j = 1, #part, 2 do self:Segment(ax, ay, bx, by, c, alpha, px)
pts[j], pts[j + 1] = part[j] * W, part[j + 1] * H
end
if route.closed then
pts[#pts + 1], pts[#pts + 2] = pts[1], pts[2]
end
self:Dashed(pts, style.dash * W, style.gap * W, W, H, c, alpha, px)
end
-- the jump to the next part (teleport or other continent), when both ends show here
local nextPart = parts[k % #parts + 1]
if not route.closed and part and nextPart then
local jump = { part[#part - 1] * W, part[#part] * H, nextPart[1] * W, nextPart[2] * H }
self:Dashed(jump, STYLE.jump.dash * W, STYLE.jump.gap * W, W, H, c, alpha * 0.8, px * 0.8)
end end
end end
end end
end end
function provider:SetHighlight(route) -- routes: a set of routes to light up, or nil
if self.highlight ~= route then function provider:SetHighlight(routes)
self.highlight = route self.highlight = routes
self:DrawLines() self:DrawLines()
end
end end
function provider:RemoveAllData() function provider:RemoveAllData()
@ -322,57 +384,88 @@ function provider:RefreshAllData()
end end
local map = self:GetMap() local map = self:GetMap()
local mapID = map:GetMapID() local mapID = map:GetMapID()
local proj = mapID and GetProjector(mapID) if not mapID then
if not proj then
return return
end end
self.overlay:SetFrameLevel(map:GetPinFrameLevelsManager():GetValidFrameLevel("PIN_FRAME_LEVEL_MAP_HIGHLIGHT")) self.overlay:SetFrameLevel(map:GetPinFrameLevelsManager():GetValidFrameLevel("PIN_FRAME_LEVEL_MAP_HIGHLIGHT"))
local canvas = map:GetCanvas() local canvas = map:GetCanvas()
local W, H = canvas:GetWidth(), canvas:GetHeight() local W, H = canvas:GetWidth(), canvas:GetHeight()
if not W or W == 0 then
return
end
local exits = {}
for _, route in ipairs(ns.routes) do for _, route in ipairs(ns.routes) do
if Visible(route) then if Visible(route) then
local item = { route = route, parts = {} }
local any = false
for k, part in ipairs(route.parts) do
local out = false
if proj(part.m, part[1], part[2]) then
out = {}
for j = 1, #part, 2 do
out[j], out[j + 1] = proj(part.m, part[j], part[j + 1])
end
any = true
end
item.parts[k] = out
end
if any then
self.drawn[#self.drawn + 1] = item
end
for i, stop in ipairs(route.stops) do for i, stop in ipairs(route.stops) do
local u, v = proj(stop[2], stop[3], stop[4]) local u, v = Project(mapID, stop[2], stop[3], stop[4])
if Inside(u, v) then if Inside(u, v) then
map:AcquirePin(TEMPLATE, "dock", route, i):SetPosition(u, v) map:AcquirePin(TEMPLATE, "dock", route, i):SetPosition(u, v)
end end
end end
-- an arrow where the route leaves this map for somewhere it doesn't show for _, leg in ipairs(route.legs) do
if not route.closed then local pts, ok = {}, true
local parts = item.parts for j = 1, #leg, 3 do
for k, part in ipairs(parts) do local u, v = Project(mapID, leg[j], leg[j + 1], leg[j + 2])
local n = part and #part or 0 if not u then
if n >= 4 and not parts[k % #parts + 1] and route.parts[k].next then ok = false
local u, v = part[n - 1], part[n] break
if Inside(u, v) then end
local dx, dy = (u - part[n - 3]) * W, (v - part[n - 2]) * H pts[#pts + 1], pts[#pts + 2] = u * W, v * H
local angle = math.atan2(-dy, dx) end
map:AcquirePin(TEMPLATE, "exit", route, route.parts[k].next, angle):SetPosition(u, v) if ok and #pts >= 4 then
if leg.smooth then
pts = Smooth(pts)
end
self.drawn[#self.drawn + 1] = { route = route, pts = pts }
-- a leg with one end on this map gets a marker where it leaves
local n = #pts
local startIn = Inside(pts[1] / W, pts[2] / H)
local endIn = Inside(pts[n - 1] / W, pts[n] / H)
if startIn ~= endIn then
local walk, far = pts, leg.to
if endIn then
walk, far = {}, leg.from
for j = n - 1, 1, -2 do
walk[#walk + 1], walk[#walk + 2] = pts[j], pts[j + 1]
end
end
local x, y, angle, edge = ExitPoint(walk, W, H)
if x then
exits[#exits + 1] = { route = route, leg = leg, far = far, x = x, y = y, angle = angle, edge = edge }
end end
end end
end end
end end
end end
end end
-- merge markers that leave at about the same place, then place them inside the border
local groups = {}
for _, e in ipairs(exits) do
local into
for _, g in ipairs(groups) do
local dx, dy = e.x - g[1].x, e.y - g[1].y
if dx * dx + dy * dy <= (EXIT_MERGE * W) ^ 2 then
into = g
break
end
end
if into then
into[#into + 1] = e
else
groups[#groups + 1] = { e }
end
end
local inset = EXIT_INSET
for _, g in ipairs(groups) do
local u = math.max(inset, math.min(1 - inset, g[1].x / W))
local v = math.max(inset, math.min(1 - inset, g[1].y / H))
map:AcquirePin(TEMPLATE, "exit", g):SetPosition(u, v)
end
self:DrawLines() self:DrawLines()
end end
@ -398,27 +491,67 @@ ShipRoutesPinMixin = CreateFromMixins(MapCanvasPinMixin)
function ShipRoutesPinMixin:OnLoad() function ShipRoutesPinMixin:OnLoad()
self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI") self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
self:SetScalingLimits(1, 1.0, 1.25) self:SetScalingLimits(1, 1.0, 1.25)
local font, size = self.Label:GetFont()
if font then
self.Label:SetFont(font, size, "OUTLINE")
end
end end
function ShipRoutesPinMixin:OnAcquired(kind, route, index, angle) local LABEL_ANCHOR = {
self.kind, self.route, self.index = kind, route, index left = { "LEFT", "RIGHT", 3, 0, "LEFT" },
local c = Color(route) right = { "RIGHT", "LEFT", -3, 0, "RIGHT" },
local exit = kind == "exit" top = { "TOP", "BOTTOM", 0, -2, "CENTER" },
self:SetSize(exit and 15 or 20, exit and 15 or 20) bottom = { "BOTTOM", "TOP", 0, 2, "CENTER" },
self.Disc:SetVertexColor(0.06, 0.06, 0.08, 0.9) }
self.Ring:SetVertexColor(c[1], c[2], c[3], 1)
self.Glyph:SetTexture(exit and GLYPH.exit or GLYPH[route.kind]) function ShipRoutesPinMixin:OnAcquired(kind, a, b)
self.Glyph:SetRotation(exit and angle or 0) self.kind = kind
if exit then self.Label:ClearAllPoints()
self.Glyph:SetVertexColor(c[1], c[2], c[3], 1) if kind == "dock" then
else self.route, self.index, self.exits = a, b, nil
local c = Color(a)
self:SetSize(20, 20)
self.Ring:SetVertexColor(c[1], c[2], c[3], 1)
self.Glyph:SetTexture(GLYPH[a.kind])
self.Glyph:SetRotation(0)
self.Glyph:SetVertexColor(1, 1, 1, 1) self.Glyph:SetVertexColor(1, 1, 1, 1)
self.Label:Hide()
else
local first = a[1]
self.route, self.index, self.exits = first.route, first.far, a
local c = Color(first.route)
self:SetSize(16, 16)
self.Ring:SetVertexColor(c[1], c[2], c[3], 1)
self.Glyph:SetTexture(GLYPH.exit)
self.Glyph:SetRotation(first.angle)
self.Glyph:SetVertexColor(c[1], c[2], c[3], 1)
-- one line per destination, in its route's colour
local text, seen = {}, {}
for _, e in ipairs(a) do
local name = e.route.stops[e.far][1]
local ec = Color(e.route)
local key = name .. ec[1]
if not seen[key] then
seen[key] = true
text[#text + 1] = string.format("|cff%02x%02x%02x%s|r", ec[1] * 255, ec[2] * 255, ec[3] * 255, name)
end
end
local anchor = LABEL_ANCHOR[first.edge]
self.Label:SetPoint(anchor[1], self, anchor[2], anchor[3], anchor[4])
self.Label:SetJustifyH(anchor[5])
self.Label:SetText(table.concat(text, "\n"))
self.Label:Show()
end end
self.Disc:SetVertexColor(0.06, 0.06, 0.08, 0.9)
self:CheckMouseButtonPassthrough("RightButton") self:CheckMouseButtonPassthrough("RightButton")
end end
function ShipRoutesPinMixin:OnMouseEnter() function ShipRoutesPinMixin:OnMouseEnter()
provider:SetHighlight(self.route) local set = { [self.route] = true }
for _, e in ipairs(self.exits or {}) do
set[e.route] = true
end
provider:SetHighlight(set)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT") GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
FillTooltip(GameTooltip, self) FillTooltip(GameTooltip, self)
GameTooltip:Show() GameTooltip:Show()

View file

@ -16,6 +16,9 @@
</Anchors> </Anchors>
</Texture> </Texture>
</Layer> </Layer>
<Layer level="OVERLAY">
<FontString parentKey="Label" inherits="GameFontHighlightSmall" hidden="true"/>
</Layer>
</Layers> </Layers>
<Scripts> <Scripts>
<OnLoad method="OnLoad"/> <OnLoad method="OnLoad"/>

View file

@ -4,6 +4,11 @@ usage: python3 generate.py <TaxiPathNode.db2> <Data.lua>
Transports sail along TaxiPath node lists. The client has no record of which paths are Transports sail along TaxiPath node lists. The client has no record of which paths are
transports, so the paths and the dock names below are curated by hand. A path whose stops transports, so the paths and the dock names below are curated by hand. A path whose stops
don't match a known dock fails the run instead of guessing. don't match a known dock fails the run instead of guessing.
Each route is drawn as legs between consecutive stops. A leg the ship sails without a
teleport follows its real path. A leg across a teleport (another continent, or a zeppelin
that vanishes mid-flight) follows hand-placed waypoints on the Azeroth world map instead,
so it goes around the continents rather than straight through them.
""" """
import collections, math, os, sys import collections, math, os, sys
@ -57,29 +62,55 @@ ROUTES = [
(11457, "Airship", "air", None), (11457, "Airship", "air", None),
] ]
# Where each continent sits on the Azeroth world map (uiMap 947), from UiMapAssignment.db2:
# instance -> (u min, u max, v min, v max, world x min, x max, y min, y max)
ON_WORLD_MAP = {
0: (0.5505, 0.8966, 0.0994, 0.8691, -16000, 6933, -7467, 8000),
1: (0.0399, 0.4083, 0.0855, 0.9234, -12800, 12267, -9600, 6933),
}
# Sea lanes for legs across a teleport, as points on the world map. They were placed on a
# 1517 x 1019 pixel render of uiMap 947; keys are (from, to) and are reversed as needed.
WAYPOINTS_PX = {
("Booty Bay", "Ratchet"): [(930, 770), (880, 710), (770, 600), (600, 585), (430, 550)],
("Menethil Harbor", "Theramore Isle"): [(960, 450), (700, 520), (430, 600)],
("Southshore", "Auberdine"): [(1010, 385), (930, 405), (700, 300), (440, 165), (300, 135), (205, 180)],
("Auberdine", "Menethil Harbor"): [(205, 180), (300, 135), (440, 165), (700, 300), (960, 430)],
("Stormwind Harbor", "Auberdine"): [(900, 590), (700, 380), (440, 165), (300, 135), (205, 180)],
("Steamwheedle Port", "Riverglades"): [(520, 770), (800, 830), (1050, 860), (1150, 770), (1235, 660)],
}
PX_W, PX_H, PX_X, PX_Y = 1517, 1019, 92, 32 # render size and the crop it was taken from
AIR_BEND = 0.12 # air legs without waypoints bow out by this share of their length
TELEPORT = 0x1 TELEPORT = 0x1
WORLD = -1 # instance marker for a point given in world map coordinates
def dock_name(m, x, y): def dock_name(m, x, y):
best = min((math.hypot(x - dx, y - dy), n) for n, dm, dx, dy in DOCKS if dm == m) if any(d[1] == m for d in DOCKS) else None near = [(math.hypot(x - dx, y - dy), n) for n, dm, dx, dy in DOCKS if dm == m]
if not best or best[0] > 300: if not near or min(near)[0] > 300:
raise SystemExit("no dock near %d %.0f %.0f" % (m, x, y)) raise SystemExit("no dock near %d %.0f %.0f" % (m, x, y))
return best[1] return min(near)[1]
def catmull(points, closed): def to_world_map(m, x, y):
if m not in ON_WORLD_MAP:
return None
u0, u1, v0, v1, xmin, xmax, ymin, ymax = ON_WORLD_MAP[m]
return u0 + (ymax - y) / (ymax - ymin) * (u1 - u0), v0 + (xmax - x) / (xmax - xmin) * (v1 - v0)
def catmull(points, steps_for):
"""Subdivide a polyline along a uniform Catmull-Rom spline.""" """Subdivide a polyline along a uniform Catmull-Rom spline."""
n = len(points) n = len(points)
if n < 3: if n < 3:
return points return points
out = [] out = []
segs = n if closed else n - 1 for i in range(n - 1):
for i in range(segs): p0, p1, p2 = points[max(i - 1, 0)], points[i], points[i + 1]
p0 = points[(i - 1) % n] if closed or i > 0 else points[i] p3 = points[min(i + 2, n - 1)]
p1 = points[i] steps = steps_for(p1, p2)
p2 = points[(i + 1) % n]
p3 = points[(i + 2) % n] if closed or i + 2 < n else p2
steps = max(1, min(6, int(math.hypot(p2[0] - p1[0], p2[1] - p1[1]) // 60)))
for s in range(steps): for s in range(steps):
t = s / steps t = s / steps
t2, t3 = t * t, t * t * t t2, t3 = t * t, t * t * t
@ -87,60 +118,83 @@ def catmull(points, closed):
0.5 * (2 * p1[k] + (-p0[k] + p2[k]) * t + (2 * p0[k] - 5 * p1[k] + 4 * p2[k] - p3[k]) * t2 0.5 * (2 * p1[k] + (-p0[k] + p2[k]) * t + (2 * p0[k] - 5 * p1[k] + 4 * p2[k] - p3[k]) * t2
+ (-p0[k] + 3 * p1[k] - 3 * p2[k] + p3[k]) * t3) + (-p0[k] + 3 * p1[k] - 3 * p2[k] + p3[k]) * t3)
for k in (0, 1))) for k in (0, 1)))
if not closed: out.append(points[-1])
out.append(points[-1])
return out return out
def build(path, nodes): def waypoints(kind, a, b):
"""World map points between stops a and b (name, m, x, y), or [] if none apply."""
if (a[0], b[0]) in WAYPOINTS_PX:
px = WAYPOINTS_PX[(a[0], b[0])]
elif (b[0], a[0]) in WAYPOINTS_PX:
px = list(reversed(WAYPOINTS_PX[(b[0], a[0])]))
else:
pa, pb = to_world_map(*a[1:]), to_world_map(*b[1:])
if kind == "air" and pa and pb:
# a gentle arc: a quadratic curve whose middle sits AIR_BEND of the length off
# the straight line (measured with the map's 1.5 aspect), sampled at a few points
dx, dy = (pb[0] - pa[0]) * 1.5, pb[1] - pa[1]
cx = (pa[0] + pb[0]) / 2 - dy * 2 * AIR_BEND / 1.5
cy = (pa[1] + pb[1]) / 2 + dx * 2 * AIR_BEND
return [((1 - t) ** 2 * pa[0] + 2 * (1 - t) * t * cx + t * t * pb[0],
(1 - t) ** 2 * pa[1] + 2 * (1 - t) * t * cy + t * t * pb[1]) for t in (0.25, 0.5, 0.75)]
if pa and pb:
raise SystemExit("no sea lane for %s - %s" % (a[0], b[0]))
return [] # one end isn't on the world map (Zephras Isle): nothing to draw between them
return [((x + PX_X) / PX_W, (y + PX_Y) / PX_H) for x, y in px]
def build(kind, nodes):
nodes = sorted(nodes) # (index, map, x, y, flags, delay) nodes = sorted(nodes) # (index, map, x, y, flags, delay)
n = len(nodes) n = len(nodes)
brk = [bool(nodes[i][4] & TELEPORT) or nodes[i][1] != nodes[(i + 1) % n][1] for i in range(n)] brk = [bool(nodes[i][4] & TELEPORT) or nodes[i][1] != nodes[(i + 1) % n][1] for i in range(n)]
closed = not any(brk)
start = 0 if closed else (brk.index(True) + 1) % n
order = nodes[start:] + nodes[:start]
brk = brk[start:] + brk[:start]
# stops in loop order, merging a stop that is split across the loop's seam # stops in node order, merging a stop that is split across the loop's seam
stops, stop_at = [], {} stops, at = [], []
for i, (_, m, x, y, _, delay) in enumerate(order): for i, (_, m, x, y, _, delay) in enumerate(nodes):
if delay: if delay:
name = dock_name(m, x, y) name = dock_name(m, x, y)
if stops and stops[-1][0] == name and stops[-1][1] == m: if stops and stops[-1][0] == name and stops[-1][1] == m:
stop_at[i] = len(stops) - 1
continue continue
stops.append((name, m, x, y)) stops.append((name, m, x, y))
stop_at[i] = len(stops) - 1 at.append(i)
if len(stops) > 2 and stops[0][0] == stops[-1][0]: if len(stops) > 2 and stops[0][0] == stops[-1][0]:
stops.pop() stops.pop()
stop_at = {i: (s if s < len(stops) else 0) for i, s in stop_at.items()} at.pop()
parts, cur = [], [] # a two-stop route is one line; longer loops draw every leg
for i, node in enumerate(order): pairs = [(0, 1)] if len(stops) == 2 else [(i, (i + 1) % len(stops)) for i in range(len(stops))]
cur.append(i) legs = []
if brk[i] or i == n - 1: for i, j in pairs:
parts.append(cur) span = []
cur = [] k = at[i]
while True:
out_parts = [] span.append(k)
for p in parts: if k == at[j]:
if len(p) < 2: # a lone node between two teleports draws nothing
continue
pts = catmull([(order[i][2], order[i][3]) for i in p], closed)
# first stop reached after this part ends, in loop order
nxt = None
for k in list(range(p[-1] + 1, n)) + list(range(0, p[-1] + 1)):
if k in stop_at:
nxt = stop_at[k]
break break
out_parts.append({"m": order[p[0]][1], "pts": pts, "next": nxt}) k = (k + 1) % n
return stops, out_parts, closed if not any(brk[k] for k in span[:-1]):
m = nodes[at[i]][1]
pts = catmull([(nodes[k][2], nodes[k][3]) for k in span],
lambda p, q: max(1, min(3, int(math.hypot(q[0] - p[0], q[1] - p[1]) // 80))))
legs.append({"from": i, "to": j, "smooth": False, "pts": [(m, x, y) for x, y in pts]})
else:
a, b = stops[i], stops[j]
mid = [(WORLD, u, v) for u, v in waypoints(kind, a, b)]
legs.append({"from": i, "to": j, "smooth": True, "pts": [a[1:]] + mid + [b[1:]]})
return stops, legs
def lua_str(s): def lua_str(s):
return '"' + s.replace("\\", "\\\\").replace('"', '\\"') + '"' return '"' + s.replace("\\", "\\\\").replace('"', '\\"') + '"'
def fmt(m, a, b):
if m == WORLD:
return "%d, %.4f, %.4f" % (m, a, b)
return "%d, %.0f, %.0f" % (m, a, b)
def main(): def main():
src, dst = sys.argv[1], sys.argv[2] src, dst = sys.argv[1], sys.argv[2]
rows, _ = read(src) rows, _ = read(src)
@ -152,27 +206,27 @@ def main():
lines = [ lines = [
"-- Generated by tools/generate.py from TaxiPathNode.db2. Do not edit by hand.", "-- Generated by tools/generate.py from TaxiPathNode.db2. Do not edit by hand.",
"-- stops: { name, instance, worldX, worldY }", "-- stops: { name, instance, worldX, worldY }",
"-- parts: sailed in order; a gap between parts is a teleport or a change of map.", "-- legs: from / to stop index, then points as (instance, worldX, worldY) triples;",
"-- next: index of the first stop reached after the part ends.", "-- instance -1 is a point on the Azeroth world map (u, v). smooth legs are drawn as a curve.",
"local _, ns = ...", "local _, ns = ...",
"ns.routes = {", "ns.routes = {",
] ]
for path, noun, kind, faction in ROUTES: for path, noun, kind, faction in ROUTES:
if path not in paths: if path not in paths:
raise SystemExit("path %d missing" % path) raise SystemExit("path %d missing" % path)
stops, parts, closed = build(path, paths[path]) stops, legs = build(kind, paths[path])
print(path, noun, " -> ".join(s[0] for s in stops), "%d parts" % len(parts), file=sys.stderr) print(path, noun, " -> ".join(s[0] for s in stops), "%d legs" % len(legs), file=sys.stderr)
lines.append(" { path = %d, noun = %s, kind = %s, faction = %s, closed = %s," % ( lines.append(" { path = %d, noun = %s, kind = %s, faction = %s," % (
path, lua_str(noun), lua_str(kind), lua_str(faction) if faction else "nil", "true" if closed else "false")) path, lua_str(noun), lua_str(kind), lua_str(faction) if faction else "nil"))
lines.append(" stops = {") lines.append(" stops = {")
for name, m, x, y in stops: for name, m, x, y in stops:
lines.append(" { %s, %d, %.1f, %.1f }," % (lua_str(name), m, x, y)) lines.append(" { %s, %d, %.1f, %.1f }," % (lua_str(name), m, x, y))
lines.append(" },") lines.append(" },")
lines.append(" parts = {") lines.append(" legs = {")
for part in parts: for leg in legs:
coords = ", ".join("%.0f, %.0f" % pt for pt in part["pts"]) lines.append(" { from = %d, to = %d, smooth = %s, %s }," % (
lines.append(" { m = %d, next = %s, %s }," % ( leg["from"] + 1, leg["to"] + 1, "true" if leg["smooth"] else "false",
part["m"], part["next"] + 1 if part["next"] is not None else "nil", coords)) ", ".join(fmt(*p) for p in leg["pts"])))
lines.append(" },") lines.append(" },")
lines.append(" },") lines.append(" },")
lines.append("}") lines.append("}")

View file

@ -10,14 +10,22 @@ local function check(cond, msg)
end end
end end
-- world rects: top/bottom are world X, left/right world Y -- Map rects from the client's UiMapAssignment.db2. top/bottom are world X, left/right world Y.
local RECTS = { local RECTS = {
[1415] = { inst = 0, top = 4000, bottom = -16000, left = 4000, right = -7000, type = 2 }, [1415] = { inst = 0, top = 7467, bottom = -16000, left = 16000, right = -19200, type = 2 },
[1414] = { inst = 1, top = 10000, bottom = -12000, left = 5000, right = -8000, type = 2 }, [1414] = { inst = 1, top = 12800, bottom = -11733, left = 17067, right = -19733, type = 2 },
[1437] = { inst = 0, top = -2000, bottom = -4500, left = 0, right = -3000, type = 3 }, -- "Wetlands" [1437] = { inst = 0, top = -1500, bottom = -4800, left = 200, right = -4800, type = 3 }, -- "Wetlands"
[2521] = { inst = 2991, top = 2500, bottom = 0, left = 1500, right = -1500, type = 3 }, [2521] = { inst = 2991, top = 4956, bottom = 1248, left = 4231, right = -1331, type = 3 },
} }
local ON_WORLD = { [1415] = { 0.55, 0.95, 0.1, 0.9 }, [1414] = { 0.05, 0.45, 0.1, 0.9 } } -- how each continent's world area sits on the Azeroth map (947): u0, u1, v0, v1, xmin, xmax, ymin, ymax
local ON_947 = {
[0] = { 0.5505, 0.8966, 0.0994, 0.8691, -16000, 6933, -7467, 8000 },
[1] = { 0.0399, 0.4083, 0.0855, 0.9234, -12800, 12267, -9600, 6933 },
}
local function to947(inst, x, y)
local a = ON_947[inst]
return a[1] + (a[8] - y) / (a[8] - a[7]) * (a[2] - a[1]), a[3] + (a[6] - x) / (a[6] - a[5]) * (a[4] - a[3])
end
Enum = { UIMapType = { Cosmic = 0, World = 1, Continent = 2, Zone = 3 } } Enum = { UIMapType = { Cosmic = 0, World = 1, Continent = 2, Zone = 3 } }
function CreateVector2D(x, y) function CreateVector2D(x, y)
@ -35,8 +43,11 @@ C_Map = {
return r.inst, CreateVector2D(r.top + (r.bottom - r.top) * v.y, r.left + (r.right - r.left) * v.x) return r.inst, CreateVector2D(r.top + (r.bottom - r.top) * v.y, r.left + (r.right - r.left) * v.x)
end, end,
GetMapRectOnMap = function(id, top) GetMapRectOnMap = function(id, top)
local r = top == 947 and ON_WORLD[id] local r = RECTS[id]
if r then return r[1], r[2], r[3], r[4] end if top ~= 947 or not r or not ON_947[r.inst] then return nil end
local u1, v1 = to947(r.inst, r.top, r.left)
local u2, v2 = to947(r.inst, r.bottom, r.right)
return u1, u2, v1, v2
end, end,
GetMapInfoAtPosition = function(id, u, v) GetMapInfoAtPosition = function(id, u, v)
return { mapID = id * 10 } return { mapID = id * 10 }
@ -112,6 +123,14 @@ WorldMapFrame = {
local pin = CreateFromMixins(ShipRoutesPinMixin) local pin = CreateFromMixins(ShipRoutesPinMixin)
pin.map = self pin.map = self
pin.Disc, pin.Ring, pin.Glyph = region(), region(), region() pin.Disc, pin.Ring, pin.Glyph = region(), region(), region()
local label = region()
function label:GetFont() return "font", 10 end
function label:SetFont(_, _, flags) self.flags = flags end
function label:ClearAllPoints() self.point = nil end
function label:SetPoint(p, _, rp) self.point = { p, rp } end
function label:SetJustifyH(j) self.justify = j end
function label:SetText(t) self.text = t end
pin.Label = label
function pin:SetSize(w) self.size = w end function pin:SetSize(w) self.size = w end
function pin:SetPosition(u, v) self.u, self.v = u, v end function pin:SetPosition(u, v) self.u, self.v = u, v end
pin:OnLoad() pin:OnLoad()
@ -147,12 +166,21 @@ check(provider ~= nil, "provider attached to the world map")
local function find(kind, name) local function find(kind, name)
for _, p in ipairs(pins) do for _, p in ipairs(pins) do
if p.kind == kind then if p.kind == kind and kind == "dock" and p.route.stops[p.index][1] == name then
local stop = p.route.stops[p.index] return p
if stop[1] == name then return p end end
if p.kind == kind and kind == "exit" then
for _, e in ipairs(p.exits) do
if e.route.stops[e.far][1] == name then return p end
end
end end
end end
end end
local function count(kind)
local n = 0
for _, p in ipairs(pins) do if p.kind == kind then n = n + 1 end end
return n
end
local function visibleLines() local function visibleLines()
local n = 0 local n = 0
for _, l in ipairs(allLines) do if l.shown then n = n + 1 end end for _, l in ipairs(allLines) do if l.shown then n = n + 1 end end
@ -163,27 +191,44 @@ end
check(#ns.routes == 12, "twelve routes, got " .. #ns.routes) check(#ns.routes == 12, "twelve routes, got " .. #ns.routes)
for _, r in ipairs(ns.routes) do for _, r in ipairs(ns.routes) do
check(#r.stops >= 2, "route " .. r.path .. " has two or more stops") check(#r.stops >= 2, "route " .. r.path .. " has two or more stops")
for _, p in ipairs(r.parts) do check(#r.legs == (#r.stops == 2 and 1 or #r.stops), "route " .. r.path .. " has one leg per stop pair")
check(#p >= 4 and #p % 2 == 0, "route " .. r.path .. " part has coordinate pairs") for _, leg in ipairs(r.legs) do
check(#leg >= 6 and #leg % 3 == 0, "route " .. r.path .. " leg has point triples")
check(leg[1] == r.stops[leg.from][2] and leg[2] == math.floor(r.stops[leg.from][3] + 0.5) or not leg.smooth,
"route " .. r.path .. " lane starts at its dock")
end end
end end
-- projection: EK corner and centre -- projection: EK map corner and centre, a world map point, and the world map itself
local proj = ns.GetProjector(1415) local u, v = ns.Project(1415, 0, 7467, 16000)
local u, v = proj(0, 4000, 4000)
check(math.abs(u) < 1e-9 and math.abs(v) < 1e-9, "top left projects to 0,0") check(math.abs(u) < 1e-9 and math.abs(v) < 1e-9, "top left projects to 0,0")
u, v = proj(0, -6000, -1500) u, v = ns.Project(1415, 0, (7467 - 16000) / 2, (16000 - 19200) / 2)
check(math.abs(u - 0.5) < 1e-9 and math.abs(v - 0.5) < 1e-9, "centre projects to 0.5,0.5") check(math.abs(u - 0.5) < 1e-9 and math.abs(v - 0.5) < 1e-9, "centre projects to 0.5,0.5")
check(proj(1, 0, 0) == nil, "other instance does not project") local wu, wv = to947(0, -14278, 583)
u, v = ns.Project(947, 0, -14278, 583)
check(math.abs(u - wu) < 1e-9 and math.abs(v - wv) < 1e-9, "Booty Bay lands where the client puts it on the world map")
u, v = ns.Project(1415, -1, wu, wv)
local bu, bv = ns.Project(1415, 0, -14278, 583)
check(math.abs(u - bu) < 1e-9 and math.abs(v - bv) < 1e-9, "a world map point maps back onto the continent")
u = ns.Project(1415, 1, -4016, -4741)
check(u and u < 0, "Theramore lies off the west edge of the EK map")
check(ns.Project(947, 2991, 1848, 569) == nil, "Zephras Isle has no place on the world map")
-- Eastern Kingdoms -- Eastern Kingdoms
mapID = 1415
provider:RefreshAllData() provider:RefreshAllData()
check(find("dock", "Stormwind Harbor") ~= nil, "Stormwind Harbor dock on EK") check(find("dock", "Stormwind Harbor") ~= nil, "Stormwind Harbor dock on EK")
check(find("dock", "Southshore") ~= nil, "Southshore dock on EK") check(find("dock", "Southshore") ~= nil, "Southshore dock on EK")
check(find("dock", "Riverglades") ~= nil, "Riverglades dock on EK")
check(find("dock", "Theramore Isle") == nil, "no Kalimdor docks on EK") check(find("dock", "Theramore Isle") == nil, "no Kalimdor docks on EK")
local exitToTheramore = find("exit", "Theramore Isle") local toTheramore = find("exit", "Theramore Isle")
check(exitToTheramore ~= nil, "exit arrow toward Theramore on EK") check(toTheramore ~= nil, "edge marker toward Theramore on EK")
check(exitToTheramore and exitToTheramore.Glyph.rotation ~= nil, "exit arrow is rotated") check(toTheramore and toTheramore.Glyph.rotation ~= nil, "edge arrow is rotated")
check(toTheramore and toTheramore.u <= 0.03, "Theramore marker sits on the west edge")
check(toTheramore and toTheramore.Label.text:find("Theramore Isle", 1, true), "edge marker is labelled")
check(toTheramore and toTheramore.Label.point[1] == "LEFT", "west edge label reads inward")
check(find("exit", "Zephras Isle") == nil, "no edge marker toward Zephras Isle")
check(find("exit", "Grom'gol") == nil, "no edge marker for a route that stays on the map")
check(visibleLines() > 50, "route lines drawn on EK, got " .. visibleLines()) check(visibleLines() > 50, "route lines drawn on EK, got " .. visibleLines())
check(provider.overlay.level == 100, "overlay frame level set") check(provider.overlay.level == 100, "overlay frame level set")
for _, l in ipairs(allLines) do for _, l in ipairs(allLines) do
@ -192,6 +237,9 @@ for _, l in ipairs(allLines) do
break break
end end
end end
for _, p in ipairs(pins) do
check(p.u >= 0 and p.u <= 1 and p.v >= 0 and p.v <= 1, "pins sit on the map")
end
-- tooltip at Menethil's Southshore pier -- tooltip at Menethil's Southshore pier
local menethil local menethil
@ -203,7 +251,7 @@ menethil:OnMouseEnter()
local tip = table.concat(tipLines, "\n") local tip = table.concat(tipLines, "\n")
check(tip:find("Boat to Southshore, then Auberdine", 1, true), "tooltip lists next stops in order:\n" .. tip) check(tip:find("Boat to Southshore, then Auberdine", 1, true), "tooltip lists next stops in order:\n" .. tip)
check(tip:find("Also from here:", 1, true) and tip:find("Boat to Theramore Isle", 1, true), "tooltip lists the other pier:\n" .. tip) check(tip:find("Also from here:", 1, true) and tip:find("Boat to Theramore Isle", 1, true), "tooltip lists the other pier:\n" .. tip)
check(provider.highlight == menethil.route, "hover highlights the route") check(provider.highlight and provider.highlight[menethil.route], "hover highlights the route")
local dim, bright = 0, 0 local dim, bright = 0, 0
for _, l in ipairs(allLines) do for _, l in ipairs(allLines) do
if l.shown and l.layer == "ARTWORK" then if l.shown and l.layer == "ARTWORK" then
@ -222,18 +270,41 @@ menethil:OnMouseClickAction("RightButton")
check(shownMap == nil, "right click does nothing") check(shownMap == nil, "right click does nothing")
check(menethil.passthrough == "RightButton", "right click passes through to the map") check(menethil.passthrough == "RightButton", "right click passes through to the map")
-- world map: both continents, jump connectors instead of exit arrows -- Kalimdor: the Southshore and Menethil lanes leave the east edge together, Stormwind's apart
mapID = 1414
provider:RefreshAllData()
local lane = find("exit", "Southshore")
check(lane ~= nil, "edge marker toward Southshore on Kalimdor")
local onLane = {}
for _, e in ipairs(lane and lane.exits or {}) do onLane[e.route.stops[e.far][1]] = true end
check(onLane["Menethil Harbor"], "Southshore and Menethil lanes share one marker")
check(find("exit", "Stormwind Harbor") ~= nil and find("exit", "Stormwind Harbor") ~= lane, "Stormwind lane has its own marker")
check(lane and lane.u >= 0.97, "Auberdine lane marker on the east edge")
check(lane and lane.Label.point[1] == "RIGHT", "east edge label reads inward")
lane:OnMouseEnter()
tip = table.concat(tipLines, "\n")
check(tip:find("Boat from Southshore", 1, true) and tip:find("Boat to Menethil Harbor", 1, true),
"edge tooltip names each lane:\n" .. tip)
local lit = 0
for r in pairs(provider.highlight or {}) do lit = lit + 1 end
check(lit == 2, "hovering the lane lights both routes on it, got " .. lit)
lane:OnMouseLeave()
lane:OnMouseClickAction("LeftButton")
check(shownMap ~= nil, "clicking an edge marker opens a map")
-- world map: everything on it, nothing to point off-map
mapID = 947 mapID = 947
provider:RefreshAllData() provider:RefreshAllData()
check(find("dock", "Theramore Isle") ~= nil and find("dock", "Menethil Harbor") ~= nil, "both continents on the world map") check(find("dock", "Theramore Isle") ~= nil and find("dock", "Menethil Harbor") ~= nil, "both continents on the world map")
check(find("exit", "Theramore Isle") == nil, "no exit arrow when the far side shows") check(count("exit") == 0, "no edge markers on the world map, got " .. count("exit"))
check(find("dock", "Zephras Isle") == nil, "Zephras Isle not placed on the mock world map") check(find("dock", "Zephras Isle") == nil, "Zephras Isle not on the world map")
-- zone map: docks outside it are left out -- zone map: docks outside it are left out, its lanes are labelled at the edge
mapID = 1437 mapID = 1437
provider:RefreshAllData() provider:RefreshAllData()
check(find("dock", "Menethil Harbor") ~= nil, "Menethil on its zone map") check(find("dock", "Menethil Harbor") ~= nil, "Menethil on its zone map")
check(find("dock", "Stormwind Harbor") == nil, "Stormwind not on the Wetlands map") check(find("dock", "Stormwind Harbor") == nil, "Stormwind not on the Wetlands map")
check(find("exit", "Theramore Isle") ~= nil and find("exit", "Southshore") ~= nil, "Wetlands edge markers toward Theramore and Southshore")
-- faction filter -- faction filter
faction = "Horde" faction = "Horde"