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>
77 lines
2.8 KiB
Rust
77 lines
2.8 KiB
Rust
//! A WMO's last chunk clamps to EOF: the reference's walk (`0x6c3a60`) reads chunks while the
|
|
//! 8-byte header is in bounds and never requires exact tiling. The one shipped file that needs it
|
|
//! is `Undercity_144.wmo`, whose MOGP declares one byte past the end.
|
|
|
|
use benilla_formats::{parse_wmo_root, wmo_group_header, Chain};
|
|
|
|
/// g144 is the corridor joining g95 and g152, and its portal-ref span (MOGP `+0x24`, `+0x26`) is
|
|
/// the portal flood's only way through.
|
|
#[test]
|
|
fn undercity_144_mogp_survives_its_one_byte_overrun() {
|
|
let data = benilla_formats::wow_data_or_skip!();
|
|
let reader = Chain::open(&data).expect("open vanilla patch chain");
|
|
let bytes = reader
|
|
.read("World\\wmo\\Lorderon\\Undercity\\Undercity_144.wmo")
|
|
.expect("read Undercity_144");
|
|
|
|
let declared =
|
|
u32::from_le_bytes([bytes[0x10], bytes[0x11], bytes[0x12], bytes[0x13]]) as usize;
|
|
assert_eq!(
|
|
0x0c + 8 + declared,
|
|
bytes.len() + 1,
|
|
"Undercity_144's MOGP is supposed to declare exactly one byte past EOF"
|
|
);
|
|
|
|
let h = wmo_group_header(&bytes).expect("MOGP must survive the clamp");
|
|
assert_eq!(h.flags, 0xa805, "MOGP+0x08 flags");
|
|
assert_eq!(h.portal_ref_start, 397, "MOGP+0x24 portal-ref start");
|
|
assert_eq!(h.portal_ref_count, 2, "MOGP+0x26 portal-ref count");
|
|
}
|
|
|
|
/// Every WMO in the corpus yields the chunk its loader needs: a root parses, a group gives up its
|
|
/// MOGP header.
|
|
#[test]
|
|
fn every_wmo_in_the_corpus_yields_its_loader_chunk() {
|
|
let data = benilla_formats::wow_data_or_skip!();
|
|
let mut reader = Chain::open(&data).expect("open vanilla patch chain");
|
|
let mut paths: Vec<String> = reader
|
|
.list()
|
|
.expect("list the patch chain")
|
|
.into_iter()
|
|
.map(|e| e.name)
|
|
.filter(|n| n.to_ascii_lowercase().ends_with(".wmo"))
|
|
.collect();
|
|
paths.sort();
|
|
paths.dedup();
|
|
assert!(
|
|
paths.len() > 5000,
|
|
"expected the full WMO corpus, found {} files",
|
|
paths.len()
|
|
);
|
|
|
|
let mut checked = 0u32;
|
|
let mut bad: Vec<String> = Vec::new();
|
|
for p in &paths {
|
|
let Ok(b) = reader.read_file(p) else { continue };
|
|
if b.is_empty() {
|
|
continue; // 0-byte stubs ship in the corpus; the reference accepts them too
|
|
}
|
|
checked += 1;
|
|
// A group file is MVER + MOGP, so its 4CC sits at 0x0c; anything else is a root.
|
|
let ok = if b.len() > 16 && &b[12..16] == b"PGOM" {
|
|
wmo_group_header(&b).is_some()
|
|
} else {
|
|
parse_wmo_root(&b).is_ok()
|
|
};
|
|
if !ok {
|
|
bad.push(p.clone());
|
|
}
|
|
}
|
|
assert!(
|
|
bad.is_empty(),
|
|
"{} of {checked} WMO files lost the chunk their loader needs: {:?}",
|
|
bad.len(),
|
|
&bad[..bad.len().min(10)]
|
|
);
|
|
}
|