grom: "can't see flight master location marks, even tho I have them on."
Nothing was broken — the layer was silently empty. pfQuest-octo has deleted its
shipped pfDB.meta.flight table in favour of this call (db/meta.lua:181 is a stub
whose comment says the data "always comes live from the client (ClassicAPI)"),
and SearchFlightNodes opens with
if not (C_TaxiMap and C_TaxiMap.GetTaxiNodesForMap) then return maps end
so with the namespace absent the option stays ticked, no error is raised, and no
icon is ever drawn. Same silent-by-construction shape as C_Map.GetAreas, same
consumer.
The contract is half read off the bundled ClassicAPI.dll's string pool
(C_TaxiMap, GetTaxiNodesForMap, nodeID, faction, reachable, state and the
FlightPathFaction/FlightPathState enum names) and half off the caller: the
areaID/mapX/mapY triple is not separately visible there, since the pool holds
one copy of each string and C_Map.GetAreaTriggerInfo already uses all three, so
for those SearchFlightNodes itself is the authority. It reads six fields, gates
on `node.areaID and node.mapX and node.mapY`, and feeds the pair into
pfMap:AddNode as meta.x/meta.y, which UpdateNodes divides by 100 — so they are
percentages of the zone rect. Both files say which half is which.
Faction comes from the two MountCreatureID columns, the reference's own gate
(0x4a2650 asks for the mount of the player's half): one column filled is that
faction, both is neutral, and neither means the row is not a flight master at
all — on this install those are exactly the eight Transport/Ferry/zeppelin
endpoints, and passing them on would put "Flight Master" pins on the Menethil
docks.
Attributing a node to a zone needed the file's own names. Geometry over
WorldMapArea boxes proposes — these are axis-aligned boxes around irregular
zones, so a node near a border sits inside two or three of them — but no purely
geometric rule works: "smallest box" misfiled a dozen of ~70 rows (Crossroads
under Mulgore, Aerie Peak under Alterac Mountains), and "most central box",
much better and what zones_at now sorts by, still loses Talonbranch Glade to
Darkshore by about one percent of inset. TaxiNodes.dbc names its rows
"<place>, <zone>" and a city row leads with the city, which is itself a zone, so
trying each comma-separated part against the candidates gets Ironforge over Dun
Morogh *and* Felwood over Darkshore from one rule. zones_at also reaches the
instance-map list, so Alterac Valley's two nodes place on the battleground map
instead of nowhere.
Seeded before the interface loads, after the map catalog it reads the rects
from. That deadline is tighter than file scope: pfQuest replays its saved
tracking selections once on PLAYER_ENTERING_WORLD and then unregisters every
event (database.lua:131-151), so a push one frame later is a push after the only
read.
Verified against the real addon offline, not just by unit test:
SearchFlightNodes now adds 69 nodes through the probe harness. Three tests pin
the rule against the DBC itself — the capitals and the border nodes by hand, and
every named row held to the zone its own name claims, which is the test that
rejected both earlier geometric rules. It also pins the four rows that name no
zone, three of which are this realm's own additions (Northshire Abbey and two
Darkshore canoe routes), so the next custom node shows up as a failing
assertion rather than a pin in the wrong zone.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgstFWtn1RxEJ5kVrpgYwn
257 lines
9.3 KiB
Rust
257 lines
9.3 KiB
Rust
//! The taxi-map bindings the stock `TaxiFrame.lua` runs on, over a node list the app resolves
|
|
//! and pushes (types, positions, fares and routes); `TakeTaxiNode` and `CloseTaxiMap` queue
|
|
//! intents the app drains. Positions are normalized 0..1 from the map's bottom-left, which the Lua
|
|
//! scales by the 316x352 map.
|
|
|
|
use mlua::{Lua, Table};
|
|
|
|
use super::region::region_handle_of;
|
|
use super::Model;
|
|
|
|
/// A visible node's icon state (`TaxiNodeGetType`): green, white or yellow in the reference.
|
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
|
pub enum TaxiNodeType {
|
|
/// The flight master's own node, "You are here".
|
|
Current,
|
|
/// Known and routable from the current node; clickable.
|
|
#[default]
|
|
Reachable,
|
|
/// Known but unroutable. Never produced: the reference's DISTANT branch is dead and an
|
|
/// unroutable node does not render; the variant stays because `TaxiButtonTypes` names it.
|
|
Distant,
|
|
}
|
|
|
|
impl TaxiNodeType {
|
|
/// The type string, a `TaxiButtonTypes` key.
|
|
fn era_str(self) -> &'static str {
|
|
match self {
|
|
TaxiNodeType::Current => "CURRENT",
|
|
TaxiNodeType::Reachable => "REACHABLE",
|
|
TaxiNodeType::Distant => "DISTANT",
|
|
}
|
|
}
|
|
}
|
|
|
|
/// One node on the open taxi map, resolved by the app.
|
|
#[derive(Clone, Debug, Default, PartialEq)]
|
|
pub struct TaxiUiNode {
|
|
/// `TaxiNodeName`, the DBC's localized name.
|
|
pub name: String,
|
|
/// `TaxiNodeGetType`; a node the reference types `"NONE"` is not pushed.
|
|
pub node_type: TaxiNodeType,
|
|
/// `TaxiNodePosition`: normalized `(x, y)` on the map art, from the bottom-left.
|
|
pub pos: (f32, f32),
|
|
/// `TaxiNodeCost`: the fare in copper, 0 for the current node.
|
|
pub cost: u32,
|
|
/// The hover route's hops as `[src_x, src_y, dest_x, dest_y]` in the same space, for
|
|
/// `GetNumRoutes` and `TaxiGetSrcX` to `TaxiGetDestY`; empty for the current node.
|
|
pub routes: Vec<[f32; 4]>,
|
|
}
|
|
|
|
/// The open taxi map: the continent art and the visible nodes.
|
|
#[derive(Clone, Debug, Default, PartialEq)]
|
|
pub struct TaxiUiState {
|
|
/// The map art `SetTaxiMap` assigns (e.g. `Interface\TaxiFrame\TAXIMAP1`).
|
|
pub art: String,
|
|
/// The visible nodes, in the app's order (Lua indexes them 1-based).
|
|
pub nodes: Vec<TaxiUiNode>,
|
|
}
|
|
|
|
/// One `TaxiNodes.dbc` row as ClassicAPI's `C_TaxiMap.GetTaxiNodesForMap` hands it to Lua.
|
|
///
|
|
/// Every row in the file, not the player's known mask and not the open window's list: the callers
|
|
/// draw flight masters on a map, so a node the player has never visited still has to be in the
|
|
/// answer.
|
|
#[derive(Clone, Debug, Default, PartialEq)]
|
|
pub struct TaxiMapNode {
|
|
/// `TaxiNodes.dbc`'s own id, the `nodeID` field, which both consumers key their own tables by.
|
|
pub node_id: u32,
|
|
/// The localized name, "Ironforge, Dun Morogh".
|
|
pub name: String,
|
|
/// `ClassicAPI`'s `Enum.FlightPathFaction`: 0 neutral, 1 Horde, 2 Alliance. Read off the two
|
|
/// `MountCreatureID` columns, which is how the reference decides whom a node serves
|
|
/// (`0x4a2650` reads the player's faction half): both filled is neutral.
|
|
pub faction: u8,
|
|
/// The `AreaTable` zone whose `WorldMapArea` rect contains the node, the `areaID` field;
|
|
/// `None` for a node on no zone map, which the callers skip.
|
|
pub area_id: Option<u32>,
|
|
/// The node's place inside that zone's rect, `(mapX, mapY)` in **percent** from its top-left —
|
|
/// the units pfQuest's `AddNode` stores and divides by 100 again when it places a pin.
|
|
pub map_percent: Option<(f32, f32)>,
|
|
}
|
|
|
|
impl super::UiScript {
|
|
/// Push the static `TaxiNodes.dbc` catalog for `C_TaxiMap`.
|
|
///
|
|
/// No event: no stock frame reads it, and the one consumer replays its saved tracking
|
|
/// selections on `PLAYER_ENTERING_WORLD` and then unregisters every event
|
|
/// (`pfQuest/database.lua:131-151`), so this must be seated *before* the interface loads or
|
|
/// the flight-master layer stays empty for the whole session. Seeded beside the world-map
|
|
/// catalog for that reason.
|
|
pub fn set_taxi_map_catalog(&mut self, nodes: Vec<TaxiMapNode>) {
|
|
self.model_mut().taxi_catalog = nodes;
|
|
}
|
|
|
|
/// Push (or clear, with `None`) the open taxi map's snapshot.
|
|
pub fn set_taxi(&mut self, state: Option<TaxiUiState>) {
|
|
self.model_mut().taxi = state;
|
|
}
|
|
|
|
/// Whether the player is riding a taxi, for `UnitOnTaxi("player")`.
|
|
pub fn set_on_taxi(&mut self, riding: bool) {
|
|
self.model_mut().taxi_riding = riding;
|
|
}
|
|
|
|
/// Drain the 1-based indices `TakeTaxiNode` queued; the app sends the activate for each.
|
|
pub fn take_taxi_node(&mut self) -> Vec<usize> {
|
|
std::mem::take(&mut self.model_mut().taxi_takes)
|
|
}
|
|
|
|
/// Whether `CloseTaxiMap` was called since the last drain; it sends no packet, as the server
|
|
/// holds no window session for the map.
|
|
pub fn take_taxi_close(&mut self) -> bool {
|
|
std::mem::take(&mut self.model_mut().taxi_close)
|
|
}
|
|
}
|
|
|
|
/// A node by 1-based Lua index.
|
|
fn node(model: &Model, i: i64) -> Option<&TaxiUiNode> {
|
|
let nodes = &model.taxi.as_ref()?.nodes;
|
|
usize::try_from(i)
|
|
.ok()?
|
|
.checked_sub(1)
|
|
.and_then(|i| nodes.get(i))
|
|
}
|
|
|
|
pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
|
let g = lua.globals();
|
|
|
|
g.set(
|
|
"NumTaxiNodes",
|
|
lua.create_function(|lua, ()| {
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
Ok(model.taxi.as_ref().map_or(0, |t| t.nodes.len()) as i64)
|
|
})?,
|
|
)?;
|
|
|
|
// "NONE" out of range, a button the reference hides.
|
|
g.set(
|
|
"TaxiNodeGetType",
|
|
lua.create_function(|lua, i: i64| {
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
Ok(node(&model, i).map_or("NONE", |n| n.node_type.era_str()))
|
|
})?,
|
|
)?;
|
|
|
|
g.set(
|
|
"TaxiNodePosition",
|
|
lua.create_function(|lua, i: i64| {
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
let (x, y) = node(&model, i).map_or((0.0, 0.0), |n| n.pos);
|
|
Ok((x, y))
|
|
})?,
|
|
)?;
|
|
|
|
g.set(
|
|
"TaxiNodeName",
|
|
lua.create_function(|lua, i: i64| {
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
Ok(node(&model, i).map_or(String::new(), |n| n.name.clone()))
|
|
})?,
|
|
)?;
|
|
|
|
g.set(
|
|
"TaxiNodeCost",
|
|
lua.create_function(|lua, i: i64| {
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
Ok(node(&model, i).map_or(0, |n| n.cost) as i64)
|
|
})?,
|
|
)?;
|
|
|
|
// The reference computes the hovered node's route here; the app precomputes every route.
|
|
g.set(
|
|
"TaxiNodeSetCurrent",
|
|
lua.create_function(|_, _: i64| Ok(()))?,
|
|
)?;
|
|
|
|
g.set(
|
|
"GetNumRoutes",
|
|
lua.create_function(|lua, i: i64| {
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
Ok(node(&model, i).map_or(0, |n| n.routes.len()) as i64)
|
|
})?,
|
|
)?;
|
|
|
|
// One coordinate of 1-based hop `hop`, for the reference's `DrawRouteLine` loop.
|
|
for (name, pick) in [
|
|
("TaxiGetSrcX", 0usize),
|
|
("TaxiGetSrcY", 1),
|
|
("TaxiGetDestX", 2),
|
|
("TaxiGetDestY", 3),
|
|
] {
|
|
g.set(
|
|
name,
|
|
lua.create_function(move |lua, (i, hop): (i64, i64)| {
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
let coord = node(&model, i)
|
|
.zip(usize::try_from(hop).ok().and_then(|h| h.checked_sub(1)))
|
|
.and_then(|(n, h)| n.routes.get(h))
|
|
.map_or(0.0, |seg| seg[pick]);
|
|
Ok(coord)
|
|
})?,
|
|
)?;
|
|
}
|
|
|
|
g.set(
|
|
"TakeTaxiNode",
|
|
lua.create_function(|lua, i: i64| {
|
|
if let Ok(i) = usize::try_from(i) {
|
|
lua.app_data_mut::<Model>()
|
|
.expect("model")
|
|
.taxi_takes
|
|
.push(i);
|
|
}
|
|
Ok(())
|
|
})?,
|
|
)?;
|
|
|
|
g.set(
|
|
"CloseTaxiMap",
|
|
lua.create_function(|lua, ()| {
|
|
lua.app_data_mut::<Model>().expect("model").taxi_close = true;
|
|
Ok(())
|
|
})?,
|
|
)?;
|
|
|
|
// The open map's continent art (`TAXIMAP<map>`, the app's pick) onto the given texture.
|
|
g.set(
|
|
"SetTaxiMap",
|
|
lua.create_function(|lua, this: Table| {
|
|
let rh = region_handle_of(lua, &this)?;
|
|
let mut model = lua.app_data_mut::<Model>().expect("model");
|
|
let art = model.taxi.as_ref().map(|t| t.art.clone());
|
|
if let Some(art) = art {
|
|
model.region_data.entry(rh).or_default().texture = Some(art);
|
|
}
|
|
Ok(())
|
|
})?,
|
|
)?;
|
|
|
|
// `0x517a40`: the number 1 or nil, never a boolean; an argument neither string nor number
|
|
// raises the reference's usage (`0x517a48`). Only the player is tracked, as the stock UI asks
|
|
// about no other unit.
|
|
g.set(
|
|
"UnitOnTaxi",
|
|
lua.create_function(|lua, unit: mlua::Value| {
|
|
let unit =
|
|
crate::script::binding_abi::string_arg(lua, unit, r#"Usage: UnitOnTaxi("unit")"#)?;
|
|
let model = lua.app_data_ref::<Model>().expect("model");
|
|
Ok(crate::script::binding_abi::flag(
|
|
unit.eq_ignore_ascii_case("player") && model.taxi_riding,
|
|
))
|
|
})?,
|
|
)?;
|
|
|
|
Ok(())
|
|
}
|