From 33c8c3e37cedafdb03ffbd74779a3fdd9a727ef7 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 23 Jul 2026 05:59:50 -0500 Subject: [PATCH] Add C_TaxiMap.GetTaxiRoute(slotIndex) Exposes the client's computed flight route to a taxi-map slot as an array of TaxiNodes.dbc IDs in flight order { currentNodeID, ..., destNodeID } -- the exact chain TakeTaxiNode sends the server. Mirrors the TakeTaxiNode worker (FUN_004dc8d0): a single direct hop when a TaxiPath edge exists (via the FUN_004dbad0 adjacency matrix), otherwise the client's precomputed multi-hop route array (slot +0x14, length +0x18). This lets addons identify every hop of a per-character route without matching flight-map coordinates back to nodes. Offsets added: per-slot route array/count/flag, the current-node record pointer, and the node adjacency matrix. Documented in docs/API.md + README. --- README.md | 2 +- docs/API.md | 25 ++++++++++++++++ src/Offsets.h | 23 +++++++++++++++ src/taxi/Map.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 36d17394..da7ac03d 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Full per-function reference: **[docs/API.md](docs/API.md)**. | [State](docs/API.md#state) | `CancelShapeshiftForm`, `Dismount`, `GetMirrorTimerInfo`, `GetMirrorTimerProgress`, `GetShapeshiftFormID`, `IsAssistingRitual`, `IsFalling`, `IsInGroup`, `IsInRaid`, `IsLoggedIn`, `IsMounted`, `IsStealthed`, `IsSwimming` | | [Talent](docs/API.md#talent) | `GetTalentIDByIndex`, `GetTalentSpellID` | | [Targeting](docs/API.md#targeting) | `GetPlayerFacing`, `TargetDirectionEnemy`, `TargetDirectionFriend`, `TargetNearest`, `TargetNearestEnemyPlayer`, `TargetNearestFriendPlayer` | -| [TaxiMap](docs/API.md#taximap) | `C_TaxiMap.GetTaxiNodesForMap`, `C_TaxiMap.GetAllTaxiNodes`, `C_TaxiMap.GetTaxiPaths`, `C_TaxiMap.GetTaxiPathWaypoints` | +| [TaxiMap](docs/API.md#taximap) | `C_TaxiMap.GetTaxiNodesForMap`, `C_TaxiMap.GetAllTaxiNodes`, `C_TaxiMap.GetTaxiPaths`, `C_TaxiMap.GetTaxiPathWaypoints`, `C_TaxiMap.GetTaxiRoute` | | [Time](docs/API.md#time) | `C_DateAndTime.AdjustTimeByDays`, `C_DateAndTime.AdjustTimeByMinutes`, `C_DateAndTime.CompareCalendarTime`, `C_DateAndTime.GetCalendarTimeFromEpoch`, `C_DateAndTime.GetCurrentCalendarTime`, `C_DateAndTime.GetSecondsUntilDailyReset`, `C_DateAndTime.GetServerTimeLocal`, `C_Timer.After`, `C_Timer.NewTicker`, `C_Timer.NewTimer`, `GetServerTime` | | [Totem](docs/API.md#totem) | `GetTotemInfo`, `GetTotemTimeLeft`, `GetTotemDuration`, `TargetTotem` | | [TradeSkillUI](docs/API.md#tradeskillui) | `C_TradeSkillUI.GetTradeSkillListLink`, `C_TradeSkillUI.GetCraftListLink`, `C_TradeSkillUI.GetTradeSkillListRecipes` | diff --git a/docs/API.md b/docs/API.md index d1046258..93907394 100644 --- a/docs/API.md +++ b/docs/API.md @@ -462,6 +462,7 @@ build instructions. - [`C_TaxiMap.GetAllTaxiNodes([uiMapID])`](#c_taximapgetalltaxinodesuimapid) - [`C_TaxiMap.GetTaxiPaths()`](#c_taximapgettaxipaths) - [`C_TaxiMap.GetTaxiPathWaypoints(pathID)`](#c_taximapgettaxipathwaypointspathid) + - [`C_TaxiMap.GetTaxiRoute(slotIndex)`](#c_taximapgettaxiroutepslotindex) - [Time](#time) - [`GetServerTime()`](#getservertime) @@ -11232,6 +11233,30 @@ speed is 32 yd/s, so `length / 32 ≈ flight seconds` for a single hop. the corner at each intermediate flight master via data not present in any client file, so a client-side estimate of a chained route is an upper bound.) +### `C_TaxiMap.GetTaxiRoute(slotIndex)` + +Returns the node chain the client would actually fly to a taxi-map slot, as an +array of `TaxiNodes.dbc` IDs in flight order (`{ currentNodeID, …, destNodeID }`). +`slotIndex` is the legacy `1..NumTaxiNodes()` index (the same one +`TaxiNodeName`/`TakeTaxiNode` take). **Only meaningful while the taxi map is +open.** + +```lua +local route = C_TaxiMap.GetTaxiRoute(slotIndex) +-- route = { 8, 16, 43, 66 } (Thelsamar -> Refuge Pointe -> Aerie Peak -> Chillwind) +``` + +This is the exact chain `TakeTaxiNode(slotIndex)` would send to the server — +mirrors the client's own routing decision: a single direct hop when a `TaxiPath` +edge exists (`{ current, dest }`), otherwise the client's precomputed multi-hop +route (which, per character, may detour around flight points you haven't +discovered). Returns nothing when the map is closed, the slot is out of range, +it's the current node, or no route exists. + +Pairs with `GetTaxiPaths` (each consecutive `(from, to)` names a `pathID`) and +`GetTaxiPathWaypoints` (that path's geometry) to measure a chained trip without +matching flight-map pixel coordinates back to nodes. + ## Time ### `GetServerTime()` diff --git a/src/Offsets.h b/src/Offsets.h index c0f56340..b38f78a3 100644 --- a/src/Offsets.h +++ b/src/Offsets.h @@ -2438,6 +2438,29 @@ enum Offsets { // "DISTANT" / other) — the node's reachability for the open session. FUN_TAXI_NODE_TYPE = 0x004DC4E0, + // Per-slot computed route (the chain that TakeTaxiNode sends to the + // server). Derived from FUN_004dc8d0 (the TakeTaxiNode worker) and the + // route builder FUN_004dbce0: + // +0x0C (byte) nonzero when the multi-hop route array below is built + // +0x14 (int*) array of TaxiNodes.dbc IDs, current->dest in flight + // order, length at +0x18 + // +0x18 (int) route length (node count; hops = count - 1) + // A direct hop (a TaxiPath edge exists current->dest) is flown as just + // {current, dest} and does NOT populate +0x14 — see VAR_TAXI_ADJACENCY. + OFF_TAXI_SLOT_MULTIHOP = 0x0C, + OFF_TAXI_SLOT_ROUTE = 0x14, + OFF_TAXI_SLOT_ROUTE_COUNT = 0x18, + + // Pointer to the CURRENT flight master's TaxiNodes.dbc record (id @ +0); + // the origin of every route. Used by FUN_004dc8d0 / FUN_004dbce0. + VAR_TAXI_CURRENT_REC = 0x00BB4A80, + + // Node x node -> pathID adjacency matrix (256-wide rows, int cells; cell + // [from*0x100 + to] is the direct TaxiPath id, or 0 if none). Backs the + // direct-hop test FUN_004dbad0. IDs are 1..256. + VAR_TAXI_ADJACENCY = 0x00B7365C, + TAXI_ADJACENCY_DIM = 0x100, + // TaxiPath.dbc (4 fields, 0x10 bytes): {id, fromNode@+0x04, toNode@+0x08, // cost}. A real flight master is a node some flight path connects to; // Northshire Abbey / spurious duplicate rows / standalone markers are not diff --git a/src/taxi/Map.cpp b/src/taxi/Map.cpp index 08fec696..c8ac9451 100644 --- a/src/taxi/Map.cpp +++ b/src/taxi/Map.cpp @@ -366,6 +366,80 @@ int __fastcall Script_GetAllTaxiNodes(void *L) { return 1; } +// Direct-edge test — mirrors FUN_004dbad0: a 256x256 [from][to] matrix of +// TaxiPath IDs (0 = no direct flight path). IDs outside 1..256 are never direct. +bool DirectEdge(int from, int to) { + if (from <= 0 || from > Offsets::TAXI_ADJACENCY_DIM || + to <= 0 || to > Offsets::TAXI_ADJACENCY_DIM) + return false; + const int *adj = reinterpret_cast(Offsets::VAR_TAXI_ADJACENCY); + return adj[from * Offsets::TAXI_ADJACENCY_DIM + to] != 0; +} + +// `C_TaxiMap.GetTaxiRoute(slotIndex)` — the TaxiNodes.dbc ID chain the client +// would fly to the taxi-map slot `slotIndex` (1..NumTaxiNodes), in flight +// order { currentNodeID, ..., destNodeID }. This mirrors TakeTaxiNode's own +// decision (FUN_004dc8d0): a direct hop when a TaxiPath edge exists, otherwise +// the client's precomputed multi-hop route array. It is the exact node list +// TakeTaxiNode would hand the server, so an addon can identify every hop +// without matching flight-map coordinates back to nodes. Returns nothing when +// no taxi map is open, the slot is out of range, it is the current node, or no +// route exists. +int __fastcall Script_GetTaxiRoute(void *L) { + if (!Game::Lua::IsNumber(L, 1)) + return 0; + const int slot1 = static_cast(Game::Lua::ToNumber(L, 1)); + const int count = + *reinterpret_cast(Offsets::VAR_TAXI_NODE_COUNT); + if (count <= 0 || slot1 < 1 || slot1 > count) + return 0; + + const auto *arrayBase = + reinterpret_cast(Offsets::VAR_TAXI_NODE_ARRAY); + const uint8_t *slotRec = + arrayBase + (slot1 - 1) * Offsets::TAXI_NODE_STRIDE; + + const uint8_t *curRec = *reinterpret_cast( + Offsets::VAR_TAXI_CURRENT_REC); + const uint8_t *dstRec = *reinterpret_cast( + slotRec + Offsets::OFF_TAXI_SLOT_RECORD); + if (curRec == nullptr || dstRec == nullptr) + return 0; + const int currentID = IntField(curRec, 0); + const int destID = IntField(dstRec, 0); + if (currentID == 0 || destID == 0 || currentID == destID) + return 0; + + // Collect the chain exactly as FUN_004dc8d0 (TakeTaxiNode) would send it. + int ids[64]; + int n = 0; + if (DirectEdge(currentID, destID)) { + ids[n++] = currentID; + ids[n++] = destID; + } else if (*(slotRec + Offsets::OFF_TAXI_SLOT_MULTIHOP) != 0) { + const int *route = *reinterpret_cast( + slotRec + Offsets::OFF_TAXI_SLOT_ROUTE); + const int rc = *reinterpret_cast( + slotRec + Offsets::OFF_TAXI_SLOT_ROUTE_COUNT); + if (route == nullptr || rc < 2) + return 0; + const int cap = rc < 64 ? rc : 64; + for (int i = 0; i < cap; ++i) + ids[n++] = route[i]; + } else { + return 0; // reachable node with no computed route (shouldn't happen) + } + + Game::Lua::SetTop(L, 0); + Game::Lua::NewTable(L); + for (int i = 0; i < n; ++i) { + Game::Lua::PushNumber(L, static_cast(i + 1)); + Game::Lua::PushNumber(L, static_cast(ids[i])); + Game::Lua::SetTable(L, -3); + } + return 1; +} + void RegisterLuaFunctions() { static const Game::Lua::EnumIntegerEntry kFaction[] = { {"Neutral", FACTION_NEUTRAL}, @@ -385,6 +459,8 @@ void RegisterLuaFunctions() { &Script_GetTaxiNodesForMap); Game::Lua::RegisterTableFunction("C_TaxiMap", "GetAllTaxiNodes", &Script_GetAllTaxiNodes); + Game::Lua::RegisterTableFunction("C_TaxiMap", "GetTaxiRoute", + &Script_GetTaxiRoute); } const Game::ModuleAutoRegister _autoreg{&RegisterLuaFunctions};