Add Ship Routes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-11-11 15:19:19 +00:00
parent 01a351a865
commit 63eebfc8bd
15 changed files with 1426 additions and 2 deletions

View file

@ -1,6 +1,6 @@
# WoW Forever addons # WoW Forever addons
Five small quality-of-life addons for WoW Forever (client 1.60.1, Interface 16001). Six small quality-of-life addons for WoW Forever (client 1.60.1, Interface 16001).
| Addon | What it does | Check command | | Addon | What it does | Check command |
| --- | --- | --- | | --- | --- | --- |
@ -9,10 +9,11 @@ Five small quality-of-life addons for WoW Forever (client 1.60.1, Interface 1600
| 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` |
## Install ## Install
Copy the five addon folders into `World of Warcraft/_forever_/Interface/AddOns/`, then type `/reload` in game. Copy the six 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. 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 ## Known limits
@ -23,6 +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.
## Tests ## Tests
@ -35,6 +37,7 @@ lua tests/test_vf.lua VendorFlag/VendorFlag.lua
lua tests/test_dpq.lua DungeonPreQuest/DungeonPreQuest.lua lua tests/test_dpq.lua DungeonPreQuest/DungeonPreQuest.lua
lua tests/test_dpq_minimap.lua DungeonPreQuest/Minimap.lua lua tests/test_dpq_minimap.lua DungeonPreQuest/Minimap.lua
lua tests/test_qsl.lua QuestShoppingList/QuestShoppingList.lua lua tests/test_qsl.lua QuestShoppingList/QuestShoppingList.lua
lua tests/test_sr.lua ShipRoutes
``` ```
## Regenerating Dungeon Pre-Quest's data ## Regenerating Dungeon Pre-Quest's data
@ -47,6 +50,18 @@ lua DungeonPreQuest/tools/generate.lua merged.lua DungeonPreQuest/Data.lua Dunge
lua QuestShoppingList/tools/generate.lua merged.lua QuestShoppingList/Data.lua lua QuestShoppingList/tools/generate.lua merged.lua QuestShoppingList/Data.lua
``` ```
## Regenerating Ship Routes' data
`ShipRoutes/Data.lua` comes from the client's own `TaxiPathNode.db2`, read out of the local game install (product `wowf`) with Python 3:
```
python3 ShipRoutes/tools/casc.py "<World of Warcraft dir>" wowf out 1000437
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.
## Credits and licence ## Credits and licence
Dungeon Pre-Quest's data is derived from [QuestieDB](https://github.com/Questie/QuestieDB) and Dungeon Pre-Quest's data is derived from [QuestieDB](https://github.com/Questie/QuestieDB) and

125
ShipRoutes/Data.lua Normal file
View file

@ -0,0 +1,125 @@
-- Generated by tools/generate.py from TaxiPathNode.db2. Do not edit by hand.
-- stops: { name, instance, worldX, worldY }
-- parts: sailed in order; a gap between parts is a teleport or a change of map.
-- next: index of the first stop reached after the part ends.
local _, ns = ...
ns.routes = {
{ path = 241, noun = "Boat", kind = "boat", faction = "Neutral", closed = false,
stops = {
{ "Booty Bay", 0, -14277.7, 582.9 },
{ "Ratchet", 1, -1005.6, -3841.6 },
},
parts = {
{ 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 },
{ 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,
stops = {
{ "Theramore Isle", 1, -4016.4, -4740.6 },
{ "Menethil Harbor", 0, -3905.2, -585.8 },
},
parts = {
{ 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 },
{ 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,
stops = {
{ "Rut'theran Village", 1, 8532.0, 1023.7 },
{ "Auberdine", 1, 6594.4, 759.8 },
},
parts = {
{ 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 },
},
},
{ path = 303, noun = "Boat", kind = "boat", faction = "Alliance", closed = true,
stops = {
{ "Feathermoon Stronghold", 1, -4197.3, 3286.6 },
{ "The Forgotten Coast", 1, -4347.8, 2444.4 },
},
parts = {
{ 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 },
},
},
{ path = 11167, noun = "Boat", kind = "boat", faction = "Alliance", closed = false,
stops = {
{ "Auberdine", 1, 6406.2, 823.1 },
{ "Menethil Harbor", 0, -3709.5, -575.1 },
{ "Southshore", 0, -1102.6, -554.7 },
},
parts = {
{ 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 },
{ 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 },
},
},
{ path = 11616, noun = "Boat", kind = "boat", faction = "Alliance", closed = false,
stops = {
{ "Stormwind Harbor", 0, -8654.5, 1344.4 },
{ "Auberdine", 1, 6548.3, 942.2 },
},
parts = {
{ 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 },
{ 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,
stops = {
{ "Riverglades", 0, -8232.3, -5800.8 },
{ "Steamwheedle Port", 1, -6932.6, -4950.8 },
},
parts = {
{ 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 },
{ 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,
stops = {
{ "Orgrimmar", 1, 1360.9, -4631.3 },
{ "Grom'gol", 0, -12464.0, 231.6 },
},
parts = {
{ 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 },
{ 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,
stops = {
{ "Undercity", 0, 2062.6, 235.3 },
{ "Grom'gol", 0, -12406.9, 211.8 },
},
parts = {
{ 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 },
},
},
{ path = 302, noun = "Zeppelin", kind = "air", faction = "Horde", closed = false,
stops = {
{ "Undercity", 0, 2062.4, 293.0 },
{ "Orgrimmar", 1, 1318.1, -4658.0 },
},
parts = {
{ 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 },
{ 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,
stops = {
{ "Zephras Isle", 2991, 1848.3, 569.1 },
{ "Dalaran", 0, 544.8, 424.2 },
},
parts = {
{ 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 },
{ 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,
stops = {
{ "Zephras Isle", 2991, 1952.5, 1019.1 },
{ "Thunder Bluff", 1, -802.0, 366.5 },
},
parts = {
{ 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 },
{ 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 },
},
},
}

BIN
ShipRoutes/Icons/anchor.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
ShipRoutes/Icons/arrow.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
ShipRoutes/Icons/disc.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
ShipRoutes/Icons/ring.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

493
ShipRoutes/ShipRoutes.lua Normal file
View file

@ -0,0 +1,493 @@
-- Ship Routes: draws boat, zeppelin and airship routes on the world map, with a marker
-- at each dock that says where the ship goes. Route data is in Data.lua (generated).
local addonName, ns = ...
local PREFIX = "|cff66bbffShip Routes|r: "
local TEMPLATE = "ShipRoutesPinTemplate"
local ICONS = "Interface\\AddOns\\ShipRoutes\\Icons\\"
local GLYPH = { boat = ICONS .. "anchor", air = ICONS .. "zeppelin", exit = ICONS .. "arrow" }
local COLORS = {
Alliance = { 0.35, 0.62, 1.00 },
Horde = { 1.00, 0.32, 0.24 },
Neutral = { 1.00, 0.82, 0.25 },
}
-- dash and gap as a share of the canvas width; width in screen pixels
local STYLE = {
boat = { dash = 0.010, gap = 0.006, width = 3 },
air = { dash = 0.004, gap = 0.006, width = 2.5 },
jump = { dash = 0.003, gap = 0.010 },
}
-- the zone or continent map each instance is drawn from on the world map
local HOME_MAP = { [0] = 1415, [1] = 1414, [2991] = 2521 }
local NEARBY = 800 -- yards: other departures this close show in a dock's tooltip
local db
local function Color(route)
return COLORS[route.faction or "Neutral"]
end
local function Visible(route)
if not db or not db.mine then
return true
end
local f = route.faction
return f == nil or f == "Neutral" or f == UnitFactionGroup("player")
end
ns.Visible = Visible
---------------------------------------------------------------------------
-- Projection: world position -> normalized position on a uiMap
---------------------------------------------------------------------------
local function DirectProjector(uiMapID)
local inst, topLeft = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0, 0))
local _, mid = C_Map.GetWorldPosFromMapPos(uiMapID, CreateVector2D(0.5, 0.5))
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
local projectors = {}
local function GetProjector(uiMapID)
local cached = projectors[uiMapID]
if cached ~= nil then
return cached or nil
end
local proj
local info = C_Map.GetMapInfo(uiMapID)
if info and info.mapType and info.mapType <= Enum.UIMapType.World then
-- world maps have no world position of their own: place each home map's rect on it
local rects = {}
for inst, home in pairs(HOME_MAP) do
local minX, maxX, minY, maxY = C_Map.GetMapRectOnMap(home, uiMapID)
local direct = DirectProjector(home)
if minX and direct and maxX ~= minX then
rects[inst] = { direct, minX, maxX, minY, maxY }
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
projectors[uiMapID] = proj or false
return proj
end
ns.GetProjector = GetProjector
local function Inside(u, v)
return u and u >= 0 and u <= 1 and v >= 0 and v <= 1
end
---------------------------------------------------------------------------
-- Text
---------------------------------------------------------------------------
-- the stops a ship leaving stop i calls at, in order
local function Destinations(route, i)
local out, n = {}, #route.stops
for k = 1, n - 1 do
out[k] = route.stops[(i - 1 + k) % n + 1]
end
return out
end
ns.Destinations = Destinations
local function RouteText(route, i)
local d = Destinations(route, i)
local text = route.noun .. " to " .. d[1][1]
for k = 2, #d do
text = text .. ", then " .. d[k][1]
end
return text
end
ns.RouteText = RouteText
local function Departures(stop, except)
local out = {}
for _, route in ipairs(ns.routes) do
if route ~= except and Visible(route) then
for i, s in ipairs(route.stops) do
if s[2] == stop[2] then
local dx, dy = s[3] - stop[3], s[4] - stop[4]
if dx * dx + dy * dy <= NEARBY * NEARBY then
out[#out + 1] = { route = route, index = i }
end
end
end
end
end
return out
end
local function FillTooltip(tip, pin)
local route = pin.route
local c = Color(route)
if pin.kind == "dock" then
local stop = route.stops[pin.index]
tip:SetText(stop[1], 1, 1, 1)
tip:AddLine(RouteText(route, pin.index), c[1], c[2], c[3])
if route.faction then
tip:AddLine(route.faction, 0.6, 0.6, 0.6)
end
local others = Departures(stop, route)
if #others > 0 then
tip:AddLine(" ")
tip:AddLine("Also from here:", 0.8, 0.8, 0.8)
for _, o in ipairs(others) do
local oc = Color(o.route)
tip:AddLine(RouteText(o.route, o.index), oc[1], oc[2], oc[3])
end
end
tip:AddLine("Click: show " .. Destinations(route, pin.index)[1][1], 0.5, 0.5, 0.5)
else
local dest = route.stops[pin.index]
tip:SetText(route.noun .. " to " .. dest[1], c[1], c[2], c[3])
tip:AddLine("Click: show " .. dest[1], 0.5, 0.5, 0.5)
end
end
ns.FillTooltip = FillTooltip
-- opens the zone map holding a stop, or its continent
local function ShowStop(map, stop)
local home = HOME_MAP[stop[2]]
if not home then
return
end
local target = home
local proj = GetProjector(home)
local u, v = nil, nil
if proj then
u, v = proj(stop[2], stop[3], stop[4])
end
if u then
local info = C_Map.GetMapInfoAtPosition(home, u, v)
if info and info.mapID then
target = info.mapID
end
end
map:SetMapID(target)
end
---------------------------------------------------------------------------
-- Data provider: lines on an overlay, pins for docks and map exits
---------------------------------------------------------------------------
local provider = CreateFromMixins(MapCanvasDataProviderMixin)
ns.provider = provider
function provider:OnAdded(map)
MapCanvasDataProviderMixin.OnAdded(self, map)
self.overlay = CreateFrame("Frame", nil, map:GetCanvas())
self.overlay:SetAllPoints(map:GetCanvas())
self.lines = { BORDER = {}, ARTWORK = {} }
self.used = { BORDER = 0, ARTWORK = 0 }
self.drawn = {}
end
function provider:Line(layer)
local n = self.used[layer] + 1
self.used[layer] = n
local line = self.lines[layer][n]
if not line then
line = self.overlay:CreateLine(nil, layer)
self.lines[layer][n] = line
end
line:Show()
return line
end
function provider:ClearLines()
for layer, list in pairs(self.lines) do
for i = 1, #list do
list[i]:Hide()
end
self.used[layer] = 0
end
end
function provider:Segment(x1, y1, x2, y2, c, alpha, px)
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
local line = self:Line(spec[1])
line.px = spec[2]
line:SetThickness(spec[2] / scale)
line:SetColorTexture(spec[3], spec[4], spec[5], spec[6])
line:SetStartPoint("TOPLEFT", self.overlay, x1, -y1)
line:SetEndPoint("TOPLEFT", self.overlay, x2, -y2)
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()
self:ClearLines()
local canvas = self:GetMap():GetCanvas()
local W, H = canvas:GetWidth(), canvas:GetHeight()
if not W or W == 0 then
return
end
for _, item in ipairs(self.drawn) do
local route = item.route
local style = STYLE[route.kind]
local c = Color(route)
local hl = self.highlight
local alpha = (hl and hl ~= route) and 0.25 or 0.95
local px = style.width + (hl == route and 1.5 or 0)
local parts = item.parts
for k, part in ipairs(parts) do
if part then
local pts = {}
for j = 1, #part, 2 do
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
function provider:SetHighlight(route)
if self.highlight ~= route then
self.highlight = route
self:DrawLines()
end
end
function provider:RemoveAllData()
self:GetMap():RemoveAllPinsByTemplate(TEMPLATE)
self:ClearLines()
self.drawn = {}
self.highlight = nil
end
function provider:RefreshAllData()
self:RemoveAllData()
if not db or db.hidden then
return
end
local map = self:GetMap()
local mapID = map:GetMapID()
local proj = mapID and GetProjector(mapID)
if not proj then
return
end
self.overlay:SetFrameLevel(map:GetPinFrameLevelsManager():GetValidFrameLevel("PIN_FRAME_LEVEL_MAP_HIGHLIGHT"))
local canvas = map:GetCanvas()
local W, H = canvas:GetWidth(), canvas:GetHeight()
for _, route in ipairs(ns.routes) do
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
local u, v = proj(stop[2], stop[3], stop[4])
if Inside(u, v) then
map:AcquirePin(TEMPLATE, "dock", route, i):SetPosition(u, v)
end
end
-- an arrow where the route leaves this map for somewhere it doesn't show
if not route.closed then
local parts = item.parts
for k, part in ipairs(parts) do
local n = part and #part or 0
if n >= 4 and not parts[k % #parts + 1] and route.parts[k].next then
local u, v = part[n - 1], part[n]
if Inside(u, v) then
local dx, dy = (u - part[n - 3]) * W, (v - part[n - 2]) * H
local angle = math.atan2(-dy, dx)
map:AcquirePin(TEMPLATE, "exit", route, route.parts[k].next, angle):SetPosition(u, v)
end
end
end
end
end
end
self:DrawLines()
end
function provider:OnCanvasScaleChanged()
local scale = self:GetMap():GetCanvasScale()
for layer, list in pairs(self.lines) do
for i = 1, self.used[layer] do
list[i]:SetThickness(list[i].px / scale)
end
end
end
function provider:OnCanvasSizeChanged()
self:RefreshAllData()
end
---------------------------------------------------------------------------
-- Pins
---------------------------------------------------------------------------
ShipRoutesPinMixin = CreateFromMixins(MapCanvasPinMixin)
function ShipRoutesPinMixin:OnLoad()
self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
self:SetScalingLimits(1, 1.0, 1.25)
end
function ShipRoutesPinMixin:OnAcquired(kind, route, index, angle)
self.kind, self.route, self.index = kind, route, index
local c = Color(route)
local exit = kind == "exit"
self:SetSize(exit and 15 or 20, exit and 15 or 20)
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])
self.Glyph:SetRotation(exit and angle or 0)
if exit then
self.Glyph:SetVertexColor(c[1], c[2], c[3], 1)
else
self.Glyph:SetVertexColor(1, 1, 1, 1)
end
self:CheckMouseButtonPassthrough("RightButton")
end
function ShipRoutesPinMixin:OnMouseEnter()
provider:SetHighlight(self.route)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
FillTooltip(GameTooltip, self)
GameTooltip:Show()
end
function ShipRoutesPinMixin:OnMouseLeave()
provider:SetHighlight(nil)
GameTooltip:Hide()
end
function ShipRoutesPinMixin:OnMouseClickAction(button)
if button ~= "LeftButton" then
return
end
local stop
if self.kind == "dock" then
stop = Destinations(self.route, self.index)[1]
else
stop = self.route.stops[self.index]
end
ShowStop(self:GetMap(), stop)
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:SetScript("OnEvent", function(_, _, name)
if name == addonName then
ShipRoutesDB = ShipRoutesDB or {}
db = ShipRoutesDB
Attach()
elseif name == "Blizzard_WorldMap" then
Attach()
end
end)
SLASH_SHIPROUTES1 = "/routes"
SlashCmdList.SHIPROUTES = function(msg)
msg = (msg or ""):lower():match("^%s*(.-)%s*$")
if msg == "mine" then
db.mine = true
db.hidden = false
print(PREFIX .. "showing routes your faction can take.")
elseif msg == "all" then
db.mine = false
db.hidden = false
print(PREFIX .. "showing all routes.")
elseif msg == "" then
db.hidden = not db.hidden
print(PREFIX .. (db.hidden and "hidden." or "shown."))
else
print(PREFIX .. "/routes toggles the map lines, /routes mine shows only your faction's, /routes all shows every route.")
end
Refresh()
end

View file

@ -0,0 +1,9 @@
## Interface: 16001
## Title: Ship Routes
## Notes: Draws boat, zeppelin and airship routes on the world map, with a marker at each dock.
## Version: 1.0
## SavedVariables: ShipRoutesDB
Data.lua
ShipRoutes.lua
ShipRoutes.xml

24
ShipRoutes/ShipRoutes.xml Normal file
View file

@ -0,0 +1,24 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Frame name="ShipRoutesPinTemplate" mixin="ShipRoutesPinMixin" enableMouse="true" virtual="true">
<Size x="20" y="20"/>
<Layers>
<Layer level="BACKGROUND">
<Texture parentKey="Disc" file="Interface\AddOns\ShipRoutes\Icons\disc" setAllPoints="true"/>
</Layer>
<Layer level="BORDER">
<Texture parentKey="Ring" file="Interface\AddOns\ShipRoutes\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>

139
ShipRoutes/tools/casc.py Normal file
View file

@ -0,0 +1,139 @@
"""Minimal local CASC reader: extract files by FileDataID.
usage: python3 casc.py <WoW dir> <product> <outdir> <fdid> [fdid...]"""
import os, sys, struct, zlib
wow, product, outdir = sys.argv[1], sys.argv[2], sys.argv[3]
fdids = [int(a) for a in sys.argv[4:]]
data = os.path.join(wow, "Data")
# .build.info -> build key
lines = open(os.path.join(wow, ".build.info")).read().splitlines()
cols = [c.split("!")[0] for c in lines[0].split("|")]
build_key = None
for l in lines[1:]:
row = dict(zip(cols, l.split("|")))
if row.get("Product") == product:
build_key = row["Build Key"]
print("version", row["Version"], file=sys.stderr)
assert build_key, "product not found"
def cfg(key):
p = os.path.join(data, "config", key[:2], key[2:4], key)
out = {}
for l in open(p):
if " = " in l:
k, v = l.strip().split(" = ", 1)
out[k] = v.split()
return out
build = cfg(build_key)
# local indices: highest version per bucket
idx = {}
best = {}
for f in os.listdir(os.path.join(data, "data")):
if f.endswith(".idx"):
b, v = int(f[:2], 16), int(f[2:10], 16)
if b not in best or v > best[b][0]:
best[b] = (v, f)
for _, f in best.values():
raw = open(os.path.join(data, "data", f), "rb").read()
hsize = struct.unpack_from("<I", raw, 0)[0]
pos = (8 + hsize + 0x0F) & ~0x0F
esize = struct.unpack_from("<I", raw, pos)[0]
pos += 8
for i in range(esize // 18):
e = raw[pos + i * 18: pos + i * 18 + 18]
key = e[:9]
off = int.from_bytes(e[9:14], "big")
size = struct.unpack_from("<I", e, 14)[0]
idx.setdefault(key, (off >> 30, off & 0x3FFFFFFF, size))
def blte(b):
assert b[:4] == b"BLTE", b[:4]
hsize = struct.unpack_from(">I", b, 4)[0]
if hsize == 0:
chunks = [len(b) - 8]
pos = 8
else:
n = int.from_bytes(b[9:12], "big")
chunks = [struct.unpack_from(">I", b, 12 + i * 24)[0] for i in range(n)]
pos = hsize
out = bytearray()
for c in chunks:
ch = b[pos:pos + c]
pos += c
m = ch[:1]
if m == b"N":
out += ch[1:]
elif m == b"Z":
out += zlib.decompress(ch[1:])
elif m == b"E":
raise ValueError("encrypted chunk")
else:
raise ValueError("chunk mode %r" % m)
return bytes(out)
def read_ekey(ekey):
a, off, size = idx[ekey[:9]]
with open(os.path.join(data, "data", "data.%03d" % a), "rb") as fh:
fh.seek(off)
b = fh.read(size)
return blte(b[30:])
# encoding: ckey -> ekey
enc = read_ekey(bytes.fromhex(build["encoding"][1]))
assert enc[:2] == b"EN"
ck, ek = enc[3], enc[4]
cepage = struct.unpack_from(">H", enc, 5)[0] * 1024
cecount = struct.unpack_from(">I", enc, 9)[0]
espec = struct.unpack_from(">I", enc, 18)[0]
pos = 22 + espec + cecount * 32
ckey2ekey = {}
for p in range(cecount):
page = enc[pos + p * cepage: pos + (p + 1) * cepage]
q = 0
while q + 6 + ck <= len(page):
n = page[q]
if n == 0:
break
c = page[q + 6: q + 6 + ck]
ckey2ekey[c] = page[q + 6 + ck: q + 6 + ck + ek]
q += 6 + ck + ek * n
# root (MFST): fdid -> ckey (prefer enUS / all-locale)
root = read_ekey(ckey2ekey[bytes.fromhex(build["root"][0])])
assert root[:4] == b"TSFM", root[:4]
hs, ver = struct.unpack_from("<II", root, 4)
if hs == 0x18:
pos = hs
else:
ver, pos = 0, 12
want = set(fdids)
found = {}
while pos < len(root):
if ver >= 2:
n, locale, u1, u2 = struct.unpack_from("<IIII", root, pos)
u3 = root[pos + 16]
content = u1 | u2 | (u3 << 17)
pos += 17
else:
n, content, locale = struct.unpack_from("<III", root, pos)
pos += 12
deltas = struct.unpack_from("<%di" % n, root, pos)
pos += 4 * n
keys = root[pos: pos + 16 * n]
pos += 16 * n
if not (content & 0x10000000):
pos += 8 * n
fd = -1
for i, d in enumerate(deltas):
fd = fd + 1 + d
if fd in want and (locale & 0x2 or fd not in found):
found[fd] = keys[i * 16:(i + 1) * 16]
os.makedirs(outdir, exist_ok=True)
for fd in fdids:
b = read_ekey(ckey2ekey[found[fd]])
open(os.path.join(outdir, "%d.db2" % fd), "wb").write(b)
print(fd, len(b), b[:4], file=sys.stderr)

View file

@ -0,0 +1,182 @@
"""Builds ShipRoutes/Data.lua from the client's TaxiPathNode.db2 (FileDataID 1000437).
usage: python3 generate.py <TaxiPathNode.db2> <Data.lua>
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
don't match a known dock fails the run instead of guessing.
"""
import collections, math, os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from wdc5 import read, f32
# name, instance (map id), world x, world y
DOCKS = [
("Ratchet", 1, -1006, -3842),
("Booty Bay", 0, -14278, 583),
("Menethil Harbor", 0, -3905, -586),
("Menethil Harbor", 0, -3709, -575),
("Theramore Isle", 1, -4016, -4741),
("Rut'theran Village", 1, 8532, 1024),
("Auberdine", 1, 6594, 760),
("Auberdine", 1, 6406, 823),
("Auberdine", 1, 6548, 942),
("Southshore", 0, -1103, -555),
("Stormwind Harbor", 0, -8654, 1344),
("Feathermoon Stronghold", 1, -4197, 3287),
("The Forgotten Coast", 1, -4348, 2444),
("Steamwheedle Port", 1, -6933, -4951),
("Riverglades", 0, -8232, -5801),
("Grom'gol", 0, -12464, 232),
("Grom'gol", 0, -12407, 212),
("Orgrimmar", 1, 1361, -4631),
("Orgrimmar", 1, 1318, -4658),
("Undercity", 0, 2063, 235),
("Undercity", 0, 2062, 293),
("Dalaran", 0, 545, 424),
("Thunder Bluff", 1, -802, 367),
("Zephras Isle", 2991, 1848, 569),
("Zephras Isle", 2991, 1953, 1019),
]
# path id, noun, kind, faction (None = unknown)
# Path 295 (Menethil - Auberdine direct) is still in the file, but 11167 uses the same
# piers with a Southshore stop, so it is the one that sails in Forever.
ROUTES = [
(241, "Boat", "boat", "Neutral"),
(292, "Boat", "boat", "Alliance"),
(293, "Boat", "boat", "Alliance"),
(303, "Boat", "boat", "Alliance"),
(11167, "Boat", "boat", "Alliance"),
(11616, "Boat", "boat", "Alliance"),
(11391, "Boat", "boat", "Neutral"),
(285, "Zeppelin", "air", "Horde"),
(301, "Zeppelin", "air", "Horde"),
(302, "Zeppelin", "air", "Horde"),
(11398, "Airship", "air", None),
(11457, "Airship", "air", None),
]
TELEPORT = 0x1
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
if not best or best[0] > 300:
raise SystemExit("no dock near %d %.0f %.0f" % (m, x, y))
return best[1]
def catmull(points, closed):
"""Subdivide a polyline along a uniform Catmull-Rom spline."""
n = len(points)
if n < 3:
return points
out = []
segs = n if closed else n - 1
for i in range(segs):
p0 = points[(i - 1) % n] if closed or i > 0 else points[i]
p1 = points[i]
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):
t = s / steps
t2, t3 = t * t, t * t * t
out.append(tuple(
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)
for k in (0, 1)))
if not closed:
out.append(points[-1])
return out
def build(path, nodes):
nodes = sorted(nodes) # (index, map, x, y, flags, delay)
n = len(nodes)
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, stop_at = [], {}
for i, (_, m, x, y, _, delay) in enumerate(order):
if delay:
name = dock_name(m, x, y)
if stops and stops[-1][0] == name and stops[-1][1] == m:
stop_at[i] = len(stops) - 1
continue
stops.append((name, m, x, y))
stop_at[i] = len(stops) - 1
if len(stops) > 2 and stops[0][0] == stops[-1][0]:
stops.pop()
stop_at = {i: (s if s < len(stops) else 0) for i, s in stop_at.items()}
parts, cur = [], []
for i, node in enumerate(order):
cur.append(i)
if brk[i] or i == n - 1:
parts.append(cur)
cur = []
out_parts = []
for p in parts:
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
out_parts.append({"m": order[p[0]][1], "pts": pts, "next": nxt})
return stops, out_parts, closed
def lua_str(s):
return '"' + s.replace("\\", "\\\\").replace('"', '\\"') + '"'
def main():
src, dst = sys.argv[1], sys.argv[2]
rows, _ = read(src)
paths = collections.defaultdict(list)
for r in rows:
loc, _id, p, idx, m, flags, delay, _a, _d = r["fields"]
paths[p].append((idx, m, f32(loc[0]), f32(loc[1]), flags, delay))
lines = [
"-- Generated by tools/generate.py from TaxiPathNode.db2. Do not edit by hand.",
"-- stops: { name, instance, worldX, worldY }",
"-- parts: sailed in order; a gap between parts is a teleport or a change of map.",
"-- next: index of the first stop reached after the part ends.",
"local _, ns = ...",
"ns.routes = {",
]
for path, noun, kind, faction in ROUTES:
if path not in paths:
raise SystemExit("path %d missing" % path)
stops, parts, closed = build(path, paths[path])
print(path, noun, " -> ".join(s[0] for s in stops), "%d parts" % len(parts), file=sys.stderr)
lines.append(" { path = %d, noun = %s, kind = %s, faction = %s, closed = %s," % (
path, lua_str(noun), lua_str(kind), lua_str(faction) if faction else "nil", "true" if closed else "false"))
lines.append(" stops = {")
for name, m, x, y in stops:
lines.append(" { %s, %d, %.1f, %.1f }," % (lua_str(name), m, x, y))
lines.append(" },")
lines.append(" parts = {")
for part in parts:
coords = ", ".join("%.0f, %.0f" % pt for pt in part["pts"])
lines.append(" { m = %d, next = %s, %s }," % (
part["m"], part["next"] + 1 if part["next"] is not None else "nil", coords))
lines.append(" },")
lines.append(" },")
lines.append("}")
open(dst, "w").write("\n".join(lines) + "\n")
main()

81
ShipRoutes/tools/icons.py Normal file
View file

@ -0,0 +1,81 @@
"""Draws the map marker textures as 64x64 white-on-transparent TGAs (tinted in game).
usage: python3 icons.py <Icons dir>"""
import math, os, struct, sys
N, SS = 64, 4 # size, supersampling
def seg_dist(px, py, ax, ay, bx, by):
dx, dy = bx - ax, by - ay
t = max(0.0, min(1.0, ((px - ax) * dx + (py - ay) * dy) / (dx * dx + dy * dy)))
return math.hypot(px - ax - t * dx, py - ay - t * dy)
def in_tri(px, py, a, b, c):
def s(p, q, r):
return (p[0] - r[0]) * (q[1] - r[1]) - (q[0] - r[0]) * (p[1] - r[1])
d1, d2, d3 = s((px, py), a, b), s((px, py), b, c), s((px, py), c, a)
neg = d1 < 0 or d2 < 0 or d3 < 0
pos = d1 > 0 or d2 > 0 or d3 > 0
return not (neg and pos)
def disc(x, y):
return math.hypot(x - 32, y - 32) <= 30
def ring(x, y):
return 25.5 <= math.hypot(x - 32, y - 32) <= 30
def anchor(x, y):
if abs(math.hypot(x - 32, y - 13) - 4.5) <= 1.8: # eye
return True
if seg_dist(x, y, 32, 17, 32, 51) <= 2.2: # shank
return True
if seg_dist(x, y, 23, 23, 41, 23) <= 2.0: # stock
return True
r = math.hypot(x - 32, y - 33)
if y >= 33 and abs(r - 17) <= 2.2: # arms
return True
for side in (-1, 1): # flukes
if in_tri(x, y, (32 + side * 17, 30), (32 + side * 12, 38), (32 + side * 22, 38)):
return True
return False
def zeppelin(x, y):
if ((x - 34) / 21) ** 2 + ((y - 24) / 11) ** 2 <= 1: # envelope
return True
for a, b, c in (((15, 24), (6, 14), (12, 24)), ((15, 24), (6, 34), (12, 24))): # tail fins
if in_tri(x, y, a, b, c):
return True
if seg_dist(x, y, 9, 15, 9, 33) <= 2:
return True
if 26 <= x <= 42 and 40 <= y <= 47: # gondola
return True
if seg_dist(x, y, 29, 33, 29, 40) <= 1.3 or seg_dist(x, y, 39, 33, 39, 40) <= 1.3:
return True
return False
def arrow(x, y): # points right, rotated in game
if seg_dist(x, y, 12, 32, 44, 32) <= 4:
return True
return in_tri(x, y, (54, 32), (36, 18), (36, 46))
def write(path, fn):
px = bytearray()
for j in range(N):
for i in range(N):
hits = sum(fn(i + (a + 0.5) / SS, j + (b + 0.5) / SS) for a in range(SS) for b in range(SS))
alpha = round(255 * hits / (SS * SS))
px += bytes((255, 255, 255, alpha))
header = struct.pack("<BBBHHBHHHHBB", 0, 0, 2, 0, 0, 0, 0, 0, N, N, 32, 0x28)
open(path, "wb").write(header + px)
out = sys.argv[1]
for name, fn in (("disc", disc), ("ring", ring), ("anchor", anchor), ("zeppelin", zeppelin), ("arrow", arrow)):
write(os.path.join(out, name + ".tga"), fn)

96
ShipRoutes/tools/wdc5.py Normal file
View file

@ -0,0 +1,96 @@
"""Generic WDC5 reader: rows as {"id", "fields": [values...], "rel"}; floats left as raw u32."""
import struct
def read(path):
b = open(path, "rb").read()
assert b[:4] == b"WDC5", b[:4]
(rc, fc, rs, sts, th, lh, minid, maxid, loc) = struct.unpack_from("<9I", b, 136)
flags, id_index = struct.unpack_from("<HH", b, 172)
(tfc, bpo, lcc, fsis, cds, pds, sc) = struct.unpack_from("<7I", b, 176)
pos = 204
sections = []
for i in range(sc):
sections.append(struct.unpack_from("<Q8I", b, pos))
pos += 40
fstruct = [struct.unpack_from("<hH", b, pos + i * 4) for i in range(fc)]
pos += fc * 4
finfo = [struct.unpack_from("<HHIIIII", b, pos + i * 24) for i in range(fsis // 24)]
pos += fsis
pallet_start = pos
pos += pds
common_start = pos
pos += cds
# per-field pallet/common offsets
pal_off, com = [], []
po, co = pallet_start, common_start
for (fo, fs, ads, comp, v1, v2, v3) in finfo:
pal_off.append(po if comp in (3, 4) else None)
if comp in (3, 4):
po += ads
if comp == 2:
d = {}
for k in range(ads // 8):
i_, v_ = struct.unpack_from("<II", b, co + k * 8)
d[i_] = v_
com.append(d)
co += ads
else:
com.append(None)
# encrypted id lists
for s in sections:
if s[0] != 0:
n = struct.unpack_from("<I", b, pos)[0]
pos += 4 + 4 * n
rows = []
for (tact, off, src, ssz, ore, idls, rels, omc, ctc) in sections:
if tact != 0 and all(x == 0 for x in b[off:off + 16]):
continue
p = off
recs = b[p:p + src * rs]
p += src * rs + ssz
ids = list(struct.unpack_from("<%dI" % (idls // 4), b, p)) if idls else None
p += idls
copies = [struct.unpack_from("<II", b, p + k * 8) for k in range(ctc)]
p += ctc * 8 + omc * 6
rel = {}
if rels:
n = struct.unpack_from("<I", b, p)[0]
for k in range(n):
fid, ri = struct.unpack_from("<II", b, p + 12 + k * 8)
rel[ri] = fid
for r in range(src):
rec = int.from_bytes(recs[r * rs:(r + 1) * rs], "little")
vals = []
for f, (fo, fs, ads, comp, v1, v2, v3) in enumerate(finfo):
raw = (rec >> fo) & ((1 << fs) - 1)
if comp == 0:
n = max(1, fs // 32)
v = [(raw >> (32 * k)) & 0xFFFFFFFF for k in range(n)] if fs >= 32 else [raw]
vals.append(v if len(v) > 1 else v[0])
elif comp == 1:
vals.append(raw)
elif comp == 5:
vals.append(raw - (1 << fs) if raw >> (fs - 1) else raw)
elif comp == 2:
vals.append(None) # filled after id known
elif comp == 3:
vals.append(struct.unpack_from("<I", b, pal_off[f] + raw * 4)[0])
elif comp == 4:
vals.append(list(struct.unpack_from("<%dI" % v3, b, pal_off[f] + raw * 4 * v3)))
rid = ids[r] if ids else vals[id_index]
for f, (fo, fs, ads, comp, v1, v2, v3) in enumerate(finfo):
if comp == 2:
vals[f] = com[f].get(rid, v1)
rows.append({"id": rid, "fields": vals, "rel": rel.get(r), "base": off + r * rs, "b": b})
for new, old in copies:
src_row = next(x for x in rows if x["id"] == old)
rows.append(dict(src_row, id=new))
return rows, finfo
def f32(u):
return struct.unpack("<f", struct.pack("<I", u & 0xFFFFFFFF))[0]
def string(row, finfo, f):
b = row["b"]
p = row["base"] + finfo[f][0] // 8 + row["fields"][f]
return b[p:b.index(b"\0", p)].decode("utf8", "replace")

260
tests/test_sr.lua Normal file
View file

@ -0,0 +1,260 @@
-- Runs ShipRoutes against a mock of the WoW map API.
-- arg[1] = addon folder (ShipRoutes)
local dir = arg[1] or "ShipRoutes"
local failures = 0
local function check(cond, msg)
if not cond then
failures = failures + 1
io.write("FAIL: ", msg, "\n")
end
end
-- world rects: top/bottom are world X, left/right world Y
local RECTS = {
[1415] = { inst = 0, top = 4000, bottom = -16000, left = 4000, right = -7000, type = 2 },
[1414] = { inst = 1, top = 10000, bottom = -12000, left = 5000, right = -8000, type = 2 },
[1437] = { inst = 0, top = -2000, bottom = -4500, left = 0, right = -3000, type = 3 }, -- "Wetlands"
[2521] = { inst = 2991, top = 2500, bottom = 0, left = 1500, right = -1500, type = 3 },
}
local ON_WORLD = { [1415] = { 0.55, 0.95, 0.1, 0.9 }, [1414] = { 0.05, 0.45, 0.1, 0.9 } }
Enum = { UIMapType = { Cosmic = 0, World = 1, Continent = 2, Zone = 3 } }
function CreateVector2D(x, y)
return { x = x, y = y, GetXY = function(self) return self.x, self.y end }
end
C_Map = {
GetMapInfo = function(id)
if id == 947 then return { mapID = 947, mapType = 1 } end
local r = RECTS[id]
return r and { mapID = id, mapType = r.type }
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,
GetMapRectOnMap = function(id, top)
local r = top == 947 and ON_WORLD[id]
if r then return r[1], r[2], r[3], r[4] end
end,
GetMapInfoAtPosition = function(id, u, v)
return { mapID = id * 10 }
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,
}
MapCanvasPinMixin = {
UseFrameLevelType = function() end,
SetScalingLimits = function() end,
CheckMouseButtonPassthrough = function(self, b) self.passthrough = b end,
GetMap = function(self) return self.map end,
}
local function region()
local r = { shown = true }
function r:Show() self.shown = true end
function r:Hide() self.shown = false end
function r:SetThickness(t) self.thickness = t end
function r:SetColorTexture(cr, cg, cb, ca) self.color = { cr, cg, cb, ca } end
function r:SetStartPoint(_, _, x, y) self.x1, self.y1 = x, y end
function r:SetEndPoint(_, _, x, y) self.x2, self.y2 = x, y end
function r:SetVertexColor(cr, cg, cb, ca) self.vertex = { cr, cg, cb, ca } end
function r:SetTexture(p) self.texture = p end
function r:SetRotation(a) self.rotation = a end
return r
end
local eventFrame
local allLines = {}
function CreateFrame(kind, _, parent)
local f = { scripts = {} }
function f:RegisterEvent() end
function f:SetScript(name, fn) self.scripts[name] = fn end
function f:SetAllPoints() end
function f:SetFrameLevel(l) self.level = l end
function f:CreateLine(_, layer)
local l = region()
l.layer = layer
allLines[#allLines + 1] = l
return l
end
if not parent then eventFrame = f end
return f
end
local canvas = { GetWidth = function() return 1000 end, GetHeight = function() return 700 end }
local pins = {}
local mapID = 1415
local shownMap
WorldMapFrame = {
AddDataProvider = function(self, p) p:OnAdded(self); self.provider = p end,
GetCanvas = function() return canvas end,
GetMapID = function() return mapID end,
GetCanvasScale = function() return 2 end,
GetPinFrameLevelsManager = function()
return { GetValidFrameLevel = function() return 100 end }
end,
RemoveAllPinsByTemplate = function() pins = {} end,
SetMapID = function(_, id) shownMap = id end,
AcquirePin = function(self, template, ...)
assert(template == "ShipRoutesPinTemplate")
local pin = CreateFromMixins(ShipRoutesPinMixin)
pin.map = self
pin.Disc, pin.Ring, pin.Glyph = region(), region(), region()
function pin:SetSize(w) self.size = w end
function pin:SetPosition(u, v) self.u, self.v = u, v end
pin:OnLoad()
pin:OnAcquired(...)
pins[#pins + 1] = pin
return pin
end,
}
local tipLines = {}
GameTooltip = {
SetOwner = function() tipLines = {} end,
SetText = function(_, t) tipLines[#tipLines + 1] = t end,
AddLine = function(_, t) tipLines[#tipLines + 1] = t end,
Show = function() end,
Hide = function() end,
}
local faction = "Alliance"
function UnitFactionGroup() return faction end
local realPrint = print
local printed
function print(msg) printed = msg end
SlashCmdList = {}
local ns = {}
assert(loadfile(dir .. "/Data.lua"))("ShipRoutes", ns)
assert(loadfile(dir .. "/ShipRoutes.lua"))("ShipRoutes", ns)
eventFrame.scripts.OnEvent(eventFrame, "ADDON_LOADED", "ShipRoutes")
local provider = WorldMapFrame.provider
check(provider ~= nil, "provider attached to the world map")
local function find(kind, name)
for _, p in ipairs(pins) do
if p.kind == kind then
local stop = p.route.stops[p.index]
if stop[1] == name then return p end
end
end
end
local function visibleLines()
local n = 0
for _, l in ipairs(allLines) do if l.shown then n = n + 1 end end
return n
end
-- the data itself
check(#ns.routes == 12, "twelve routes, got " .. #ns.routes)
for _, r in ipairs(ns.routes) do
check(#r.stops >= 2, "route " .. r.path .. " has two or more stops")
for _, p in ipairs(r.parts) do
check(#p >= 4 and #p % 2 == 0, "route " .. r.path .. " part has coordinate pairs")
end
end
-- projection: EK corner and centre
local proj = ns.GetProjector(1415)
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")
u, v = proj(0, -6000, -1500)
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")
-- Eastern Kingdoms
provider:RefreshAllData()
check(find("dock", "Stormwind Harbor") ~= nil, "Stormwind Harbor dock on EK")
check(find("dock", "Southshore") ~= nil, "Southshore dock on EK")
check(find("dock", "Theramore Isle") == nil, "no Kalimdor docks on EK")
local exitToTheramore = find("exit", "Theramore Isle")
check(exitToTheramore ~= nil, "exit arrow toward Theramore on EK")
check(exitToTheramore and exitToTheramore.Glyph.rotation ~= nil, "exit arrow is rotated")
check(visibleLines() > 50, "route lines drawn on EK, got " .. visibleLines())
check(provider.overlay.level == 100, "overlay frame level set")
for _, l in ipairs(allLines) do
if l.shown then
check(math.abs(l.thickness - l.px / 2) < 1e-9, "line thickness divides by canvas scale")
break
end
end
-- tooltip at Menethil's Southshore pier
local menethil
for _, p in ipairs(pins) do
if p.kind == "dock" and p.route.path == 11167 and p.route.stops[p.index][1] == "Menethil Harbor" then menethil = p end
end
check(menethil ~= nil, "Menethil pier of the Southshore boat")
menethil:OnMouseEnter()
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("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")
local dim, bright = 0, 0
for _, l in ipairs(allLines) do
if l.shown and l.layer == "ARTWORK" then
if l.color[4] < 0.5 then dim = dim + 1 else bright = bright + 1 end
end
end
check(dim > 0 and bright > 0, "other routes dim while one is highlighted")
menethil:OnMouseLeave()
check(provider.highlight == nil, "leaving clears the highlight")
-- click opens the next stop's zone
menethil:OnMouseClickAction("LeftButton")
check(shownMap == 14150, "click shows Southshore's zone, got " .. tostring(shownMap))
shownMap = nil
menethil:OnMouseClickAction("RightButton")
check(shownMap == nil, "right click does nothing")
check(menethil.passthrough == "RightButton", "right click passes through to the map")
-- world map: both continents, jump connectors instead of exit arrows
mapID = 947
provider:RefreshAllData()
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(find("dock", "Zephras Isle") == nil, "Zephras Isle not placed on the mock world map")
-- zone map: docks outside it are left out
mapID = 1437
provider:RefreshAllData()
check(find("dock", "Menethil Harbor") ~= nil, "Menethil on its zone map")
check(find("dock", "Stormwind Harbor") == nil, "Stormwind not on the Wetlands map")
-- faction filter
faction = "Horde"
mapID = 1415
SlashCmdList.SHIPROUTES("mine")
check(find("dock", "Stormwind Harbor") == nil, "Alliance docks hidden for Horde with /routes mine")
check(find("dock", "Grom'gol") ~= nil, "Horde docks kept")
check(find("dock", "Booty Bay") ~= nil, "neutral docks kept")
check(find("dock", "Dalaran") ~= nil, "unknown-faction docks kept")
SlashCmdList.SHIPROUTES("all")
check(find("dock", "Stormwind Harbor") ~= nil, "/routes all shows Alliance docks again")
-- toggle
SlashCmdList.SHIPROUTES("")
check(#pins == 0 and visibleLines() == 0, "/routes hides everything")
check(ShipRoutesDB.hidden == true, "hidden is saved")
SlashCmdList.SHIPROUTES("")
check(#pins > 0, "/routes shows it again")
if failures > 0 then
realPrint(failures .. " failure(s)")
os.exit(1)
end
realPrint("ok")