Files
benilla-octo/crates/benilla-formats/tests/light_no_row_fallback.rs
T
Sam SungandClaude Opus 5.5 8505187668 Comments in benilla-formats: one line of fact each, no history, no record numbers (#130)
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>
2026-09-24 19:38:53 +07:00

103 lines
3.5 KiB
Rust

//! A map with no `Light.dbc` row falls back to the record whose id is 1. For Deeprun Tram (369)
//! the per-map filter of `0x6d6170` matches nothing (`0x6d61a9`), the tail writes `idMap[1]` into
//! slot 0 (`0x6d62b2`-`0x6d62c9`), `0x6d2d00` has nothing to blend, and that record, the Azeroth
//! global with `LightParams` 12 (int bands 199..216, float bands 67..72), commits whole.
use benilla_formats::{Chain, LightCatalog, Submersion};
const MAP_DEEPRUN_TRAM: u32 = 369;
/// Half-minutes; 1440 = noon.
const NOON: u32 = 1440;
#[test]
fn deeprun_tram_takes_light_record_1_not_an_invented_default() {
let data = benilla_formats::wow_data_or_skip!();
let mut chain = Chain::open(&data).expect("open vanilla patch chain");
let cat = LightCatalog::load(&mut chain).expect("load Light/LightParams/*Band");
// The position is irrelevant: no row covers any point of the map.
let tram = cat.sample_blended(
MAP_DEEPRUN_TRAM,
[25.0, -1256.0, -117.0],
NOON,
false,
Submersion::Dry,
false,
);
// LightParams 12 at noon, off the shipped bands.
let rgb = |c: [f32; 3]| c.map(|v| (v * 255.0).round() as i32);
assert_eq!(
rgb(tram.fog_color),
[77, 120, 143],
"fog must be LightParams 12's own band, not the old [140,183,234] invention"
);
assert_eq!(rgb(tram.ambient), [104, 130, 154], "ambient = band sub-1");
assert_eq!(rgb(tram.sun_diffuse), [255, 136, 0], "diffuse = band sub-0");
assert!(
(tram.fog_end - 500.0).abs() < 1.0,
"fog end {} should be 18000 inches / 36 = 500 yd (was 1000)",
tram.fog_end
);
assert!(
(tram.fog_start_frac - 0.25).abs() < 1e-3,
"start fraction {} should be 0.25 (was 0.40)",
tram.fog_start_frac
);
// Every map with no row lands on the same record, whatever its id or position.
let other_rowless = cat.sample_blended(
4242,
[9000.0, -1000.0, 60.0],
NOON,
false,
Submersion::Dry,
false,
);
assert_eq!(
rgb(other_rowless.fog_color),
rgb(tram.fog_color),
"any map with no Light.dbc row takes the same record 1"
);
let midnight = cat.sample_blended(
MAP_DEEPRUN_TRAM,
[25.0, -1256.0, -117.0],
0,
false,
Submersion::Dry,
false,
);
assert_ne!(
rgb(midnight.fog_color),
rgb(tram.fog_color),
"the fallback runs the ordinary day/night pipeline, so the hours must differ"
);
}
/// Seven maps have positioned rows but no `(0,0,0)` global: the reference fills slots 1.. and
/// leaves slot 0 unwritten, an effect not traced, so they stay out of the record-1 fallback.
#[test]
fn maps_with_positioned_rows_but_no_global_are_left_alone() {
let data = benilla_formats::wow_data_or_skip!();
let mut chain = Chain::open(&data).expect("open vanilla patch chain");
let cat = LightCatalog::load(&mut chain).expect("load Light/LightParams/*Band");
// Map 169 (Emerald Dream): 4 rows, none a global, sampled far from all of them.
let far = cat.sample_blended(169, [0.0, 0.0, 0.0], NOON, false, Submersion::Dry, false);
let tram = cat.sample_blended(
MAP_DEEPRUN_TRAM,
[25.0, -1256.0, -117.0],
NOON,
false,
Submersion::Dry,
false,
);
let rgb = |c: [f32; 3]| c.map(|v| (v * 255.0).round() as i32);
assert_ne!(
rgb(far.fog_color),
rgb(tram.fog_color),
"a map WITH rows must not inherit the zero-match fallback"
);
}