The mailbox reads, lists and sends mail as 1.12.1 does (#2219)

The mailbox now follows 1.12.1's inbox and send code, and the mail verbs act inside their call (Part of #2202).
- Expired mail stays listed.
- Mail from an ignored player is dropped on type 0 only.
- Delete and return use the reference's tests, and the postage sum matches.
- Reply follows `0x4aefa5`.
- `GetInboxText` reads the mail's template id, and `CMSG_MAIL_CREATE_TEXT_ITEM` now carries it, pinned byte for byte.
- A row with no paper takes the first usable one, in `0x4ada90`'s order.
- The send slot refuses as `0x4adf38` does.
- The profanity filter masks subjects and bodies.
- The header icons and non-player sender names come from the bytes.
- Keeping the wire id where the reference crashes on a null paper is a written `Deviation:`.

Tests pin each address. Built on macOS.

Fixes #1241
Fixes #1235
Fixes #247
Fixes #240
Fixes #55
Fixes #140

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sam Sung
2026-10-22 06:21:55 +07:00
committed by GitHub
parent 85ba44b4d5
commit 0689a07471
28 changed files with 2675 additions and 846 deletions
+4 -3
View File
@@ -174,16 +174,17 @@ fn last_event(script: &UiScript) -> String {
fn mail_probe(
time: ProbeClock,
mut probe: ResMut<MailProbe>,
mail: Res<MailOpen>,
mut windows: Commands,
mut hosted_vm: crate::script_calls::HostedVm,
// The session is the call host's too ([`crate::ui_mail::MailVerbs`]): the probe's verbs apply
// as its turn ends.
mut vm: crate::script_calls::VmWith<Res<'static, MailOpen>>,
self_player: Query<(), With<SelfPlayer>>,
player: Res<Player>,
objects: Query<(&Guid, &NetEntity, &ObjectStore, &Transform), Without<SelfPlayer>>,
net: Res<NetCommands>,
mut exit: MessageWriter<AppExit>,
) {
hosted_vm.run(|script| {
vm.turn(|script, mail| {
if self_player.is_empty() {
return; // not in-world yet
}
+5 -1
View File
@@ -984,12 +984,16 @@ fn setup_entities(
}
match benilla_formats::load_stationery_catalog(&mut chain) {
Ok(catalog) => commands.insert_resource(crate::ui_mail::Stationery(catalog)),
Err(e) => warn!("stationery catalog unavailable, mail uses the default backdrop: {e:#}"),
Err(e) => warn!("stationery catalog unavailable, mail has no paper or texture: {e:#}"),
}
match benilla_formats::load_packages(&mut chain) {
Ok(rows) => commands.insert_resource(crate::ui_mail::Packages(rows)),
Err(e) => warn!("mail packages unavailable, GetNumPackages answers 0: {e:#}"),
}
match benilla_formats::load_mail_templates(&mut chain) {
Ok(rows) => commands.insert_resource(crate::ui_mail::MailTemplates(rows)),
Err(e) => warn!("mail templates unavailable, a template letter has no body: {e:#}"),
}
match benilla_formats::load_page_text_material_catalog(&mut chain) {
Ok(catalog) => commands.insert_resource(crate::ui_item_text::PageMaterials(catalog)),
Err(e) => warn!("page text materials unavailable, books read on parchment: {e:#}"),
+12
View File
@@ -183,6 +183,18 @@ impl GameObjectTemplates {
self.templates.get(entry).map(|t| t.name.as_str())
}
/// A template's name by entry, read as `ask` says, a miss asked with no spawn's guid: the inbox
/// header's game object sender (`0x558560` with the callback `0x4af080`, `0x4aee94`).
pub(crate) fn resolve_name(
&self,
entry: u32,
ask: crate::query_cache::Ask<'_>,
) -> Option<&str> {
self.templates
.read(entry, ask, |commands| Self::send(entry, 0, commands))
.map(|t| t.name.as_str())
}
/// The cached template for a GameObject, found through its own descriptor.
pub(crate) fn of(&self, fields: &ObjectFields) -> Option<&GoTemplate> {
Self::key(fields).and_then(|e| self.templates.get(e))
+1
View File
@@ -1616,6 +1616,7 @@ pub(crate) enum ClientCommand {
MailCreateTextItem {
mailbox: u64,
mail_id: u32,
template_id: u32,
},
/// `CMSG_ITEM_TEXT_QUERY`, once per mail with a nonzero `item_text_id`.
ItemTextQuery {
+5 -3
View File
@@ -1640,9 +1640,11 @@ pub(super) fn writer_loop(
ClientCommand::MailDelete { mailbox, mail_id } => {
w.mail_delete(mailbox, mail_id)
}
ClientCommand::MailCreateTextItem { mailbox, mail_id } => {
w.mail_create_text_item(mailbox, mail_id)
}
ClientCommand::MailCreateTextItem {
mailbox,
mail_id,
template_id,
} => w.mail_create_text_item(mailbox, mail_id, template_id),
ClientCommand::ItemTextQuery { text_id, mail_id } => {
w.item_text_query(text_id, mail_id)
}
+3 -1
View File
@@ -84,13 +84,14 @@ pub(crate) struct ScriptCallHost<'w, 's> {
crate::ui_party::PartyCalls<'w, 's>,
),
>,
// The bags' and the loot window's.
// The bags', the loot window's and the mailbox's.
ParamSet<
'w,
's,
(
crate::ui_items::ScriptItemUse<'w, 's>,
crate::ui_loot::LootSteps<'w, 's>,
crate::ui_mail::MailVerbs<'w>,
),
>,
crate::ui_pet::PetPress<'w, 's>,
@@ -194,6 +195,7 @@ impl CallHost for ScriptCallHost<'_, '_> {
ScriptCall::Auction(call) => appliers.p4().p3().apply(script, call),
ScriptCall::Social(call) => appliers.p4().p4().apply(script, call),
ScriptCall::Party(request) => appliers.p4().p5().apply(script, request),
ScriptCall::Mail(call) => appliers.p5().p2().apply(script, call),
}
// A selection this call made with the targeting cursor up was handed to the cast
// (`SelectTarget`, `0x4935d5`) and is bound now, before the next call reads either.
+33 -26
View File
@@ -7,11 +7,11 @@
//! (`[0xb6e5f0]`) that is never reset, so the phase carries across matches and messages. Patterns
//! apply in list order, not text order, every occurrence, and the length never changes.
//!
//! Only the chat chokepoint is wired. The reference masks twelve more sites, not built here: the
//! mail subject, `GetInboxText`, `GetGuildInfo`, the two guild-record accessors, the roster MOTD
//! and info, `GetGuildRosterInfo`, `GuildControlGetRankName`, item text, `SendChatMessage` and the
//! guild-event MOTD; seven of them pass the `dl = 1` memo, which re-blits a cached string without
//! advancing the index.
//! The chat chokepoint, the mail list's subjects (`0x4ad5b2`) and `GetInboxText`'s letter
//! (`0x4af203`) are wired. The reference masks ten more sites, not built here: `GetGuildInfo`, the
//! two guild-record accessors, the roster MOTD and info, `GetGuildRosterInfo`,
//! `GuildControlGetRankName`, item text, `SendChatMessage` and the guild-event MOTD; seven of them
//! pass the `dl = 1` memo, which re-blits a cached string without advancing the index.
//!
//! The predicate has one call site, in the chat chokepoint; it never edits the text, and a hit
//! drops the line silently.
@@ -293,8 +293,10 @@ pub(crate) struct TextFilter {
/// (`0xce893c`) is read by the masker and the name check alike.
profanity: Arc<PatternList>,
spam: PatternList,
/// `[0xb6e5f0]`: zero-initialized, advanced mod 8, never reset.
mask_index: usize,
/// `[0xb6e5f0]`: zero-initialized, advanced mod 8, never reset. Atomic, so every reader of the
/// filter (the chat chokepoint, the mail calls) shares the one index without excluding the
/// others.
mask_index: std::sync::atomic::AtomicUsize,
}
impl Default for TextFilter {
@@ -303,7 +305,7 @@ impl Default for TextFilter {
TextFilter {
profanity: Arc::new(PatternList::empty()),
spam: PatternList::empty(),
mask_index: 0,
mask_index: std::sync::atomic::AtomicUsize::new(0),
}
}
}
@@ -313,7 +315,7 @@ impl TextFilter {
TextFilter {
profanity: Arc::new(PatternList::compile(profanity, "chat profanity filter")),
spam: PatternList::compile(spam, "chat spam filter"),
mask_index: 0,
mask_index: std::sync::atomic::AtomicUsize::new(0),
}
}
@@ -351,16 +353,24 @@ impl TextFilter {
/// `0x4a1a60` with `dl = 0`: mask in place, return whether anything matched. `enabled` is
/// `profanityFilter`, tested here as the reference does.
pub(crate) fn mask(&mut self, enabled: bool, text: &mut String) -> bool {
pub(crate) fn mask(&self, enabled: bool, text: &mut String) -> bool {
if !enabled || text.is_empty() || self.profanity.len() == 0 {
return false;
}
self.mask_uncached(text)
}
/// The index's current token, and the index advanced past it.
fn next_mask_index(&self) -> usize {
use std::sync::atomic::Ordering::Relaxed;
let at = self.mask_index.load(Relaxed);
self.mask_index.store((at + 1) % MASK_TOKENS.len(), Relaxed);
at
}
/// The byte loop of `0x4a1b6a`-`0x4a1ba6`: one pass in list order over the mutating buffer, so
/// an earlier pattern's mask can enable a later match but never the reverse.
fn mask_uncached(&mut self, text: &mut String) -> bool {
fn mask_uncached(&self, text: &mut String) -> bool {
// The subject is ASCII-lowercased, byte-aligned with `text` and masked in step.
let mut subject = ascii_lower(text);
let mut candidates = self.profanity.candidates(&subject);
@@ -380,11 +390,7 @@ impl TextFilter {
// One token per byte of the span, as the reference's loop writes; a match is on
// char boundaries, so both strings stay valid UTF-8 and aligned.
let run: String = (start..end)
.map(|_| {
let token = MASK_TOKENS[self.mask_index] as char;
self.mask_index = (self.mask_index + 1) % MASK_TOKENS.len();
token
})
.map(|_| MASK_TOKENS[self.next_mask_index()] as char)
.collect();
text.replace_range(start..end, &run);
subject.replace_range(start..end, &run);
@@ -433,7 +439,7 @@ mod tests {
let f = TextFilter::new(&list(&[spelling]), &[]);
let mut hit = "you twat here".to_string();
let mut miss = "atwatb".to_string();
let mut copy = f;
let copy = f;
assert!(copy.mask(true, &mut hit), "{spelling} must match [4,8)");
assert_eq!(hit, "you !@#$ here", "{spelling}");
assert!(
@@ -458,7 +464,7 @@ mod tests {
}
fn masked(pattern: &str, text: &str) -> String {
let mut f = TextFilter::new(&list(&[pattern]), &[]);
let f = TextFilter::new(&list(&[pattern]), &[]);
let mut line = text.to_string();
f.mask(true, &mut line);
line
@@ -572,7 +578,7 @@ mod tests {
/// carrying across calls, and list order giving the later word the earlier mask characters.
#[test]
fn the_masker_reproduces_the_oracle_transcript() {
let mut f = TextFilter::new(&list(&[r"\<fagg[aeiouy]t", r"\<twat\>", "shit"]), &[]);
let f = TextFilter::new(&list(&[r"\<fagg[aeiouy]t", r"\<twat\>", "shit"]), &[]);
let mut line = "you are a twat and a faggot".to_string();
assert!(f.mask(true, &mut line));
@@ -596,7 +602,8 @@ mod tests {
assert_eq!(line, "hello friend, nice weather");
assert_eq!(
f.mask_index, 6,
f.mask_index.load(std::sync::atomic::Ordering::Relaxed),
6,
"the cycle carries forward, and is never reset"
);
}
@@ -604,17 +611,17 @@ mod tests {
/// With `profanityFilter = 0` the text is untouched and the phase does not move.
#[test]
fn the_masker_self_gates_and_a_gated_call_does_not_move_the_phase() {
let mut f = TextFilter::new(&list(&[r"\<twat\>"]), &[]);
let f = TextFilter::new(&list(&[r"\<twat\>"]), &[]);
let mut line = "you are a twat".to_string();
assert!(!f.mask(false, &mut line));
assert_eq!(line, "you are a twat");
assert_eq!(f.mask_index, 0);
assert_eq!(f.mask_index.load(std::sync::atomic::Ordering::Relaxed), 0);
}
/// A multi-byte match is masked byte for byte.
#[test]
fn a_non_ascii_match_is_masked_byte_for_byte() {
let mut f = TextFilter::new(&list(&["傻B"]), &[]);
let f = TextFilter::new(&list(&["傻B"]), &[]);
let mut line = "说 傻B 了".to_string();
let before = line.len();
assert!(f.mask(true, &mut line));
@@ -715,7 +722,7 @@ mod tests {
let mut chain = benilla_formats::open_chain(&data).expect("open chain");
let profanity = benilla_formats::load_chat_profanity(&mut chain).expect("profanity");
let spam = benilla_formats::load_spam_messages(&mut chain).expect("spam");
let mut f = TextFilter::new(&profanity, &spam);
let f = TextFilter::new(&profanity, &spam);
let mut line = "you are a twat and a faggot".to_string();
assert!(f.mask(true, &mut line));
@@ -798,7 +805,7 @@ impl benilla_ui::script::NameLists for NameFilter {
/// Bevy's sixteen-parameter limit.
#[derive(bevy::ecs::system::SystemParam)]
pub(crate) struct ChatTextFilter<'w> {
filter: ResMut<'w, TextFilter>,
filter: Res<'w, TextFilter>,
switches: Res<'w, TextFilterSwitches>,
}
@@ -822,7 +829,7 @@ impl ChatTextFilter<'_> {
/// Arm 2: mask the line if its type is in the reference's table (`0x49aa98`-`0x49aac2`); the
/// CVar is the masker's own.
pub(crate) fn mask_chat(&mut self, chat_type: u8, text: &mut String) {
pub(crate) fn mask_chat(&self, chat_type: u8, text: &mut String) {
if !PROFANITY_MASKED_CHAT_TYPES.contains(&chat_type) {
return;
}
+1 -1
View File
@@ -1120,7 +1120,7 @@ pub(super) fn feed_chat(
),
unit_names: crate::ui_unit::NameTables,
// The spam and profanity filters, which run in the reference's display function `0x49a870`.
mut text_filter: crate::text_filter::ChatTextFilter,
text_filter: crate::text_filter::ChatTextFilter,
) {
let (Some(script), set) = vm.parts() else {
return;
+3 -3
View File
@@ -410,8 +410,8 @@ fn readable(
/// Drive the begun session to `ITEM_TEXT_READY`, which shows the window, once the body and any
/// creator line are in.
fn feed_item_text(
mut vm: crate::script_calls::VmWith<ResMut<'static, ItemTextOpen>>,
mail: Res<MailOpen>,
// The mail session's body cache is the call host's too ([`crate::ui_mail::MailVerbs`]).
mut vm: crate::script_calls::VmWith<(ResMut<'static, ItemTextOpen>, Res<'static, MailOpen>)>,
pages: Res<PageTexts>,
objects: Objects,
items: Res<Items>,
@@ -424,7 +424,7 @@ fn feed_item_text(
states: Res<crate::world_state::WorldStates>,
unit_names: crate::ui_unit::NameTables,
) {
vm.feed(|script, mut open, fires| {
vm.feed(|script, (mut open, mail), fires| {
let Some(script) = script else {
return;
};
+2 -3
View File
@@ -20,9 +20,8 @@ pub(crate) mod auction_mail {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct AuctionSubject {
pub(crate) entry: u32,
/// The random-property roll. Parsed, not applied: the reference names the item with it
/// (`[rec+0x250]`, `[rec+0x254]`), and the displayed subject here does not.
#[allow(dead_code)]
/// The random-property roll, which names the item's suffix in the subject and the invoice
/// (`[rec+0x254]`, `0x5d8b00`).
pub(crate) random_property: i32,
pub(crate) result: u32,
}
File diff suppressed because it is too large Load Diff
+122 -18
View File
@@ -7,9 +7,10 @@ use bevy::prelude::*;
use super::{
mail_refusal, MailOpen, MailPending, MailResult, CHECKED_COD_PAYMENT, CHECKED_COPIED,
MAIL_SENT_KEY,
CHECKED_RETURNED, MAIL_SENT_KEY,
};
use crate::net::{ClientCommand, NetCommands, NetHandlerApp};
use crate::query_cache::Ask;
use crate::ui_items::{EquipError, EquipErrors};
pub(super) fn register(app: &mut App) {
@@ -22,9 +23,68 @@ pub(super) fn register(app: &mut App) {
.net_handler(K::Disconnected, on_session_end);
}
fn on_mail_list(In(ev): In<SessionEvent>, mut mail: ResMut<MailOpen>, commands: Res<NetCommands>) {
/// What the list handler reads beside the session: the papers it defaults a row to, the item
/// templates and GlobalStrings an auction notice's subject is written from, and the profanity
/// mask it runs on each subject.
#[derive(bevy::ecs::system::SystemParam)]
struct ListReads<'w, 's> {
stationery: Option<Res<'w, super::Stationery>>,
self_q: Query<
'w,
's,
(&'static crate::net::ObjectStore, &'static crate::net::Guid),
With<crate::net::SelfPlayer>,
>,
objects: crate::net::Objects<'w, 's>,
items: Res<'w, crate::items::Items>,
filter: Option<Res<'w, crate::text_filter::TextFilter>>,
switches: Option<Res<'w, crate::text_filter::TextFilterSwitches>>,
script: Option<NonSend<'w, benilla_ui::script::UiScript>>,
props: Option<Res<'w, crate::items::RandomProperties>>,
}
fn on_mail_list(
In(ev): In<SessionEvent>,
mut mail: ResMut<MailOpen>,
commands: Res<NetCommands>,
social: Res<crate::ui_social::SocialState>,
reads: ListReads,
) {
if let SessionEvent::MailList { mails } = ev {
mail_list(mails, &mut mail, &commands);
// The usable list's first paper (`[[0xb6ee30]]`, `0x4ad565`-`0x4ad56d`).
let first_paper = reads.stationery.as_deref().and_then(|catalog| {
super::stationeries(catalog, &reads.self_q, &reads.objects, &reads.items, None)
.first()
.map(|v| v.id)
});
let enabled = reads.switches.as_deref().is_some_and(|s| s.profanity);
let get_text = |key: &str| {
reads
.script
.as_deref()
.and_then(|s| crate::ui_chat::combat::global_string(s, key))
};
mail_list(
mails,
&mut mail,
&commands,
|guid| social.is_ignored(guid),
first_paper,
|raw| {
super::auction_subject(
raw,
&reads.items,
reads.props.as_deref(),
Ask::Event(&commands),
&get_text,
)
},
|subject| {
if let Some(filter) = reads.filter.as_deref() {
filter.mask(enabled, subject);
}
},
);
}
}
@@ -91,31 +151,75 @@ fn on_session_end(
*pending = MailPending::default();
}
/// `SMSG_MAIL_LIST_RESULT` replaces the rows; an expired row (`expire_days <= 0`) is deleted with
/// `CMSG_MAIL_DELETE` and dropped, as the handler `0x4ad1b0` does. It never touches
/// [`MailPending`]: nothing on the inbox path writes the countdown `0x845eac`.
pub(super) fn mail_list(mails: Vec<MailListEntry>, mail: &mut MailOpen, commands: &NetCommands) {
/// `SMSG_MAIL_LIST_RESULT` (`0x4ad1b0`) replaces the rows, whatever their days left: the handler
/// reads them (`0x4ad414`) and never tests them. A player's mail from an ignored sender
/// (`0x4ad47f`) that is neither returned nor a COD payment (`0x4ad496`) is answered at once and
/// dropped (`0x4ad51d`): `CMSG_MAIL_RETURN_TO_SENDER` when it holds an item or money (`0x4ad4bf`,
/// `0x4ad4c7`), else `CMSG_MAIL_DELETE` (`0x4ad4cf`), with the mailbox cell as it stands, 0 when
/// none is open (`0x4ad4e3`). Every other row with no positive stationery id takes `first_paper`,
/// the usable list's first (`0x4ad551`-`0x4ad56f`). An auction notice's subject is written by
/// `rewrite` when its item is held, else emptied (`0x4ad580`-`0x4ad5a0`, `0x4acf3d`), and every
/// row's shown subject is then
/// masked in list order (`0x4ad5b2`, `dl` 0); a notice keeps its raw triplet beside it
/// ([`super::ListedSubject`]). It never touches [`MailPending`]: nothing on the inbox path writes
/// the countdown `0x845eac`.
///
/// Deviation: with no usable paper the reference reads the first record of an empty list through
/// a null pointer (`0x4ad561`-`0x4ad56d`, `mov eax,[eax]` with `eax` 0) and faults; benilla keeps
/// the row's wire id, so the inbox still opens.
pub(super) fn mail_list(
mails: Vec<MailListEntry>,
mail: &mut MailOpen,
commands: &NetCommands,
is_ignored: impl Fn(u64) -> bool,
first_paper: Option<u32>,
mut rewrite: impl FnMut(&str) -> Option<String>,
mut mask: impl FnMut(&mut String),
) {
// The answer clears the request lock (`0x4ad5d0`).
mail.resolve_request();
// The parse ends in `MAIL_INBOX_UPDATE` (`0x4ad5c6`).
mail.list_results += 1;
let mailbox = mail.mailbox;
let mailbox = mail.mailbox.unwrap_or(0);
let mut auction_subjects = std::collections::HashMap::new();
mail.mails = mails
.into_iter()
.filter(|e| {
if e.expire_days <= 0.0 {
if let Some(mailbox) = mailbox {
let _ = commands.0.send(ClientCommand::MailDelete {
mailbox,
mail_id: e.message_id,
});
}
false
} else {
true
let answered = e.message_type == mail_message_type::NORMAL
&& is_ignored(e.sender_guid.unwrap_or(0))
&& e.checked & (CHECKED_RETURNED | CHECKED_COD_PAYMENT) == 0;
if answered {
let mail_id = e.message_id;
let _ = commands.0.send(if e.item.is_some() || e.money != 0 {
ClientCommand::MailReturnToSender { mailbox, mail_id }
} else {
ClientCommand::MailDelete { mailbox, mail_id }
});
}
!answered
})
.map(|mut e| {
// The id is read signed (`0x4ad551 cmp [ecx+0x11c],0; jg`).
if (e.stationery as i32) <= 0 {
if let Some(id) = first_paper {
e.stationery = id;
}
}
if e.message_type == mail_message_type::AUCTION {
let written = rewrite(&e.subject);
let rewritten = written.is_some();
// An item not held, or a subject the parse cannot name, leaves the cell empty
// (`0x4acf3d`, `0x4acfbd`).
let mut text = written.unwrap_or_default();
mask(&mut text);
auction_subjects.insert(e.message_id, super::ListedSubject { text, rewritten });
} else {
mask(&mut e.subject);
}
e
})
.collect();
mail.auction_subjects = auction_subjects;
}
/// Whether a take leaves the mail empty, which the client then deletes itself: `CMSG_MAIL_DELETE`,
@@ -0,0 +1,531 @@
//! The mail verbs inside their calls, through the whole client's call host: each packet goes out
//! before the verb returns, as the reference's bindings send in their own bodies, so a chunk's
//! packets leave in call order and its next line reads what the verb did.
use benilla_protocol::messages::{mail_message_type, MailAttachment, MailListEntry};
use benilla_protocol::SessionEvent;
use benilla_ui::script::{MailInboxRow, MailState, StationeryView, UiScript, UnitState};
use bevy::prelude::*;
use crossbeam_channel::Receiver;
use super::{MailOpen, MailPending, CHECKED_READ};
use crate::net::{ClientCommand, NetCommands};
use crate::script_calls::with_hosted_vm;
const MAILBOX: u64 = 0xF110_0000_0000_0B0C;
/// The sender of every player mail here.
const BOB: u64 = 0x42;
/// Commands as their debug text, `ClientCommand` having no `PartialEq`.
fn text(commands: impl IntoIterator<Item = ClientCommand>) -> Vec<String> {
commands.into_iter().map(|c| format!("{c:?}")).collect()
}
/// A wire row: a player's letter from Bob, unread, with text id `text_id` and 29 days left.
fn entry(message_id: u32, text_id: u32) -> MailListEntry {
MailListEntry {
message_id,
message_type: mail_message_type::NORMAL,
sender_guid: Some(BOB),
sender_id: None,
subject: "s".into(),
item_text_id: text_id,
package: 0,
stationery: 41,
item: None,
money: 0,
cod: 0,
checked: 0,
expire_days: 29.0,
mail_template_id: 0,
}
}
fn linen() -> MailAttachment {
MailAttachment {
entry: 2589,
perm_enchant: 0,
random_prop_id: 0,
suffix_factor: 0,
count: 1,
charges: 0,
durability: 0,
durability_max: 0,
}
}
/// The VM's row for `e`, as the feed resolves it.
fn row_of(e: &MailListEntry) -> MailInboxRow {
MailInboxRow {
mail_id: e.message_id,
item_text_id: e.item_text_id,
stationery: e.stationery,
message_type: e.message_type,
mail_template_id: e.mail_template_id,
money: e.money,
cod: e.cod,
days_left: e.expire_days,
item_id: e.item.as_ref().map_or(0, |i| i.entry),
item_count: e.item.as_ref().map_or(0, |i| u32::from(i.count)),
was_read: e.checked & CHECKED_READ != 0,
can_reply: true,
subject: e.subject.clone(),
..Default::default()
}
}
/// The whole client, headless, with a mailbox open on `mails` and the VM holding their rows,
/// recording every mail event its handlers hear.
struct Mailbox {
app: App,
rx: Receiver<ClientCommand>,
}
impl Mailbox {
fn new(mails: Vec<MailListEntry>) -> Self {
let mut app = crate::game_plugins::schedule_tests::headless_client();
let (tx, rx) = crossbeam_channel::unbounded();
app.insert_resource(NetCommands(tx));
let world = app.world_mut();
let rows = mails.iter().map(row_of).collect();
{
let mut mail = world.resource_mut::<MailOpen>();
mail.click(MAILBOX);
mail.mails = mails;
}
let mut script = UiScript::new().expect("a VM");
script
.run(
r#"HEARD = {}
local f = CreateFrame("Frame")
f:RegisterEvent("MAIL_INBOX_UPDATE")
f:SetScript("OnEvent", function() table.insert(HEARD, event) end)"#,
)
.expect("the recorder installs");
script.set_unit("player", Some(UnitState::default()));
script.set_money(1_000);
script.set_mail(Some(MailState {
inbox: rows,
open: true,
}));
world.insert_non_send_resource(script);
Self { app, rx }
}
/// Run `lua` with the host lent, as every entry that runs Lua lends it.
fn run(&mut self, lua: &str) {
with_hosted_vm(self.app.world_mut(), |s| s.expect("a VM").run(lua))
.expect("the script runs");
}
fn eval<T: benilla_ui::mlua::FromLuaMulti>(&mut self, lua: &str) -> T {
with_hosted_vm(self.app.world_mut(), |s| s.expect("a VM").eval::<T>(lua))
.expect("the chunk runs")
}
/// One frame's mail feed, its memos kept from the last.
fn feed(&mut self) {
self.app
.world_mut()
.run_system_cached(super::feed_mail)
.expect("the feed runs");
}
fn script(&mut self) -> Mut<'_, UiScript> {
self.app.world_mut().non_send_resource_mut::<UiScript>()
}
/// What went on the wire, the name and item queries aside.
fn sent(&self) -> Vec<String> {
text(self.rx.try_iter().filter(|c| {
!matches!(
c,
ClientCommand::ItemQuery { .. } | ClientCommand::NameQuery { .. }
)
}))
}
}
/// Each mail verb sends inside its call, so a roll on the chunk's next line follows it on the wire
/// (`0x4aeb0b`, `0x4af85c`, `0x4af9d2`, `0x4afc4d`, `0x4afd79`, `0x4afb08`, `0x4aea6c`).
#[test]
fn each_mail_verb_is_on_the_wire_before_the_next_line() {
let mut paid = entry(1, 0);
(paid.money, paid.item) = (50, Some(linen()));
let mut h = Mailbox::new(vec![paid, entry(2, 9)]);
let roll = text([ClientCommand::RandomRoll { min: 1, max: 100 }]);
let verb = |lua: &str, h: &mut Mailbox| {
h.script().mail_request_resolved();
h.run(&format!("{lua} RandomRoll(1, 100)"));
let sent = h.sent();
assert_eq!(sent.len(), 2, "{lua}: {sent:?}");
assert_eq!(sent[1..], roll[..], "{lua}");
sent[0].clone()
};
let take = |kind: &str, id: u32| format!("{kind} {{ mailbox: {MAILBOX}, mail_id: {id} }}");
assert_eq!(
verb("CheckInbox()", &mut h),
format!("GetMailList {{ mailbox: {MAILBOX} }}")
);
assert_eq!(verb("TakeInboxMoney(1)", &mut h), take("MailTakeMoney", 1));
assert_eq!(verb("TakeInboxItem(1)", &mut h), take("MailTakeItem", 1));
assert_eq!(
verb("ReturnInboxItem(1)", &mut h),
take("MailReturnToSender", 1)
);
assert_eq!(
verb("TakeInboxTextItem(2)", &mut h),
format!("MailCreateTextItem {{ mailbox: {MAILBOX}, mail_id: 2, template_id: 0 }}")
);
assert_eq!(verb("DeleteInboxItem(2)", &mut h), take("MailDelete", 2));
h.script().set_mail_stationeries(vec![StationeryView {
id: 41,
name: "Default Stationery".into(),
icon: "Interface\\Icons\\INV_Letter_15".into(),
cost: Some(0),
texture: "STATIONERYTEST".into(),
}]);
let sent = verb(
"SelectStationery(1) SendMail('Jaina', 'Hi', 'body')",
&mut h,
);
assert!(sent.starts_with("SendMail {"), "{sent}");
}
/// `TakeInboxTextItem` sends the template id after the mail id (`0x4afb4a`), which a template
/// letter needs to be copied.
#[test]
fn a_template_letter_is_copied_with_its_template_id() {
let mut template = entry(3, 0);
template.mail_template_id = 87;
let mut h = Mailbox::new(vec![template]);
h.run("TakeInboxTextItem(1)");
assert_eq!(
h.sent(),
[format!(
"MailCreateTextItem {{ mailbox: {MAILBOX}, mail_id: 3, template_id: 87 }}"
)]
);
}
/// `GetInboxText` marks an unread mail inside its call (`0x4af18e` → `0x4adcd0`): the packet
/// (`0x4adcfe`), the read bit (`0x4add62`), days left above 3 lowered to 3 on a mail with no COD
/// (`0x4add72`-`0x4add8e`), `MAIL_INBOX_UPDATE` (`0x4add9d`) and the deferred refresh
/// (`0x4adda6`), then the body's ask (`0x4af1bf`). The script's next line reads all of it, and
/// the feed after it, finding the VM's rows as its own, signals nothing more.
#[test]
fn opening_an_unread_mail_marks_it_inside_the_call() {
let mut h = Mailbox::new(vec![entry(1, 9)]);
h.feed();
let _ = h.sent();
let (read, days, heard): (bool, f64, i64) = h.eval(
"GetInboxText(1) local _, _, _, _, _, _, days, _, read = GetInboxHeaderInfo(1) \
return read == 1, days, table.getn(HEARD)",
);
assert_eq!((read, days, heard), (true, 3.0, 1));
assert_eq!(
h.sent(),
text([
ClientCommand::MailMarkAsRead {
mailbox: MAILBOX,
mail_id: 1,
},
ClientCommand::ItemTextQuery {
text_id: 9,
mail_id: 1,
},
])
);
let world = h.app.world_mut();
let held = &world.resource::<MailOpen>().mails[0];
assert_eq!((held.checked & CHECKED_READ, held.expire_days), (1, 3.0));
assert!(world.resource_mut::<MailPending>().take_refresh());
h.feed();
assert_eq!(h.eval::<i64>("return table.getn(HEARD)"), 1);
}
/// A mail already read is not marked again (`0x4adcee`): no packet, no event and no refresh. Its
/// body is still asked for in the call.
#[test]
fn opening_a_read_mail_only_asks_for_its_body() {
let mut read = entry(1, 9);
read.checked = CHECKED_READ;
let mut h = Mailbox::new(vec![read]);
h.run("GetInboxText(1)");
assert_eq!(
h.sent(),
text([ClientCommand::ItemTextQuery {
text_id: 9,
mail_id: 1,
}])
);
assert_eq!(h.eval::<i64>("return table.getn(HEARD)"), 0);
let world = h.app.world_mut();
assert!(!world.resource_mut::<MailPending>().take_refresh());
assert_eq!(world.resource::<MailOpen>().mails[0].expire_days, 29.0);
}
/// The list handler (`0x4ad1b0`) keeps a row whatever its days left (it never tests `+0x14c`,
/// read at `0x4ad414`), and answers an ignored player's mail at once (`0x4ad47f`): unless returned
/// or a COD payment (`0x4ad496`), `CMSG_MAIL_RETURN_TO_SENDER` when it holds an item or money
/// (`0x4ad4bf`, `0x4ad4c7`), else `CMSG_MAIL_DELETE` (`0x4ad4cf`), each with the mailbox cell as it
/// stands (`0x4ad4e3`), and drops the row (`0x4ad51d`).
#[test]
fn the_list_keeps_expired_mail_and_answers_an_ignored_sender() {
const IGNORED: u64 = 0x99;
let mut h = Mailbox::new(Vec::new());
let from_ignored = |id: u32| MailListEntry {
sender_guid: Some(IGNORED),
..entry(id, 0)
};
let mut expired = entry(1, 0);
expired.expire_days = 0.0;
let mut overdue = entry(2, 0);
overdue.expire_days = -1.0;
let mut with_item = from_ignored(3);
with_item.item = Some(linen());
let letter = from_ignored(4);
let mut returned = from_ignored(5);
(returned.money, returned.checked) = (20, 0x2);
let mut paid = from_ignored(6);
paid.money = 20;
let world = h.app.world_mut();
crate::net::handlers::dispatch(
world,
vec![
SessionEvent::IgnoreList {
guids: vec![IGNORED],
},
SessionEvent::MailList {
mails: vec![expired, overdue, with_item, letter, returned, paid],
},
],
);
let kept: Vec<u32> = world
.resource::<MailOpen>()
.mails
.iter()
.map(|e| e.message_id)
.collect();
assert_eq!(kept, [1, 2, 5]);
assert_eq!(
h.sent(),
text([
ClientCommand::MailReturnToSender {
mailbox: MAILBOX,
mail_id: 3,
},
ClientCommand::MailDelete {
mailbox: MAILBOX,
mail_id: 4,
},
ClientCommand::MailReturnToSender {
mailbox: MAILBOX,
mail_id: 6,
},
])
);
// With the mailbox closed the answer still goes, its cell 0.
let world = h.app.world_mut();
world.resource_mut::<MailOpen>().clear();
crate::net::handlers::dispatch(
world,
vec![SessionEvent::MailList {
mails: vec![from_ignored(7)],
}],
);
assert_eq!(
h.sent(),
text([ClientCommand::MailDelete {
mailbox: 0,
mail_id: 7,
}])
);
}
/// A profanity list masking the one word `darn`.
fn darn_filter() -> crate::text_filter::TextFilter {
crate::text_filter::TextFilter::new(
&[benilla_formats::FilterPattern {
id: 1,
pattern: r"\<darn\>".into(),
}],
&[],
)
}
/// The list handler gives a row with no positive stationery id the first usable paper's
/// (`0x4ad551`-`0x4ad56f`), and masks each kept row's subject (`0x4ad5b2`, `dl` 0) in list order.
#[test]
fn the_list_defaults_the_paper_and_masks_the_subject() {
let mut h = Mailbox::new(Vec::new());
let world = h.app.world_mut();
world.insert_resource(super::Stationery(
benilla_formats::StationeryCatalog::from_rows(vec![
benilla_formats::StationeryRow {
id: 42,
item: 9312,
texture: "FREE".into(),
flags: 1,
},
benilla_formats::StationeryRow {
id: 41,
item: 9311,
texture: "STATIONERYTEST".into(),
flags: 1,
},
]),
));
{
let mut items = world.resource_mut::<crate::items::Items>();
// The cheapest paper is not the lowest id, so the sort, not the id order, picks it.
for (entry, price) in [(9311, 25), (9312, 0)] {
let mut t = crate::items::test_template("Paper");
t.buy_price = price;
items.insert_template(entry, Some(t));
}
}
world.insert_resource(darn_filter());
let mut none = entry(1, 0);
none.stationery = 0;
none.subject = "darn it".into();
let mut negative = entry(2, 0);
negative.stationery = u32::MAX;
let mut gm = entry(3, 0);
gm.stationery = 61;
crate::net::handlers::dispatch(
world,
vec![SessionEvent::MailList {
mails: vec![none, negative, gm],
}],
);
let mail = world.resource::<MailOpen>();
let rows: Vec<(u32, &str)> = mail
.mails
.iter()
.map(|e| (e.stationery, e.subject.as_str()))
.collect();
assert_eq!(rows, [(42, "!@#$ it"), (42, "s"), (61, "s")]);
}
/// `GetInboxText` masks the text it reads (`0x4af203`, `dl` 0) on every call, after the `$`
/// expansion, so each read moves the mask's phase; a template's body is not masked
/// (`0x4af261`-`0x4af26e`).
#[test]
fn get_inbox_text_masks_a_letter_but_not_a_template() {
let mut letter = entry(1, 9);
letter.checked = CHECKED_READ;
let mut template = entry(2, 0);
template.mail_template_id = 87;
let mut h = Mailbox::new(vec![letter, template]);
h.app.world_mut().insert_resource(darn_filter());
{
let mut script = h.script();
let mut state = MailState {
inbox: Vec::new(),
open: true,
};
for (id, body) in [(1, "darn mail"), (2, "darn template")] {
let mut e = entry(id, if id == 1 { 9 } else { 0 });
e.checked = CHECKED_READ;
e.mail_template_id = if id == 2 { 87 } else { 0 };
state.inbox.push(MailInboxRow {
body: Some(body.into()),
..row_of(&e)
});
}
script.set_mail(Some(state));
}
let bodies: (String, String, String) = h.eval(
"local a = GetInboxText(1) local b = GetInboxText(1) local c = GetInboxText(2) \
return a, b, c",
);
assert_eq!(
bodies,
(
"!@#$ mail".to_string(),
"%^&* mail".to_string(),
"darn template".to_string()
)
);
}
/// An auction notice's subject is masked by the list parse that rewrites it, when its item is
/// held then (`0x4ace70`, then `0x4ad5b2`); one whose item is not held shows empty
/// (`0x4acf3d`) until the template's callback rewrites it (`0x4ad010` → `0x4ace40`), unmasked.
#[test]
fn an_auction_subject_is_masked_by_the_list_parse_alone() {
let mut h = Mailbox::new(Vec::new());
h.script()
.run("AUCTION_WON_MAIL_SUBJECT = 'Auction won: %s'")
.expect("the string sets");
let world = h.app.world_mut();
world.insert_resource(darn_filter());
world
.resource_mut::<crate::items::Items>()
.insert_template(2589, Some(crate::items::test_template("darn cloth")));
let notice = |id: u32, item: u32| MailListEntry {
message_type: mail_message_type::AUCTION,
sender_guid: None,
sender_id: Some(1),
subject: format!("{item}:0:1"),
..entry(id, 0)
};
crate::net::handlers::dispatch(
world,
vec![SessionEvent::MailList {
mails: vec![notice(1, 2589), notice(2, 2590)],
}],
);
h.feed();
// An item not held at the parse leaves the cell empty (`0x4acf3d`) until it lands.
let waiting: String = h.eval("local _, _, _, b = GetInboxHeaderInfo(2) return b");
assert_eq!(waiting, "");
h.app
.world_mut()
.resource_mut::<crate::items::Items>()
.insert_template(2590, Some(crate::items::test_template("darn wool")));
h.feed();
let subjects: (String, String) = h.eval(
"local _, _, _, a = GetInboxHeaderInfo(1) local _, _, _, b = GetInboxHeaderInfo(2) \
return a, b",
);
assert_eq!(
subjects,
(
"Auction won: !@#$ cloth".to_string(),
"Auction won: darn wool".to_string()
)
);
}
/// The read mark's `MAIL_INBOX_UPDATE` (`0x4add9d`) comes before the body is read and masked
/// (`0x4af1bf`, `0x4af203`), so a handler that reads the letter again inside it takes the mask's
/// first phase and the outer call its own masked body.
#[test]
fn a_nested_get_inbox_text_leaves_the_outer_body_masked() {
let mut h = Mailbox::new(vec![entry(1, 9)]);
h.app.world_mut().insert_resource(darn_filter());
{
let mut script = h.script();
script.set_mail(Some(MailState {
inbox: vec![MailInboxRow {
body: Some("darn mail".into()),
..row_of(&entry(1, 9))
}],
open: true,
}));
script
.run(
r#"local f = CreateFrame("Frame")
f:RegisterEvent("MAIL_INBOX_UPDATE")
f:SetScript("OnEvent", function()
if not INNER then INNER = GetInboxText(1) end
end)"#,
)
.expect("the reader installs");
}
let bodies: (String, String) = h.eval("local outer = GetInboxText(1) return outer, INNER");
assert_eq!(bodies, ("%^&* mail".to_string(), "!@#$ mail".to_string()));
}
+128
View File
@@ -0,0 +1,128 @@
//! The mail verbs' engine half, which the call host applies inside each call
//! ([`crate::script_calls::ScriptCallHost`]): each packet with the mailbox cell as it stands
//! (`[0xb6ef88]`), and `GetInboxText`'s read mark and body ask, before the verb returns, as the
//! reference's bindings send in their own bodies (`0x4aeab0`, `0x4af110`, `0x4af7d0`, `0x4af8e0`,
//! `0x4afa60`, `0x4afba0`, `0x4afcd0`, `0x4ae800`).
use bevy::ecs::system::SystemParam;
use bevy::prelude::*;
use benilla_ui::script::{MailCall, MailRowVerb, UiScript};
use super::{MailOpen, MailPending};
use crate::net::{ClientCommand, NetCommands};
/// The state the mail verbs read and write: the session's rows and body cache, the deferred
/// refresh, and the socket.
#[derive(SystemParam)]
pub(crate) struct MailVerbs<'w> {
/// Absent in a world with no mail session, which drops the calls.
mail: Option<ResMut<'w, MailOpen>>,
pending: Option<ResMut<'w, MailPending>>,
commands: Res<'w, NetCommands>,
/// The profanity mask a read letter's text runs through (`0x4af203`).
filter: Option<Res<'w, crate::text_filter::TextFilter>>,
switches: Option<Res<'w, crate::text_filter::TextFilterSwitches>>,
}
impl MailVerbs<'_> {
/// Apply one mail call.
pub(crate) fn apply(&mut self, script: &mut UiScript, call: MailCall) {
let Self {
mail,
pending,
commands,
filter,
switches,
} = self;
let Some(mail) = mail.as_deref_mut() else {
debug!("ui_mail: no mail session in this world; {call:?} dropped");
return;
};
match call {
MailCall::Open {
index,
mail_id,
unread,
} => {
// The mark runs with no test of the mailbox, which a close leaves 0 (`0x4add25`).
if unread {
let mailbox = mail.mailbox.unwrap_or(0);
let _ = commands
.0
.send(ClientCommand::MailMarkAsRead { mailbox, mail_id });
mail.mark_read(mail_id);
script.mark_mail_read(index);
// Only an unread mail arms the close's re-query (`0x4adda6`).
if let Some(pending) = pending.as_deref_mut() {
pending.arm_refresh();
}
}
return;
}
MailCall::ReadBody {
index,
mail_id,
text_id,
} => {
mail.bodies.lookup(text_id, || {
let _ = commands
.0
.send(ClientCommand::ItemTextQuery { text_id, mail_id });
});
// The cached text, expanded, is masked on every read (`0x4af1f6`, `0x4af203` with
// `dl` 0), so each read moves the mask's phase; a template's body is not.
if let (Some(mut body), Some(filter)) =
(script.inbox_body(index), filter.as_deref())
{
let enabled = switches.as_deref().is_some_and(|s| s.profanity);
filter.mask(enabled, &mut body);
script.answer_inbox_body(body);
}
return;
}
_ => {}
}
// The VM's guards found a mailbox the session has since forgotten: no packet goes, so the
// locks the verb took go back.
let Some(mailbox) = mail.mailbox else {
if matches!(call, MailCall::Send(_)) {
script.mail_send_resolved();
}
script.mail_request_resolved();
return;
};
let command = match call {
MailCall::Open { .. } | MailCall::ReadBody { .. } => return,
MailCall::CheckInbox => ClientCommand::GetMailList { mailbox },
MailCall::Row {
verb,
mail_id,
template_id,
} => match verb {
MailRowVerb::TakeMoney => ClientCommand::MailTakeMoney { mailbox, mail_id },
MailRowVerb::TakeItem => ClientCommand::MailTakeItem { mailbox, mail_id },
MailRowVerb::Return => ClientCommand::MailReturnToSender { mailbox, mail_id },
MailRowVerb::Delete => ClientCommand::MailDelete { mailbox, mail_id },
MailRowVerb::TakeText => ClientCommand::MailCreateTextItem {
mailbox,
mail_id,
template_id,
},
},
MailCall::Send(req) => ClientCommand::SendMail {
mailbox,
receiver: req.target,
subject: req.subject,
body: req.body,
stationery: req.stationery,
item_guid: req.item_guid,
money: req.money,
cod: req.cod,
// The package rides only with an item (`0x4ae8f3`).
package: if req.item_guid != 0 { req.package } else { 0 },
},
};
let _ = commands.0.send(command);
}
}
+79 -42
View File
@@ -1,13 +1,37 @@
//! Drives the stock `MailFrame.xml` off the player's chain with a synthetic inbox and the app's
//! own `MAIL_SHOW`/`MAIL_INBOX_UPDATE` events, and asserts what it paints and queues.
//! own `MAIL_SHOW`/`MAIL_INBOX_UPDATE` events, and asserts what it paints and the calls it makes,
//! which a VM with no host keeps.
mod common;
use benilla_ui::script::{
EditAction, EditBoxAdvanceRequest, EditUnit, MailInboxRow, MailInvoice, MailState,
MeasureRequest, TextMeasure, UiScript,
EditAction, EditBoxAdvanceRequest, EditUnit, MailCall, MailInboxRow, MailInvoice, MailRowVerb,
MailState, MeasureRequest, TextMeasure, UiScript,
};
/// A VM with no call host, keeping the mail verbs' calls for [`kept_calls`].
fn vm() -> UiScript {
let mut s = UiScript::new().unwrap();
s.keep_calls();
s
}
/// The mail calls kept since the last take, in call order.
fn kept_calls(s: &mut UiScript) -> Vec<MailCall> {
s.take_mail_calls()
}
/// The row verbs among the kept calls.
fn row_verbs(s: &mut UiScript) -> Vec<MailRowVerb> {
kept_calls(s)
.into_iter()
.filter_map(|call| match call {
MailCall::Row { verb, .. } => Some(verb),
_ => None,
})
.collect()
}
/// The mail window's load prefix, in the app's order.
const FILES: &[&str] = &[
"Interface\\FrameXML\\GlobalStrings.lua",
@@ -43,6 +67,9 @@ fn load_ui(script: &UiScript) {
/// One inbox row with the fields the window paints.
fn row(sender: &str, subject: &str, was_read: bool, item_id: u32, cod: u32) -> MailInboxRow {
MailInboxRow {
mail_id: 7,
item_text_id: 1,
stationery: 41,
package_icon: (item_id != 0).then(|| "Interface\\Icons\\INV_Misc_Bag_08".to_string()),
stationery_icon: Some("Interface\\Icons\\INV_Misc_Note_01".to_string()),
sender: Some(sender.to_string()),
@@ -57,15 +84,13 @@ fn row(sender: &str, subject: &str, was_read: bool, item_id: u32, cod: u32) -> M
can_reply: true,
is_gm: false,
body: Some("body".into()),
stationery_texture: "STATIONERYTEST".into(),
stationery_texture: Some("STATIONERYTEST".into()),
is_invoice: false,
invoice: None,
has_body: true,
item_id,
item_name: (item_id != 0).then(|| "Linen Cloth".to_string()),
item_texture: (item_id != 0).then(|| "Interface\\Icons\\INV_Fabric_Linen_01".to_string()),
item_quality: (item_id != 0).then_some(1),
can_delete: false,
item_random_property_id: 0,
item_charges: 0,
item_durability: (0, 0),
@@ -112,7 +137,7 @@ fn small_inbox() -> MailState {
#[test]
fn mail_frame_loads_and_key_regions_exist() {
let _data = benilla_formats::wow_data_or_skip!();
let s = UiScript::new().unwrap();
let s = vm();
load_ui(&s);
// The window, both tabs' bodies, a row, the open-letter toplevel, and the send-tab widgets.
for name in [
@@ -140,7 +165,7 @@ fn mail_frame_loads_and_key_regions_exist() {
#[test]
fn mail_show_opens_and_inbox_populates() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(small_inbox()));
@@ -152,7 +177,11 @@ fn mail_show_opens_and_inbox_populates() {
"the window opens on MAIL_SHOW"
);
// MAIL_SHOW's CheckInbox() queued the inbox-refresh intent.
assert!(s.take_mail_check_inbox(), "MAIL_SHOW fires CheckInbox");
assert_eq!(
kept_calls(&mut s),
[MailCall::CheckInbox],
"MAIL_SHOW fires CheckInbox"
);
s.fire_event("MAIL_INBOX_UPDATE", vec![]);
assert_eq!(s.eval::<i64>("return GetInboxNumItems()").unwrap(), 2);
@@ -179,7 +208,7 @@ fn mail_show_opens_and_inbox_populates() {
#[test]
fn paging_math_enables_next_only_when_overflowing() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
// 9 mails → 2 pages of 7.
let mut inbox = Vec::new();
@@ -212,7 +241,7 @@ fn paging_math_enables_next_only_when_overflowing() {
#[test]
fn cod_tag_shows_on_a_cod_mail() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(MailState {
inbox: vec![
@@ -242,14 +271,14 @@ fn cod_tag_shows_on_a_cod_mail() {
#[test]
fn opening_a_letter_shows_the_open_frame_and_queues_the_body() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(small_inbox()));
s.fire_event("MAIL_SHOW", vec![]);
// The list answer to `MAIL_SHOW`'s `CheckInbox` lifts the request lock (`0x4ad5d0`).
s.mail_request_resolved();
s.fire_event("MAIL_INBOX_UPDATE", vec![]);
let _ = s.take_mail_opens();
let _ = kept_calls(&mut s);
// A programmatic click toggles the check button on, then fires OnClick (this = the button).
s.run("MailItem1Button:Click()").unwrap();
@@ -257,12 +286,17 @@ fn opening_a_letter_shows_the_open_frame_and_queues_the_body() {
s.eval::<bool>("return OpenMailFrame:IsShown()").unwrap(),
"the open-letter frame shows"
);
// The sender/subject/body painted; GetInboxText queued the open (mark-read + body ask).
// The sender/subject/body painted; GetInboxText made its call (mark-read + body ask).
assert_eq!(
s.eval::<String>("return OpenMailSender:GetText()").unwrap(),
"Thrall"
);
assert!(s.take_mail_opens().contains(&1), "opening queued the row");
assert!(
kept_calls(&mut s)
.iter()
.any(|c| matches!(c, MailCall::Open { index: 1, .. })),
"opening called for the row"
);
assert!(s.take_errors().is_empty());
}
@@ -272,14 +306,14 @@ fn opening_a_letter_shows_the_open_frame_and_queues_the_body() {
#[test]
fn a_letter_and_the_centre_occupant_evict_each_other() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(small_inbox()));
s.fire_event("MAIL_SHOW", vec![]);
// The list answer to `MAIL_SHOW`'s `CheckInbox` lifts the request lock (`0x4ad5d0`).
s.mail_request_resolved();
s.fire_event("MAIL_INBOX_UPDATE", vec![]);
let _ = s.take_mail_opens();
let _ = kept_calls(&mut s);
// Mailbox left, character sheet pushed to centre beside it.
s.run(
@@ -330,7 +364,7 @@ fn a_letter_and_the_centre_occupant_evict_each_other() {
#[test]
fn reply_switches_to_send_tab_prefilled() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(small_inbox()));
s.fire_event("MAIL_SHOW", vec![]);
@@ -360,7 +394,7 @@ fn reply_switches_to_send_tab_prefilled() {
#[test]
fn closing_a_plain_letter_does_not_delete_it() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(MailState {
inbox: vec![row("One", "test", false, 0, 0)],
@@ -370,14 +404,16 @@ fn closing_a_plain_letter_does_not_delete_it() {
// The list answer to `MAIL_SHOW`'s `CheckInbox` lifts the request lock (`0x4ad5d0`).
s.mail_request_resolved();
s.fire_event("MAIL_INBOX_UPDATE", vec![]);
let _ = s.take_mail_opens();
let _ = s.take_mail_deletes();
let _ = kept_calls(&mut s);
s.run("MailItem1Button:Click()").unwrap();
assert!(s.eval::<bool>("return OpenMailFrame:IsShown()").unwrap());
s.run("OpenMailCancelButton:Click()").unwrap();
assert!(s.take_errors().is_empty(), "no Lua errors on close");
let deletes = s.take_mail_deletes();
let deletes: Vec<_> = row_verbs(&mut s)
.into_iter()
.filter(|&v| v == MailRowVerb::Delete)
.collect();
assert!(
deletes.is_empty(),
"closing a plain read letter must NOT delete it, got deletes: {deletes:?}"
@@ -390,7 +426,7 @@ fn closing_a_plain_letter_does_not_delete_it() {
#[test]
fn closing_a_taken_husk_deletes_it() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
let mut husk = row("One", "test", false, 0, 0);
husk.text_created = true;
@@ -402,15 +438,14 @@ fn closing_a_taken_husk_deletes_it() {
// The list answer to `MAIL_SHOW`'s `CheckInbox` lifts the request lock (`0x4ad5d0`).
s.mail_request_resolved();
s.fire_event("MAIL_INBOX_UPDATE", vec![]);
let _ = s.take_mail_opens();
let _ = s.take_mail_deletes();
let _ = kept_calls(&mut s);
s.run("MailItem1Button:Click()").unwrap();
s.run("OpenMailCancelButton:Click()").unwrap();
assert!(s.take_errors().is_empty(), "no Lua errors on close");
assert_eq!(
s.take_mail_deletes(),
vec![1],
row_verbs(&mut s),
[MailRowVerb::Delete],
"the husk purges on close (reference OnHide, MailFrame.lua l.256-272)"
);
}
@@ -420,7 +455,7 @@ fn closing_a_taken_husk_deletes_it() {
#[test]
fn expiry_text_pluralizes_days() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
let mut one_day = row("Two", "b", false, 0, 0);
one_day.days_left = 1.7;
@@ -450,7 +485,7 @@ fn expiry_text_pluralizes_days() {
#[test]
fn letter_button_shows_for_a_body_letter_and_click_queues_the_copy() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
let mut mail = row("One", "asd", false, 0, 0);
mail.money = 10000;
@@ -479,9 +514,9 @@ fn letter_button_shows_for_a_body_letter_and_click_queues_the_copy() {
);
s.run("OpenMailLetterButton:Click()").unwrap();
assert_eq!(
s.take_mail_take_texts(),
vec![1],
"the click queues the permanent-copy intent"
row_verbs(&mut s),
[MailRowVerb::TakeText],
"the click calls for the permanent copy"
);
assert!(s.take_errors().is_empty());
}
@@ -490,7 +525,7 @@ fn letter_button_shows_for_a_body_letter_and_click_queues_the_copy() {
#[test]
fn letter_button_hides_once_copied() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
let mut mail = row("One", "asd", false, 0, 0);
mail.money = 10000;
@@ -518,7 +553,7 @@ fn letter_button_hides_once_copied() {
#[test]
fn money_button_hover_shows_the_amount_tooltip() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
let mut mail = row("One", "asd", false, 0, 0);
mail.money = 10000;
@@ -551,7 +586,7 @@ fn money_button_hover_shows_the_amount_tooltip() {
#[test]
fn inbox_page_label_stays_empty_like_the_reference() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(small_inbox()));
s.fire_event("MAIL_SHOW", vec![]);
@@ -572,7 +607,7 @@ fn inbox_page_label_stays_empty_like_the_reference() {
#[test]
fn a_runtime_shown_pane_renders_its_own_layers() {
let _data = benilla_formats::wow_data_or_skip!();
let s = UiScript::new().unwrap();
let s = vm();
load_ui(&s);
s.eval::<()>("MailFrame:Show() SendMailFrame:Show()")
.unwrap();
@@ -603,12 +638,14 @@ fn an_auction_invoice_renders_as_a_receipt() {
.unwrap();
}
fn open_with(invoice: MailInvoice) -> UiScript {
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
strings(&s);
let mut inbox = small_inbox();
inbox.inbox[0].is_invoice = true;
inbox.inbox[0].invoice = Some(invoice);
// An auction mail's text is no letter body (`0x4af1cf`), as the feed resolves it.
(inbox.inbox[0].message_type, inbox.inbox[0].body) = (2, None);
s.set_mail(Some(inbox));
s.fire_event("MAIL_SHOW", vec![]);
// The list answer to `MAIL_SHOW`'s `CheckInbox` lifts the request lock (`0x4ad5d0`).
@@ -710,7 +747,7 @@ fn an_auction_invoice_renders_as_a_receipt() {
#[test]
fn a_plain_letter_keeps_its_body_and_shows_no_receipt() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_mail(Some(small_inbox()));
s.fire_event("MAIL_SHOW", vec![]);
@@ -736,7 +773,7 @@ fn the_open_letters_ring_icon_is_masked_but_the_inboxs_is_not() {
let _data = benilla_formats::wow_data_or_skip!();
use benilla_ui::script::QuadContent;
let mut s = UiScript::new().unwrap();
let mut s = vm();
load_ui(&s);
s.set_screen_size(1024.0, 768.0);
s.set_mail(Some(small_inbox()));
@@ -785,7 +822,7 @@ fn the_open_letters_ring_icon_is_masked_but_the_inboxs_is_not() {
#[test]
fn every_send_tab_box_takes_a_keystroke_not_just_the_one_with_an_onchar() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
s.set_screen_size(1024.0, 768.0);
load_ui(&s);
s.fire_event("MAIL_SHOW", vec![]);
@@ -842,7 +879,7 @@ fn every_send_tab_box_takes_a_keystroke_not_just_the_one_with_an_onchar() {
#[test]
fn the_compose_reset_clears_the_subject_and_the_attachment_together() {
let _data = benilla_formats::wow_data_or_skip!();
let mut s = UiScript::new().unwrap();
let mut s = vm();
s.set_screen_size(1024.0, 768.0);
load_ui(&s);
s.set_container(0, Some(one_linen_backpack()));
@@ -904,7 +941,7 @@ impl TextMeasure for Mono {
/// The send tab, open, its boxes measured by [`Mono`].
fn send_tab() -> UiScript {
let mut s = UiScript::new().unwrap();
let mut s = vm();
s.set_screen_size(1024.0, 768.0);
s.set_text_measurer(Box::new(Mono));
load_ui(&s);
@@ -31,6 +31,11 @@ pub struct AuctionHouseCatalog {
}
impl AuctionHouseCatalog {
/// A catalog of the given rows, for tests.
pub fn from_houses(houses: HashMap<u32, AuctionHouseInfo>) -> Self {
Self { houses }
}
/// The row for `house_id`.
pub fn get(&self, house_id: u32) -> Option<&AuctionHouseInfo> {
self.houses.get(&house_id)
+2
View File
@@ -120,6 +120,8 @@ mod stable_slot_prices;
pub use stable_slot_prices::{load_stable_slot_prices, StableSlotPrices};
mod page_text_material;
pub use page_text_material::{load_page_text_material_catalog, PageTextMaterialCatalog};
mod mail_template;
pub use mail_template::load_mail_templates;
mod packages;
pub use packages::{load_packages, PackageRow};
mod stationery;
@@ -0,0 +1,60 @@
//! `MailTemplate.dbc`: a quest's or an event's letter, by the mail template id a list row carries.
//! The store is `0xc0dab4` (`0x54a6b0`), 10 columns of `0x28` bytes: the id, the body in eight
//! locales and their flags. `GetInboxText` (`0x4af110`) indexes it by id up to the highest
//! (`[0xc0dac0]`, `0x4af223`) and reads `[row + 4 + 4 * locale]` (`0x4af249`-`0x4af24e`).
use std::collections::HashMap;
use anyhow::{Context, Result};
use benilla_dbc::{FieldType, Schema, SchemaField};
use crate::chain::Chain;
use crate::dbc::{loc_str_raw, parse, u32_at};
const MAIL_TEMPLATE: &str = "DBFilesClient\\MailTemplate.dbc";
/// The column count the loader requires.
const MAIL_TEMPLATE_FIELDS: usize = 10;
/// Load `MailTemplate.dbc`'s bodies by id, in the locale's column. A row whose body the file
/// leaves blank answers `""`, as the reference's row holds a pointer to an empty string.
pub fn load_mail_templates(chain: &mut Chain) -> Result<HashMap<u32, String>> {
let bytes = chain
.read_file(MAIL_TEMPLATE)
.context("reading MailTemplate.dbc")?;
let mut schema = Schema::new("MailTemplate");
for i in 0..MAIL_TEMPLATE_FIELDS {
let ty = if (1..=8).contains(&i) {
FieldType::String
} else {
FieldType::UInt32
};
schema.add_field(SchemaField::new(format!("F{i}"), ty));
}
let set = parse(&bytes, schema, "MailTemplate.dbc")?;
let locale = chain.locale();
Ok(set
.records()
.iter()
.filter_map(|r| Some((u32_at(r, 0)?, loc_str_raw(&set, r, 1, locale)?)))
.collect())
}
#[cfg(test)]
mod tests {
use super::*;
/// Template 87, a fishing quest's reward letter: Gubber Blump's thanks.
#[test]
fn the_shipped_templates_load_by_id() {
let data = crate::wow_data_or_skip!();
let mut chain = crate::open_chain(&data).expect("open chain");
let rows = load_mail_templates(&mut chain).expect("load MailTemplate.dbc");
let body = rows.get(&87).expect("template 87");
assert!(
body.starts_with("Hello there again. I'm Gubber Blump."),
"{body:?}"
);
assert_eq!(rows.len(), 96, "the 1.12.1 file's rows");
}
}
+2 -12
View File
@@ -35,24 +35,14 @@ pub struct StationeryCatalog {
}
impl StationeryCatalog {
/// Id 41's `Texture` in the shipped file, the fallback for an unknown id or a failed load.
pub const DEFAULT_TEXTURE: &'static str = "STATIONERYTEST";
/// A catalog of the given rows, for tests.
pub fn from_rows(rows: Vec<StationeryRow>) -> Self {
let by_id = rows.iter().map(|r| (r.id, r.texture.clone())).collect();
Self { rows, by_id }
}
/// The basename for a stationery id, or [`Self::DEFAULT_TEXTURE`] for one the table lacks.
pub fn texture(&self, id: u32) -> &str {
self.by_id
.get(&id)
.map(String::as_str)
.unwrap_or(Self::DEFAULT_TEXTURE)
}
/// The basename with no fallback, as `GetSelectedStationeryTexture` answers.
/// The basename for a stationery id, `None` for one the table lacks, as `GetInboxText` and
/// `GetSelectedStationeryTexture` answer it.
pub fn texture_of(&self, id: u32) -> Option<&str> {
self.by_id.get(&id).map(String::as_str)
}
+9 -5
View File
@@ -67,6 +67,8 @@ pub struct MailListEntry {
pub subject: String,
/// `0` = no letter body to fetch; nonzero = a [`super::item_text_query`] key.
pub item_text_id: u32,
/// The `Package.dbc` id (`[rec+0x118]`), 0 for none; vmangos always sends 0.
pub package: u32,
pub stationery: u32,
pub item: Option<MailAttachment>,
pub money: u32,
@@ -148,11 +150,12 @@ pub fn mail_delete(mailbox: u64, mail_id: u32) -> Vec<u8> {
mailbox_and_mail_id(mailbox, mail_id)
}
/// `CMSG_MAIL_CREATE_TEXT_ITEM`: mailbox, mail id and a `u32` template id, 0 for player mail.
/// Answered by a [`mail_action::MADE_PERMANENT`] result; on OK the mail's COPIED bit is set.
pub fn mail_create_text_item(mailbox: u64, mail_id: u32) -> Vec<u8> {
/// `CMSG_MAIL_CREATE_TEXT_ITEM`: mailbox, mail id and the mail's `u32` template id, 0 for none
/// (`0x4afb3f`-`0x4afb54`). Answered by a [`mail_action::MADE_PERMANENT`] result; on OK the
/// mail's COPIED bit is set.
pub fn mail_create_text_item(mailbox: u64, mail_id: u32, template_id: u32) -> Vec<u8> {
let mut body = mailbox_and_mail_id(mailbox, mail_id);
body.extend_from_slice(&0u32.to_le_bytes()); // mailTemplateId
body.extend_from_slice(&template_id.to_le_bytes());
body
}
@@ -184,7 +187,7 @@ pub(super) fn read_mail_list_result(r: &mut &[u8]) -> io::Result<Vec<MailListEnt
};
let subject = read_cstring(r)?;
let item_text_id = read_u32_le(r)?;
let _package = read_u32_le(r)?; // always 0 (vmangos hardcodes it)
let package = read_u32_le(r)?;
let stationery = read_u32_le(r)?;
let entry = read_u32_le(r)?;
let perm_enchant = read_u32_le(r)?;
@@ -216,6 +219,7 @@ pub(super) fn read_mail_list_result(r: &mut &[u8]) -> io::Result<Vec<MailListEnt
sender_id,
subject,
item_text_id,
package,
stationery,
item,
money,
@@ -80,10 +80,15 @@ impl WorldWriter {
/// `CMSG_MAIL_CREATE_TEXT_ITEM`: a permanent copy of the letter; acked with
/// [`messages::mail_action::MADE_PERMANENT`].
pub fn mail_create_text_item(&mut self, mailbox: u64, mail_id: u32) -> Result<()> {
pub fn mail_create_text_item(
&mut self,
mailbox: u64,
mail_id: u32,
template_id: u32,
) -> Result<()> {
self.send(
opcode::CMSG_MAIL_CREATE_TEXT_ITEM,
&messages::mail_create_text_item(mailbox, mail_id),
&messages::mail_create_text_item(mailbox, mail_id, template_id),
)
}
+8 -3
View File
@@ -61,13 +61,18 @@ fn mail_send_bodies_golden() {
assert_eq!(messages::mail_return_to_sender(MAILBOX, 77), golden);
assert_eq!(messages::mail_delete(MAILBOX, 77), golden);
// CMSG_MAIL_CREATE_TEXT_ITEM: the shared shape, then `u32` mailTemplateId 0 (vmangos
// `MailCreateTextItem::ReadFromWorldPacket`).
// CMSG_MAIL_CREATE_TEXT_ITEM: the shared shape, then the mail's `u32` template id
// (`0x4afb4a`; vmangos `MailCreateTextItem::ReadFromWorldPacket`).
assert_eq!(
messages::mail_create_text_item(MAILBOX, 77),
messages::mail_create_text_item(MAILBOX, 77, 0),
hx("420000000010f1004d00000000000000"),
"CMSG_MAIL_CREATE_TEXT_ITEM body"
);
assert_eq!(
messages::mail_create_text_item(MAILBOX, 77, 87),
hx("420000000010f1004d00000057000000"),
"CMSG_MAIL_CREATE_TEXT_ITEM body, a template letter"
);
// CMSG_ITEM_TEXT_QUERY: u32 textId, u32 mailId, u32 unk(0).
assert_eq!(
+3
View File
@@ -152,6 +152,9 @@ pub enum ScriptCall {
/// its packet inside the call, so a chunk's group packets go out in call order with every
/// other verb's.
Party(super::PartyRequest),
/// A mail verb past its binding's guards: its packet, and for `GetInboxText` the read mark
/// and the body's ask ([`super::MailCall`]).
Mail(super::MailCall),
}
/// The mode the four `TargetNearest*` shims hand the TAB cycler `0x493f60`, the only byte that
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -320,7 +320,8 @@ pub use macros::{
MAX_MACRO_NAME,
};
pub use mail::{
MailInboxRow, MailInvoice, MailSendRequest, MailState, PackageView, StationeryView,
MailCall, MailInboxRow, MailInvoice, MailRowVerb, MailSendRequest, MailState, PackageView,
StationeryView,
};
pub use measure::TextMeasure;
pub use merchant::{ItemStatsHead, MerchantItem, MerchantState, RepairCosts};
+6 -18
View File
@@ -940,9 +940,8 @@ pub(crate) struct Model {
pub(crate) item_text: Option<item_text::ItemTextState>,
pub(crate) item_text_close: bool,
pub(crate) item_text_page_turns: Vec<i32>,
/// The open inbox and mail calls, rows 1-based: `mail_opens` are rows `GetInboxText` read.
/// The inbox, rows 1-based.
pub(crate) mail: Option<mail::MailState>,
pub(crate) mail_check_inbox: bool,
/// `CheckInbox`'s throttle `[0xb6efc4]`, on the `GetTime` clock: the list query 60 s ago
/// plus its window, before which a check re-announces the held list instead.
pub(crate) mail_list_stamp: Option<f64>,
@@ -953,17 +952,13 @@ pub(crate) struct Model {
/// the send's result (`0x4ad159`) or the compose reset (`0x4ace02`); `SendMail` returns while
/// it is up (`0x4ae85e`).
pub(crate) mail_send_pending: bool,
pub(crate) mail_opens: Vec<u32>,
pub(crate) mail_take_items: Vec<u32>,
pub(crate) mail_take_money: Vec<u32>,
pub(crate) mail_deletes: Vec<u32>,
pub(crate) mail_returns: Vec<u32>,
pub(crate) mail_take_texts: Vec<u32>,
/// `CloseMail`, for the interaction latch's close.
pub(crate) mail_close: bool,
pub(crate) mail_send: Option<(String, String, String)>,
/// The masked body the host answered the applying `GetInboxText` call with (`0x4af203`).
pub(crate) mail_body_answer: Option<String>,
pub(crate) mail_send_money: u32,
pub(crate) mail_send_cod: u32,
/// The Send tab's attached item, resolved to its guid when the send fires.
/// The Send tab's attached item (`0xb6ef90`), whose guid the send carries.
pub(crate) mail_send_item: Option<cursor::CursorItem>,
/// The usable stationery, in the picker's order.
pub(crate) mail_stationeries: Vec<mail::StationeryView>,
@@ -1769,18 +1764,11 @@ impl Model {
item_text_close: false,
item_text_page_turns: Vec::new(),
mail: None,
mail_check_inbox: false,
mail_list_stamp: None,
mail_busy: false,
mail_send_pending: false,
mail_opens: Vec::new(),
mail_take_items: Vec::new(),
mail_take_money: Vec::new(),
mail_deletes: Vec::new(),
mail_returns: Vec::new(),
mail_take_texts: Vec::new(),
mail_close: false,
mail_send: None,
mail_body_answer: None,
mail_send_money: 0,
mail_send_cod: 0,
mail_send_item: None,
+6 -5
View File
@@ -29,7 +29,7 @@ A setting boots at the reference's default unless it is listed here (`docs/METHO
Each entry is the first sentence of a `Deviation:` comment, linking to where it lives.
- [benilla-app](#benilla-app): 240
- [benilla-app](#benilla-app): 241
- [benilla-assets](#benilla-assets): 6
- [benilla-blp](#benilla-blp): 1
- [benilla-formats](#benilla-formats): 22
@@ -387,8 +387,9 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### ui_mail
- A wrong field count is no invoice, because the reference would read the missing fields uninitialised. ([`src/ui_mail/invoice.rs:76`](../crates/benilla-app/src/ui_mail/invoice.rs#L76))
- An open mailbox also re-lists at once, past `CheckInbox`'s 60 s throttle, because a mail announced while the player stands there should show; the reference waits for the close. ([`src/ui_mail/net.rs:238`](../crates/benilla-app/src/ui_mail/net.rs#L238))
- A wrong field count is no invoice, because the reference would read the missing fields uninitialised. ([`src/ui_mail/invoice.rs:75`](../crates/benilla-app/src/ui_mail/invoice.rs#L75))
- With no usable paper the reference reads the first record of an empty list through a null pointer (`0x4ad561`-`0x4ad56d`, `mov eax,[eax]` with `eax` 0) and faults; benilla keeps the row's wire id, so the inbox still opens. ([`src/ui_mail/net.rs:167`](../crates/benilla-app/src/ui_mail/net.rs#L167))
- An open mailbox also re-lists at once, past `CheckInbox`'s 60 s throttle, because a mail announced while the player stands there should show; the reference waits for the close. ([`src/ui_mail/net.rs:342`](../crates/benilla-app/src/ui_mail/net.rs#L342))
#### ui_merchant
@@ -735,8 +736,8 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
- The handle's value is the address of a `CGxTex` (`SMemAlloc(0x54)`, `0x594a96`), which benilla cannot reproduce; each texture ranks instead by a creation stamp, one global sequence number taken when its cache key is first created and taken anew once its last region has let go of it (`super::texel::Texels`). ([`src/script/layer_batch.rs:9`](../crates/benilla-ui/src/script/layer_batch.rs#L9))
- The reference's byte copy can end inside a character and keep the stray bytes; a `String` must stay UTF-8, so the cut stops at the character boundary. ([`src/script/macros.rs:111`](../crates/benilla-ui/src/script/macros.rs#L111))
- A listing that finds no icon stays empty, to be listed again on the next ask, where the reference's dedup then reads below its null list (`0x4f0134`-`0x4f0145`) and faults. ([`src/script/macros.rs:439`](../crates/benilla-ui/src/script/macros.rs#L439))
- The client's Lua has no such bound, as nothing sets a hook (`lua_sethook`, `0x6fba40`, has no caller and no pointer to it), so a load that never ends hangs it. ([`src/script/mod.rs:877`](../crates/benilla-ui/src/script/mod.rs#L877))
- The reference sets the cells only when glue or the interface is built, `0x41ad10` from `0x46a828` (`0x46a7b0`) and `0x48fe2b` (`0x48fbf0`), and a resize reaches them only through the rebuild it asks for. ([`src/script/mod.rs:928`](../crates/benilla-ui/src/script/mod.rs#L928))
- The client's Lua has no such bound, as nothing sets a hook (`lua_sethook`, `0x6fba40`, has no caller and no pointer to it), so a load that never ends hangs it. ([`src/script/mod.rs:878`](../crates/benilla-ui/src/script/mod.rs#L878))
- The reference sets the cells only when glue or the interface is built, `0x41ad10` from `0x46a828` (`0x46a7b0`) and `0x48fe2b` (`0x48fbf0`), and a resize reaches them only through the rebuild it asks for. ([`src/script/mod.rs:929`](../crates/benilla-ui/src/script/mod.rs#L929))
- A path that does not resolve is stored, where the reference raises `Invalid model file: %s` (`0x878b44`), because the file loads asynchronously here and the call cannot know yet. ([`src/script/modelframe.rs:339`](../crates/benilla-ui/src/script/modelframe.rs#L339))
- Benilla plays no pre-rendered movie (#968), so `StartMovie` answers nil, the reference's "could not start" (`0x78d861`), which the stock `MovieFrame_PlayMovie` answers by hiding the frame and so by returning to the login screen. ([`src/script/movieframe.rs:4`](../crates/benilla-ui/src/script/movieframe.rs#L4))
- The reference's free list is FIFO; either keeps every index stable, all an addon can observe. ([`src/script/nameplate.rs:432`](../crates/benilla-ui/src/script/nameplate.rs#L432))
+1 -1
View File
@@ -109,7 +109,7 @@
- **benilla-adt** (lib.rs): combined_alpha
- **benilla-app** (lib.rs): addon_harness area area_poi area_trigger asset_churn aura_visual bindings blob_shadow bowstring camera_shake capture chat_bubble chr_classes cinematic client_state combat_log combat_text console crash creature_anim creature_type cursor cvars death debug_panel dev devtools doodad_events entities field_watch fishing_line footprints game_plugins game_tip glue_session go_anim go_templates hover_log item_watch items loading_screen local_state minimap name_persist nameplates names net no_install npc_text opaque2d perf pipe_warm player player_commands poi_marker portrait preflight probe_shield query_cache quest_markers raid_marks ranged_flex realmlist run_mode screen_fade screenshot script_calls shaders shutdown smart_rect sound spell swing_refusal target test_support text_filter textinput transport tutorial ui_action ui_auction ui_aura ui_bank ui_battlefield ui_battlefield_positions ui_battlefield_score ui_billing ui_bind_confirm ui_binder ui_cast ui_char ui_chat ui_craft ui_dialog_verbs ui_dressup ui_duel ui_follow ui_gamma ui_gm_ticket ui_gossip ui_guild ui_honor ui_inspect ui_instance ui_item_text ui_items ui_layout ui_logout ui_loot ui_loot_roll ui_macro ui_mail ui_memory ui_merchant ui_mirror ui_models ui_net ui_panes ui_party ui_pass ui_pet ui_pet_book ui_pet_stats ui_petition ui_quest ui_quest_log ui_quest_share ui_reputation ui_saved ui_script ui_session ui_shapeshift ui_social ui_spellbook ui_stable ui_summon ui_tabard ui_talent ui_talent_wipe ui_taxi ui_text ui_tooltip ui_trade ui_tradeskill ui_trainer ui_unit ui_world_map video vm_pass vplates weapon_trail world_backdrop world_state world_state_ui
- **benilla-assets** (lib.rs): adt anim_rng blp column_grid coords gpu_blp m2 materials minimap_grid model spatial_cache terrain tex_filter trace wdt wmo world_assets
- **benilla-formats** (lib.rs): anim_data area_poi area_sound area_table area_trigger auction_house bank_bag_slot_prices camera_shakes cfg_categories cfg_configs chain characters chat_channels chr_classes chr_races cinematics creature_families creature_sound creature_spell_data creature_types creatures dbc death_thud durability elevators emit_timing emote_text emotes environmental_damage exhaustion factions footsteps game_tips gameobjects garble gm_survey gm_ticket_category ground_effects install item_random_properties item_sounds item_visuals itembagfamily itemclass items itemsets itemsubclass languages lfg_dungeons light liquid loading_screen locale locale_routing lock lock_type loose macro_icons maps material minimap_translate models npc_greeting packages page_text_material particles pet_stats quest_headers quest_info race_creature_type race_pvp_team race_sound resistances ribbons server_messages sheathe skill_lines skill_tiers sound_entries sound_provider sound_water spell_focus spell_mechanic spell_visual spells stable_slot_prices stationery talents taxi taxi_nodes taxi_path terrain text_filter_lists tga transport_period transports unit_blood value_track vocal_ui_sounds wdl weapon_impact weapon_swing wmo_area world_map_area world_map_continent world_map_overlay world_state_ui wow_ini zone_map
- **benilla-formats** (lib.rs): anim_data area_poi area_sound area_table area_trigger auction_house bank_bag_slot_prices camera_shakes cfg_categories cfg_configs chain characters chat_channels chr_classes chr_races cinematics creature_families creature_sound creature_spell_data creature_types creatures dbc death_thud durability elevators emit_timing emote_text emotes environmental_damage exhaustion factions footsteps game_tips gameobjects garble gm_survey gm_ticket_category ground_effects install item_random_properties item_sounds item_visuals itembagfamily itemclass items itemsets itemsubclass languages lfg_dungeons light liquid loading_screen locale locale_routing lock lock_type loose macro_icons mail_template maps material minimap_translate models npc_greeting packages page_text_material particles pet_stats quest_headers quest_info race_creature_type race_pvp_team race_sound resistances ribbons server_messages sheathe skill_lines skill_tiers sound_entries sound_provider sound_water spell_focus spell_mechanic spell_visual spells stable_slot_prices stationery talents taxi taxi_nodes taxi_path terrain text_filter_lists tga transport_period transports unit_blood value_track vocal_ui_sounds wdl weapon_impact weapon_swing wmo_area world_map_area world_map_continent world_map_overlay world_state_ui wow_ini zone_map
- **benilla-lua** (lib.rs): api cfmt compile heap lex lib_base lib_math lib_string lib_table number parse pools proto reload table value vm
- **benilla-m2** (lib.rs): error model skin tests track
- **benilla-mlua** (lib.rs): conv error