Comments in benilla-ui: one line of fact each, no history, no record numbers (#143)

Part of #41: the comments of `benilla-ui` (the Lua UI engine, its FrameXML loader and its widgets) are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 43,140 comment lines become 15,161.

- **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:
  - `0x64a480` is the case-sensitive compare (a byte `repz cmpsb`), and `0x64a4c0` the case-insensitive one.
  - A frame's id sits at `+0xb0`, not `+0xb4`. `EnableKeyboard`/`IsKeyboardEnabled` are `0x776ec0`/`0x776f90`.
  - A region's unpinned edge has no fallback to its owner's rect: the owner supplies only the scale.
  - `$parent` expands to the nearest named ancestor, or "Top" when none is named (`0x76c5b0`), not simply to the parent.
  - A StatusBar fills from its internal normalised fraction, not from `GetValue()`.
  - The addresses of `StartDuel` and `StartDuelUnit` were swapped.
  - Many "untraced" notes now give the traced reference fact: the drag threshold, the per-grip sizing edges, the empty-`autoFocus` skip, and `SetTexCoordModifiesRect`'s default.
  - Stock FrameXML line citations are checked against the stock 1.12 files and corrected. `ref-` file names become the stock file names.
- **Deviation labels.** "Deviation:" now marks only a choice with a reason. A surface that exists only for the retired Era addon target says so plainly: it is not 1.12.
- **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Nine second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the code, the stock files, vmangos and the reference.

Behaviour differences the rewrite surfaced are filed as their own issues (#131–#142), and more are being validated. The comments here state what the code does. 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>
This commit is contained in:
Sam Sung
2026-09-25 01:58:49 +07:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 8505187668
commit fd386e75ae
233 changed files with 14108 additions and 42094 deletions
+11 -23
View File
@@ -1,33 +1,23 @@
//! The tutorial system's four Lua verbs (decision 1976): the registrar table at `.data 0x846b04` —
//! `TutorialsEnabled`, `FlagTutorial`, `ClearTutorials`, `ResetTutorials`.
//!
//! The banks are the app's (they are wire state, and the fire-once trigger law lives beside the
//! sites that trigger): the app pushes the **acknowledged** bank's bytes here when they change,
//! which is all `TutorialsEnabled` reads, and drains the three writes.
//!
//! | verb | shape |
//! |---|---|
//! | `TutorialsEnabled()` | one value on both legs: the number `1` if ANY byte of the acknowledged bank is not `0xFF`, else `nil` — over the whole bank, not the 50 real ids; `nil` with no bank |
//! | `FlagTutorial(n)` | `n` must pass `lua_isnumber` else `Usage: FlagTutorial("tutorial")` (the quoted usage is the reference's own, and misleading — a number is required); truncated, `n − 1` must lie in `0..50` else a SILENT no-op; zero values |
//! | `ClearTutorials()` | zero values; every bit set in both banks and `CMSG_TUTORIAL_CLEAR` |
//! | `ResetTutorials()` | zero values; every bit cleared in both banks and `CMSG_TUTORIAL_RESET` |
//! The four tutorial verbs, registered at `0x846b04`. The banks are the app's: it pushes the
//! acknowledged bank for `TutorialsEnabled` and drains the writes. `ClearTutorials()` sets every
//! bit of both banks and sends `CMSG_TUTORIAL_CLEAR`; `ResetTutorials()` clears them and sends
//! `CMSG_TUTORIAL_RESET`. None of the three writers returns a value.
use mlua::{Lua, Value};
use super::binding_abi::{flag, number_arg};
use super::Model;
/// `FlagTutorial`'s clamp: `0 ≤ n − 1 < 0x32` — the fifty ids `GlobalStrings.lua` names.
/// `FlagTutorial`'s bound, `0 ≤ n − 1 < 0x32`: the fifty tutorials `GlobalStrings.lua` names.
const TUTORIAL_IDS: i32 = 0x32;
impl super::UiScript {
/// The acknowledged bank's bytes (`None` before `SMSG_TUTORIAL_FLAGS` lands) — what
/// `TutorialsEnabled()` scans.
/// The acknowledged bank's bytes, `None` before `SMSG_TUTORIAL_FLAGS`.
pub fn set_tutorial_bank(&mut self, bank: Option<Vec<u8>>) {
self.model_mut().tutorial_bank = bank;
}
/// `FlagTutorial(n)` calls since the last drain: the **0-based** ids (`n − 1`), in range.
/// `FlagTutorial(n)` calls since the last drain, as 0-based ids (`n − 1`).
pub fn take_tutorial_flag_requests(&mut self) -> Vec<u32> {
std::mem::take(&mut self.model_mut().tutorial_flag_requests)
}
@@ -46,8 +36,8 @@ impl super::UiScript {
pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
let g = lua.globals();
// `TutorialsEnabled()` (`0x4b5960`): scans `[0xb711ec] * 4` bytes of bank B for one ≠ 0xFF;
// `1.0` or nil, one value; an unallocated bank skips the loop and answers nil.
// `TutorialsEnabled()` (`0x4b5960`): 1 if any of the bank's `[0xb711ec] * 4` bytes is not
// 0xFF, the whole bank and not just the fifty ids; else nil, as with no bank.
g.set(
"TutorialsEnabled",
lua.create_function(|lua, ()| {
@@ -60,8 +50,8 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
})?,
)?;
// `FlagTutorial(n)` (`0x4b59b0`): `lua_isnumber` else the Usage raise; `__ftol`; `dec`; `js`
// and `cmp 0x32 / jge` bail silently; else the acknowledge-and-send setter with the 0-based id.
// `FlagTutorial(n)` (`0x4b59b0`): a non-number raises the reference's usage text, which asks
// for a string; truncated, an `n − 1` outside `0..0x32` is a silent no-op.
g.set(
"FlagTutorial",
lua.create_function(|lua, n: Value| {
@@ -101,7 +91,6 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
mod tests {
use crate::script::UiScript;
/// `1` or nil, one value, over the WHOLE bank — and nil with none.
#[test]
fn tutorials_enabled_scans_the_whole_acknowledged_bank() {
let mut s = UiScript::new().unwrap();
@@ -127,7 +116,6 @@ mod tests {
assert_eq!(s.eval::<i64>("return TutorialsEnabled()").unwrap(), 1);
}
/// `FlagTutorial`: the number gate's raise, `n − 1`, the silent out-of-range legs, truncation.
#[test]
fn flag_tutorial_takes_a_one_based_number_and_bails_silently_off_the_fifty() {
let mut s = UiScript::new().unwrap();