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>
83 lines
2.6 KiB
Rust
83 lines
2.6 KiB
Rust
//! `SpellFocusObject.dbc`: the object a spell must be cast near (Anvil, Forge, …), named by the
|
|
//! crafting book's "Requires:" line from `Spell.dbc` `RequiresSpellFocus`. The server does the
|
|
//! proximity check (`Spell::CheckCast`); the client only names it.
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use anyhow::{Context, Result};
|
|
use benilla_dbc::{FieldType, Schema, SchemaField};
|
|
|
|
use crate::dbc::{parse, str_at, u32_at};
|
|
use crate::Chain;
|
|
|
|
const SPELL_FOCUS_OBJECT: &str = "DBFilesClient\\SpellFocusObject.dbc";
|
|
const SPELL_FOCUS_FIELDS: usize = 10;
|
|
const COL_NAME_ENUS: usize = 1;
|
|
|
|
/// `SpellFocusObject` id → its enUS name.
|
|
pub struct SpellFocusCatalog {
|
|
names: HashMap<u32, String>,
|
|
}
|
|
|
|
impl SpellFocusCatalog {
|
|
/// The name for a `RequiresSpellFocus` id; `None` for 0, which draws no requirement line.
|
|
pub fn name(&self, focus_id: u32) -> Option<&str> {
|
|
self.names.get(&focus_id).map(String::as_str)
|
|
}
|
|
|
|
pub fn len(&self) -> usize {
|
|
self.names.len()
|
|
}
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
self.names.is_empty()
|
|
}
|
|
}
|
|
|
|
fn schema() -> Schema {
|
|
let mut s = Schema::new("SpellFocusObject");
|
|
for i in 0..SPELL_FOCUS_FIELDS {
|
|
let ty = if i == COL_NAME_ENUS {
|
|
FieldType::String
|
|
} else {
|
|
FieldType::UInt32
|
|
};
|
|
s.add_field(SchemaField::new(format!("F{i}"), ty));
|
|
}
|
|
s
|
|
}
|
|
|
|
/// Load SpellFocusObject.dbc from the patch chain into a [`SpellFocusCatalog`].
|
|
pub fn load_spell_focus_catalog(chain: &mut Chain) -> Result<SpellFocusCatalog> {
|
|
let bytes = chain
|
|
.read_file(SPELL_FOCUS_OBJECT)
|
|
.with_context(|| format!("reading {SPELL_FOCUS_OBJECT}"))?;
|
|
let rs = parse(&bytes, schema(), "SpellFocusObject.dbc")?;
|
|
let mut names = HashMap::new();
|
|
for r in rs.records() {
|
|
let Some(id) = u32_at(r, 0) else { continue };
|
|
if let Some(name) = str_at(&rs, r, COL_NAME_ENUS) {
|
|
names.insert(id, name);
|
|
}
|
|
}
|
|
Ok(SpellFocusCatalog { names })
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn real_spell_focus_names_the_profession_objects() {
|
|
let data = crate::wow_data_or_skip!();
|
|
let mut chain = crate::open_chain(&data).expect("open chain");
|
|
let cat = load_spell_focus_catalog(&mut chain).expect("load SpellFocusObject.dbc");
|
|
|
|
assert_eq!(cat.name(1), Some("Anvil"));
|
|
assert_eq!(cat.name(3), Some("Forge"));
|
|
assert_eq!(cat.name(4), Some("Cooking Fire"));
|
|
assert_eq!(cat.name(0), None, "0 = no requirement");
|
|
assert_eq!(cat.len(), 138, "the 5875 file's full row count");
|
|
}
|
|
}
|