Files
benilla-octo/crates/benilla-ui/src/script/gm_ticket.rs
T
Sam SungandClaude Opus 5.5 fd386e75ae 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>
2026-09-25 01:58:49 +07:00

121 lines
4.3 KiB
Rust

//! The seven GM ticket globals `HelpFrame.lua` calls. The five ticket verbs share one ordered
//! queue, because call order is the reference's wire order, and two calls are two sends: the
//! ticket toast re-polls `GetGMTicket()` every 10 minutes. `GetGMTicket()` is a send, answered by
//! the `UPDATE_TICKET` event, so nothing here holds a ticket.
use mlua::{Lua, MultiValue, Value};
use super::Model;
/// One ticket verb the window called, drained in call order.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum GmTicketIntent {
/// `GetGMTicket()`: `CMSG_GMTICKET_GETTICKET`.
Ask,
/// `GetGMStatus()`: `CMSG_GMTICKET_SYSTEMSTATUS`.
AskStatus,
/// `DeleteGMTicket()`: `CMSG_GMTICKET_DELETETICKET`.
Delete,
/// `NewGMTicket` or `UpdateGMTicket`.
Write(GmTicketWrite),
}
/// One `NewGMTicket` or `UpdateGMTicket` call.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GmTicketWrite {
/// The selected `GMTicketCategory.dbc` id (`HelpFrameOpenTicket.ticketType`).
pub category: u32,
/// The text as typed; the EditBox caps it at 500, under the reference's 1999.
pub text: String,
/// `NewGMTicket` or `UpdateGMTicket`, two opcodes: the window picks by its own `hasTicket`
/// flag, and the app must not re-derive it.
pub is_new: bool,
}
impl super::UiScript {
/// The `GMTicketCategory.dbc` rows in file order, pushed once; the ids are the wire's values,
/// so renumbering them would misfile every ticket.
pub fn set_gm_ticket_categories(&mut self, categories: Vec<(u32, String)>) {
self.model_mut().gm_ticket_categories = categories;
}
/// Drain the ticket verbs in call order, one packet each.
pub fn take_gm_ticket_intents(&mut self) -> Vec<GmTicketIntent> {
std::mem::take(&mut self.model_mut().gm_ticket_intents)
}
/// Drain the `Stuck()` calls, each one cast of spell 7355.
pub fn take_stuck_casts(&mut self) -> u32 {
std::mem::take(&mut self.model_mut().stuck_casts)
}
}
pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
let g = lua.globals();
// A flat `id, name, ...` vararg list, walked in pairs by `HelpFrameGM_UpdateCategories`;
// empty until the app pushes the DBC.
g.set(
"GetGMTicketCategories",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
let mut out = Vec::with_capacity(model.gm_ticket_categories.len() * 2);
for (id, name) in &model.gm_ticket_categories {
out.push(Value::Integer(i64::from(*id)));
out.push(Value::String(lua.create_string(name)?));
}
Ok(MultiValue::from_vec(out))
})?,
)?;
// Sends: `GetGMTicket` is answered by `UPDATE_TICKET`, `GetGMStatus` by `UPDATE_GM_STATUS`.
for (name, intent) in [
("GetGMTicket", GmTicketIntent::Ask),
("GetGMStatus", GmTicketIntent::AskStatus),
("DeleteGMTicket", GmTicketIntent::Delete),
] {
g.set(
name,
lua.create_function(move |lua, ()| {
lua.app_data_mut::<Model>()
.expect("model app_data")
.gm_ticket_intents
.push(intent.clone());
Ok(())
})?,
)?;
}
// Submit and Save Changes: one signature, `(type, text)` in the reference's usage string.
for (name, is_new) in [("NewGMTicket", true), ("UpdateGMTicket", false)] {
g.set(
name,
lua.create_function(move |lua, (category, text): (u32, String)| {
lua.app_data_mut::<Model>()
.expect("model app_data")
.gm_ticket_intents
.push(GmTicketIntent::Write(GmTicketWrite {
category,
text,
is_new,
}));
Ok(())
})?,
)?;
}
// The Help window's Auto-Unstuck, not a ticket verb: it casts spell 7355, whose
// `SPELL_EFFECT_STUCK` moves the player to a safe position server-side.
g.set(
"Stuck",
lua.create_function(|lua, ()| {
lua.app_data_mut::<Model>()
.expect("model app_data")
.stuck_casts += 1;
Ok(())
})?,
)?;
Ok(())
}