Part of #41: the comments of `benilla-formats` (the library, its extract tools, examples and tests) are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 19,654 comment lines become 7,264. Fixes #105: the WMO collision comments now name walking's box-query leaf `0x6bca50` and the camera and line-of-sight segment-query leaf `0x6bc700`, in `models/collision.rs`, `examples/wmo_bsp.rs` and `tests/chain.rs`. - **The mechanical strip.** The citations that were only a private record number go first, and each edit is shown to be a pure removal. - **Wrong facts corrected.** The rewrite corrects the comments that stated wrong facts. Among them: - A placed doodad's material alpha reads file slot 0 on its spawn clock, while the reference reads bone 0's armed sequence, re-rolled every play window. The old text said doodads are armed once at load. - The fog end is stored ×36 and scaled once at load (`0x6d6090`). It is not raw. - The MCSH bit picks a map doodad's sun scale, 1.0 lit or 0.5 shadowed. 2.5 belongs to an entity's light node. - `SpellRec` is the row as stored, column × 4, not a translated copy. - A global sequence's clock is anchored at the instance's attach time (`0x714352`). - Particle twinkle is a gated size multiplier (`0x7b2adc`). - The blob shadow sizes from the Stand box. - Data claims are checked against the install: the weapon-trail kits' parameters and alphas, the beam rows' noise, and the maps' `field_16`. - Dozens more turned up on the way: renamed or deleted items, docs sitting on the wrong item, stale counts and links. - **Deviation labels.** "Deviation:" now marks only a choice with a reason. An unbuilt behaviour says so plainly. - **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Four second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the reference, the code and the shipped data. String literals are untouched; they are #92. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
102 lines
3.2 KiB
Rust
102 lines
3.2 KiB
Rust
//! `TaxiPath.dbc`: the direct hops between flight-master nodes and their fares, laid out as vmangos
|
|
//! `TaxiPathEntry` (`DBCStructure.h:688-694`); a multi-hop trip chains several. The waypoints are
|
|
//! `TaxiPathNode.dbc`'s.
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use anyhow::{Context, Result};
|
|
use benilla_dbc::{FieldType, Schema, SchemaField};
|
|
|
|
use crate::dbc::{parse, u32_at};
|
|
use crate::Chain;
|
|
|
|
const TAXI_PATH: &str = "DBFilesClient\\TaxiPath.dbc";
|
|
|
|
/// One direct hop between two flight-master nodes.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct TaxiPath {
|
|
pub id: u32,
|
|
pub from: u32,
|
|
pub to: u32,
|
|
/// The undiscounted fare in copper; vmangos applies the reputation discount when it charges.
|
|
pub cost: u32,
|
|
}
|
|
|
|
/// `TaxiPath.dbc` rows by id, plus a `(from, to)` lookup.
|
|
pub struct TaxiPaths {
|
|
rows: HashMap<u32, TaxiPath>,
|
|
by_pair: HashMap<(u32, u32), u32>,
|
|
}
|
|
|
|
impl TaxiPaths {
|
|
pub fn get(&self, id: u32) -> Option<&TaxiPath> {
|
|
self.rows.get(&id)
|
|
}
|
|
|
|
/// The direct hop from `from` to `to`; the table is directed, one row per direction.
|
|
pub fn between(&self, from: u32, to: u32) -> Option<&TaxiPath> {
|
|
self.by_pair
|
|
.get(&(from, to))
|
|
.and_then(|id| self.rows.get(id))
|
|
}
|
|
|
|
/// Every direct hop leaving `node`, in no order.
|
|
pub fn paths_from(&self, node: u32) -> impl Iterator<Item = &TaxiPath> {
|
|
self.rows.values().filter(move |p| p.from == node)
|
|
}
|
|
|
|
pub fn len(&self) -> usize {
|
|
self.rows.len()
|
|
}
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
self.rows.is_empty()
|
|
}
|
|
}
|
|
|
|
fn schema() -> Schema {
|
|
let mut s = Schema::new("TaxiPath");
|
|
for name in ["ID", "FromTaxiNode", "ToTaxiNode", "Cost"] {
|
|
s.add_field(SchemaField::new(name, FieldType::UInt32));
|
|
}
|
|
s
|
|
}
|
|
|
|
/// Read `TaxiPath.dbc` off the patch chain into a [`TaxiPaths`] catalog.
|
|
pub fn load_taxi_paths(chain: &mut Chain) -> Result<TaxiPaths> {
|
|
let bytes = chain.read_file(TAXI_PATH).context("reading TaxiPath.dbc")?;
|
|
let rs = parse(&bytes, schema(), "TaxiPath")?;
|
|
let mut rows = HashMap::with_capacity(rs.records().len());
|
|
let mut by_pair = HashMap::with_capacity(rs.records().len());
|
|
for r in rs.records() {
|
|
let Some(id) = u32_at(r, 0) else { continue };
|
|
let Some(from) = u32_at(r, 1) else { continue };
|
|
let Some(to) = u32_at(r, 2) else { continue };
|
|
let cost = u32_at(r, 3).unwrap_or(0);
|
|
rows.insert(id, TaxiPath { id, from, to, cost });
|
|
by_pair.insert((from, to), id);
|
|
}
|
|
Ok(TaxiPaths { rows, by_pair })
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
/// Hop 6 runs Stormwind (node 2) to Sentinel Hill (node 4) for 110 copper.
|
|
#[test]
|
|
fn real_taxi_path_layout_sanity() {
|
|
let data = crate::wow_data_or_skip!();
|
|
let mut chain = crate::open_chain(&data).expect("open chain");
|
|
let cat = load_taxi_paths(&mut chain).expect("load TaxiPath");
|
|
assert_eq!(cat.len(), 287, "1.12 ships 287 taxi path hops");
|
|
|
|
let hop = cat.between(2, 4).expect("a direct 2 -> 4 hop exists");
|
|
assert_eq!(hop.id, 6);
|
|
assert_eq!(hop.cost, 110);
|
|
assert!(hop.cost > 0, "a real hop always carries a nonzero fare");
|
|
|
|
assert!(cat.paths_from(2).any(|p| p.to == 4 && p.cost == 110));
|
|
}
|
|
}
|