From 63eebfc8bd2cb6375f9db792f0d187aa94676610 Mon Sep 17 00:00:00 2001 From: rope Date: Wed, 11 Nov 2026 15:19:19 +0000 Subject: [PATCH] Add Ship Routes Co-Authored-By: Claude Opus 5.5 --- README.md | 19 +- ShipRoutes/Data.lua | 125 +++++++++ ShipRoutes/Icons/anchor.tga | Bin 0 -> 16402 bytes ShipRoutes/Icons/arrow.tga | Bin 0 -> 16402 bytes ShipRoutes/Icons/disc.tga | Bin 0 -> 16402 bytes ShipRoutes/Icons/ring.tga | Bin 0 -> 16402 bytes ShipRoutes/Icons/zeppelin.tga | Bin 0 -> 16402 bytes ShipRoutes/ShipRoutes.lua | 493 ++++++++++++++++++++++++++++++++++ ShipRoutes/ShipRoutes.toc | 9 + ShipRoutes/ShipRoutes.xml | 24 ++ ShipRoutes/tools/casc.py | 139 ++++++++++ ShipRoutes/tools/generate.py | 182 +++++++++++++ ShipRoutes/tools/icons.py | 81 ++++++ ShipRoutes/tools/wdc5.py | 96 +++++++ tests/test_sr.lua | 260 ++++++++++++++++++ 15 files changed, 1426 insertions(+), 2 deletions(-) create mode 100644 ShipRoutes/Data.lua create mode 100644 ShipRoutes/Icons/anchor.tga create mode 100644 ShipRoutes/Icons/arrow.tga create mode 100644 ShipRoutes/Icons/disc.tga create mode 100644 ShipRoutes/Icons/ring.tga create mode 100644 ShipRoutes/Icons/zeppelin.tga create mode 100644 ShipRoutes/ShipRoutes.lua create mode 100644 ShipRoutes/ShipRoutes.toc create mode 100644 ShipRoutes/ShipRoutes.xml create mode 100644 ShipRoutes/tools/casc.py create mode 100644 ShipRoutes/tools/generate.py create mode 100644 ShipRoutes/tools/icons.py create mode 100644 ShipRoutes/tools/wdc5.py create mode 100644 tests/test_sr.lua diff --git a/README.md b/README.md index 2425921..3cf73e4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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 | | --- | --- | --- | @@ -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` | | 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 ` | +| 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 -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. ## 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. - Its minimap markers skip quests started by an item, and quests with profession or reputation requirements. - Quest Shopping List's prices are Auctionator's last-seen prices, so run "Search all" for current ones. Rewards count gold plus item value, not XP. +- Ship Routes' dock names and the list of which paths are transports are curated by hand in `ShipRoutes/tools/generate.py`, because the client doesn't record which ship sails which path. The Zephras Isle airships have no known faction, so they show in neutral gold. ## 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_minimap.lua DungeonPreQuest/Minimap.lua lua tests/test_qsl.lua QuestShoppingList/QuestShoppingList.lua +lua tests/test_sr.lua ShipRoutes ``` ## 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 ``` +## 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 "" 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 Dungeon Pre-Quest's data is derived from [QuestieDB](https://github.com/Questie/QuestieDB) and diff --git a/ShipRoutes/Data.lua b/ShipRoutes/Data.lua new file mode 100644 index 0000000..746fbc6 --- /dev/null +++ b/ShipRoutes/Data.lua @@ -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 }, + }, + }, +} diff --git a/ShipRoutes/Icons/anchor.tga b/ShipRoutes/Icons/anchor.tga new file mode 100644 index 0000000000000000000000000000000000000000..f490b4cf0e1a3124a8c0b6e924af87c3faa234f3 GIT binary patch literal 16402 zcmeHL+l|{W5EN3umB7!G!4gt}N=PRufhAlCEFmSR1ef5O0ki?LSW%=NK8fZ63zGYs zA=ftGVfZnK_`whE=kxg-y7oKhGtg(C&p@An7tVk~FFz~y@A5lD&Jn65!a!fk_b_VG z#+flK-hnr`E}0nH+8snimgirya-T}Xp(XwBqRG6b< z?s_JdRNjrhOUYv&p?pi)soY0sDq^Rv1&t{=?5E_M?rDzD7C5IIJc$(wW7FJL_G1Bm z#=nC{>j77+y4H2{_phpmjCXyU_SEmzX!(_?9BOqPP1}f zTjwbLdvVm_miRy5EW*9mOII(+$x2&kzQpatA$4k2&YKq6YHE000B722Y8-*1rk}+A zHL%kr{*u)jHE1izm6#)NNUhTKw}D$s^p)1}l9a5pmF6FXqqHC69Q2Xk)m!=)Q&Q9G zWSnU$$#sZ33P(vliTN}zYZGH6KDT+2pRy+G`+B3>=Dt>p!sgmdY4?pp0Feuw@K15SGQww`LXfE$;->5;& z=YVzTv*3*!+AOTB5sY}6*xSl^wJi{gArovKs`1dKWhrjbf%7?F)pft~Ogu{x;Yj&$ zuSNT#4oJ=c`|sqs)SI|+GQk;U#qys7oTw8tCjri-{#US%z-N6Y<~Wu3Sd+D{z;O+O z1J2J9QiU`fj$F$2L8>!7n)WM2><{9 literal 0 HcmV?d00001 diff --git a/ShipRoutes/Icons/arrow.tga b/ShipRoutes/Icons/arrow.tga new file mode 100644 index 0000000000000000000000000000000000000000..dfa01b28ef5e92c060a37a59e727be22329eb6bf GIT binary patch literal 16402 zcmeI0!3~2j3`L_(&=ENH*bx|k5g3I{7@;FD0wXX&N1)$_NXQBlp#)6wBSpn-n)ur< z3954s=UeS+SH0$WcI?an86X2>fDDiUGC&5%02v?yWPl8i0Wv@a$iRsV^jPb8;(FHp z|AO>+M6U|Xf#{d^MQ_lp)hBg4qJ7yq7^&B^H2+e&e;)8q%9-Fb>(2>}H@c--rHDoA z)^?kD4z%8o-NTvdehBFe`EtD@Lt58-XWfxnJ^A36vd%x&oAo9GWPl8i0Wv@a$N(82 O17v^8Vg-jsJ`QqD>n^d%)@7|T7}8#>HEny<=9`ED== zb1`S@UPNhR{b~hsQ=>H>(3F&WMN**_d>Evo=6bLBNo_QQ59CEPXXU2@4QScZgYnbQ zh5Bf!?E&Y}RH)rb7usr_nXR+uHK^f1FYL8EXnD_PW_v~R|9BpZcH)lOXn)6pOGm6r zQepUw2ZQdLmnQ9~9|l-n_2AwSU)P=kLmue(3S(Hvt7Gnr2ICU{lm|J!!dT+x9p@+ktMwor1zw!6TK?OC_+hpD zp3gnIw54+}*+Gumu-f&X9rIc=SS`OD;HZIkN*5ic7r%>!)o_G ze-j)fV72_Wqri(3R?8m`#1E_GKl=MGeoP1012EdP&u#uU3eRy6;_^y+uLcu<2qd)2xJHQBQV zTt{VVF-p+0#@e4Rsy8=a0vga#o3}Lopt|=DdO&S7l(g;H7o{O7_ll%K)ZCMCOD#0j z+z-s%BDeKskj|@eQob9^!CcH~>-5m(%#6yLlJ!fy4v85QNc1a3S#X!kAD9VM8F33Be&u2oA*|?A9kOCsZ0>FbsxWm(;@D(~qh) zhP!Q=Kh1#9gr@!X`T5zr?Y)DF_rPEE4zgZ$lO@?h<{*}2s73UAxUA7hU zpcg&QzKbA^e1Ek-Z)Tir4{%DdqmVS{40~wBW6k&dP(IwFtT!W;WaN~B*>GrHV4Y?z zapgS9$X&yeTxz1MWCpp-fd;QRBpvR_iC*-aL)2mI9q>N7&yYwu3$j`~=*^5Nz^&Fh zb51+=XeXUU9N2Xoq!xYXLY>mK{eWOfdF?|^xKyvc3>uX zoE>OenxFgKm((rwJ^CEZj-}^7>jm}c+L&4arGjZ^(UJXwA>lRwqxEOEFy&^X2K zZpl1Hr*f|nN5dFs%yH+v;fM<4a<3Fag9ELuA$XGfE|ceVXZO+I2nsmw-jn3FnLMvM zyN?D(uYmKuS<+AV?GGCL8GzQ|Y`7-Vk3XDU{aT{UcNBk+ezc5{ySK;ZeC}me|K11w zXmJc@!`08J8P2YLMT^5V`8hS7b5$QL4%g!6)OgNSeY7}S%Wr@FC0h`_@93(2i8lUC zFh=ejaaH|(Z==<<^kebgpW95H*PY!*gQHi#c?VCD-(~W=?(9Aq96WPnMr%@~8ToB@TB78t3@kyg+_fsF~~c zsxvq{(6+=USC7)~tckn)^ZNt3dBF>h_(s;`t%FuTqy!rU$*~>2t2&^Ue&iUdH#A XWDl8xSdx)LE;ZCPZ+q{c);;hAa6#d1 literal 0 HcmV?d00001 diff --git a/ShipRoutes/Icons/zeppelin.tga b/ShipRoutes/Icons/zeppelin.tga new file mode 100644 index 0000000000000000000000000000000000000000..c3283de76fa76bf54b20783dfd8558d8b33875f7 GIT binary patch literal 16402 zcmeHK+iinD5Jahf68Ov~B~U_2pahqY4qO7IP=ZUK1WF(?l2<}24&QCStmIv3b+3KQ z+)apFRbQ1@S9MkMy(~)=9(NEL2n~b=LIa_J&_HM)G!PmH4TJ`k9(OQ5opbANr5d>% z{1-mJNB9GtGMOMCKh7SIIU}`D`UN??Tx!&Jn{~tri|1W?|?qRz1jp|>$f`U{mFNP-#Bq@#AxL$ zd79#+Hyp32RpDVBHN79b;e2i7EqR*Wr}Llmg*aZHp?}gH;h*~b`}F^RHQrvn4K3y~ z+?x>-u?f!qjGCLSIG=HueIR7rLHew)_EsWMZ&1tXB4Z*zscN=@M_Z~LO zS+hapRh=3+J$%~8J$j2h*o!@1;j)}JsJnho&P(dFh`+-h@S}{iSd+C&uvlYz^qHT| zxwQ`8sDlr1u}LNym&*6LpUW#Z&MVIpu3TQZaj8CD z_j7sW#(CwL!j;P_H!ju3 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 diff --git a/ShipRoutes/ShipRoutes.toc b/ShipRoutes/ShipRoutes.toc new file mode 100644 index 0000000..065f425 --- /dev/null +++ b/ShipRoutes/ShipRoutes.toc @@ -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 diff --git a/ShipRoutes/ShipRoutes.xml b/ShipRoutes/ShipRoutes.xml new file mode 100644 index 0000000..9e6a8a8 --- /dev/null +++ b/ShipRoutes/ShipRoutes.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShipRoutes/tools/casc.py b/ShipRoutes/tools/casc.py new file mode 100644 index 0000000..af44b0a --- /dev/null +++ b/ShipRoutes/tools/casc.py @@ -0,0 +1,139 @@ +"""Minimal local CASC reader: extract files by FileDataID. +usage: python3 casc.py [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("> 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("= 2: + n, locale, u1, u2 = struct.unpack_from(" + +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() diff --git a/ShipRoutes/tools/icons.py b/ShipRoutes/tools/icons.py new file mode 100644 index 0000000..0c60545 --- /dev/null +++ b/ShipRoutes/tools/icons.py @@ -0,0 +1,81 @@ +"""Draws the map marker textures as 64x64 white-on-transparent TGAs (tinted in game). +usage: python3 icons.py """ +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("> 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("= 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")