diff --git a/.gitattributes b/.gitattributes
index aedd42bd1..c543aee43 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -7,3 +7,6 @@ reference/*.tsv -text
# The vendored kira tree is CRLF in the index and stays byte for byte.
third_party/kira/** -text
+
+# The vendored wgpu-hal tree is the registry crate byte for byte (one CRLF file stays CRLF).
+third_party/wgpu-hal/** -text
diff --git a/Cargo.lock b/Cargo.lock
index 0a5042526..4ca9196b5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -585,6 +585,7 @@ dependencies = [
"avian3d",
"benilla-assets",
"benilla-formats",
+ "benilla-movie",
"benilla-protocol",
"benilla-srp",
"benilla-ui",
@@ -702,6 +703,14 @@ dependencies = [
"benilla-lua",
]
+[[package]]
+name = "benilla-movie"
+version = "0.3.0"
+dependencies = [
+ "benilla-bytes",
+ "benilla-formats",
+]
+
[[package]]
name = "benilla-mpq"
version = "0.3.0"
@@ -718,6 +727,7 @@ dependencies = [
"benilla-srp",
"clap",
"flate2",
+ "libc",
"num-bigint",
"rand 0.8.6",
"sha1",
@@ -738,6 +748,8 @@ name = "benilla-ui"
version = "0.3.0"
dependencies = [
"benilla-mlua",
+ "benilla-movie",
+ "libc",
"roxmltree",
]
@@ -8024,8 +8036,6 @@ dependencies = [
[[package]]
name = "wgpu-hal"
version = "27.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b21cb61c57ee198bc4aff71aeadff4cbb80b927beb912506af9c780d64313ce"
dependencies = [
"android_system_properties",
"arrayvec",
diff --git a/Cargo.toml b/Cargo.toml
index 4d05f0d1d..3aa66f9a2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -42,6 +42,9 @@ kira = { path = "third_party/kira" }
# A lock-only stand-in: bevy_audio's unbuilt cpal 0.15 would otherwise hold `alsa-sys` 0.3 against
# cpal 0.17's 0.4, and a lock holds one `links = "alsa"` (`third_party/alsa-0.9/BENILLA.md`).
alsa = { path = "third_party/alsa-0.9" }
+# wgpu-hal 27.0.4, patched so a presentation stall past wgpu-core's 1 s frame timeout is waited out
+# and not turned into a lost device (`third_party/wgpu-hal/BENILLA.md`).
+wgpu-hal = { path = "third_party/wgpu-hal" }
# Dependencies at opt-level 3 in dev: at opt-level 0, avian/parry collision drops a run to <1 fps.
[profile.dev.package."*"]
@@ -51,6 +54,11 @@ opt-level = 3
# build is no slower.
codegen-units = 1
+# The movie decoder at opt-level 3 in dev as well: at 1, decoding the 1024-wide intro takes its
+# install test 29 s, at 3 under 6 s.
+[profile.dev.package.benilla-movie]
+opt-level = 3
+
# Our crates at opt-level 1: Bevy's generic hot paths monomorphize into them, and at opt-level 0
# Stormwind drops from a pinned 60 fps to ~45.
[profile.dev]
diff --git a/crates/benilla-app/Cargo.toml b/crates/benilla-app/Cargo.toml
index d62b44efb..06b3f299a 100644
--- a/crates/benilla-app/Cargo.toml
+++ b/crates/benilla-app/Cargo.toml
@@ -125,6 +125,8 @@ windows-sys = { version = "0.59", features = [
# The login cycle's fake realmd runs the server half of SRP6 (`net::io::cycle_tests`).
[dev-dependencies]
benilla-srp = { path = "../benilla-srp" }
+# The synthetic movie the movie screen's tests open.
+benilla-movie = { path = "../benilla-movie", features = ["test-support"] }
# The UI's geometry comparisons (`benilla_ui::assert_near!`).
benilla-ui = { path = "../benilla-ui", features = ["test-support"] }
# The schedule census keeps the build's own graph, sync points included, through a build pass,
diff --git a/crates/benilla-app/assets/ui/OptionsFrame.xml b/crates/benilla-app/assets/ui/OptionsFrame.xml
index 507296efd..7737b7c48 100644
--- a/crates/benilla-app/assets/ui/OptionsFrame.xml
+++ b/crates/benilla-app/assets/ui/OptionsFrame.xml
@@ -1628,9 +1628,6 @@
BenillaOptionsRow_OnLoad(this, "BlockTrades", "Block Trades",
"OPTION_TOOLTIP_BLOCK_TRADES")
-
diff --git a/crates/benilla-app/examples/extended_launcher.rs b/crates/benilla-app/examples/extended_launcher.rs
index ab09473af..15214e7e1 100644
--- a/crates/benilla-app/examples/extended_launcher.rs
+++ b/crates/benilla-app/examples/extended_launcher.rs
@@ -29,11 +29,13 @@
//! benilla-buildstamp = { git = "https://github.com/samwhosung/benilla" }
//!
//! # Cargo reads `[patch]` and `[profile]` from the root manifest only, so benilla's are repeated:
-//! # without the kira patch the mixer is not benilla's, and without the alsa one the lock holds two
-//! # `alsa-sys` and does not resolve.
+//! # without the kira patch the mixer is not benilla's, without the alsa one the lock holds two
+//! # `alsa-sys` and does not resolve, and without the wgpu-hal one a presentation stall past a
+//! # second loses the device on Vulkan.
//! [patch.crates-io]
//! kira = { git = "https://github.com/samwhosung/benilla" }
//! alsa = { git = "https://github.com/samwhosung/benilla" }
+//! wgpu-hal = { git = "https://github.com/samwhosung/benilla" }
//!
//! [profile.dev]
//! opt-level = 1
diff --git a/crates/benilla-app/src/addon_harness/mod.rs b/crates/benilla-app/src/addon_harness/mod.rs
index 0732d2a23..2a409bda9 100644
--- a/crates/benilla-app/src/addon_harness/mod.rs
+++ b/crates/benilla-app/src/addon_harness/mod.rs
@@ -1099,6 +1099,9 @@ fn global_strings() -> Option<&'static str> {
/// Every seat below is a state an in-world character is always in, kept minimal and ordinary: a VM
/// answering nil or zero there would fail addons on a state the 1.12 client cannot be in.
fn seat_a_session(script: &mut UiScript) {
+ // No engine behind it: a verb's call is kept, not refused (stock `RaidFrame_OnEvent` asks
+ // `RequestRaidInfo()` on `PLAYER_ENTERING_WORLD`, `RaidFrame.lua:28-29`).
+ script.keep_calls();
// The 1.12 client boots FrameXML with this file first; so does our app.
if let Some(src) = global_strings() {
let _ = script.run(src);
@@ -1154,8 +1157,9 @@ fn seat_a_session(script: &mut UiScript) {
// `UnitFactionGroup("player")`: every playable race has a side, and AceDB-2.0
// concatenates it into its per-realm key at file scope.
faction_group: Some("Alliance".into()),
- // `0x5efe00`'s team digit for Human (race 1), the rank-title key's second `%d`.
- pvp_team: crate::ui_unit::race_pvp_team(1),
+ // `0x5efe00`'s team digit for Human (race 1), the rank-title key's second `%d`: the
+ // stock row's template has group mask 3, Alliance.
+ pvp_team: 1,
..Default::default()
}),
);
@@ -1313,7 +1317,7 @@ fn seat_a_session(script: &mut UiScript) {
// The talent tree (`Talent.dbc` x `TalentTab.dbc`), read by position at file scope
// (`KTM_Data.lua:376`). Zero ranks and the full pool, a fresh 60 (51 points, `level - 9`), so a
// rank is a number rather than nil.
- if let Some(state) = talent_snapshot(script) {
+ if let Some(state) = talent_snapshot() {
script.set_talents(state);
}
}
@@ -1342,9 +1346,8 @@ fn auction_item_classes() -> Vec {
}
/// The seated character's talent pages, built by the live client's `build_pages`. The DBCs are read
-/// once per process; the pages are built per VM, since the requirement lines come from that VM's
-/// `GlobalStrings.lua`. `None` with no install.
-fn talent_snapshot(script: &UiScript) -> Option {
+/// once per process; the pages are built per VM. `None` with no install.
+fn talent_snapshot() -> Option {
use std::sync::OnceLock;
#[allow(clippy::type_complexity)]
static DBCS: OnceLock<
@@ -1362,14 +1365,6 @@ fn talent_snapshot(script: &UiScript) -> Option(key)
- .ok()
- .filter(|t| !t.is_empty())
- };
// Human (`ChrRaces.dbc` 1) warrior (`ChrClasses.dbc` 1), the character `seat_a_session` seats.
Some(crate::ui_talent::build_pages(
talents,
@@ -1378,7 +1373,6 @@ fn talent_snapshot(script: &UiScript) -> Option,
}
/// One resolve's compare inputs.
@@ -102,21 +105,48 @@ fn elect_event(cache: &ZoneCache, next: &ZoneSignal) -> Option<&'static str> {
}
/// Resolves the texts and PvP info, pushes the zone caches, then fires the elected zone event and,
-/// independently, `MINIMAP_ZONE_CHANGED`.
+/// independently, `MINIMAP_ZONE_CHANGED`. The poll `0x5db900` counts every tick in `ticks`
+/// (`0xc4d790`), which nothing resets, and reports only on the tenth, subtracting ten (`0x5db906`,
+/// `0x5db917`); the other nine return at once. It reports the active mover's position, else the
+/// active player's, and nothing with neither held (`0x5db937`, `0x5db956`, `0x5db95d`): after a
+/// worldport frees every object, the commit waits for our player's create. It runs on the tick
+/// after the tick's packets (category 6's drain `0x403620`, then category 5's `0x401ec0`), so it
+/// reads what the unit feed pushed of a player that arrived this frame.
+#[allow(clippy::too_many_arguments)] // a Bevy system's full input set
fn feed_zone_events(
+ mut ticks: Local,
mut hosted_vm: crate::script_calls::HostedVm,
+ me: Query<(), (With, With)>,
world: benilla_world::world_point::WorldPoint,
areas: Option>,
factions: Option>,
- self_store: Query<&ObjectStore, With>,
realm_pvp: Option>,
mut cache: Local>,
) {
+ *ticks += 1;
+ let due = *ticks >= 10;
+ if due {
+ *ticks -= 10;
+ }
hosted_vm.run(|script| {
- let (Some(script), Some(areas)) = (script, areas) else {
+ let Some(script) = script else {
return;
};
let cache = cache.get(script);
+ let realm_pvp = realm_pvp.is_some_and(|r| r.0);
+ if cache.realm_pvp != Some(realm_pvp) {
+ cache.realm_pvp = Some(realm_pvp);
+ script.set_realm_pvp(realm_pvp);
+ }
+ if !due {
+ return;
+ }
+ let Some(areas) = areas else {
+ return;
+ };
+ if me.is_empty() {
+ return;
+ }
let Some(leaf) = world.area() else { return };
let Some(leaf_row) = areas.0.get(leaf) else {
// An unknown id keeps the last state, as the resolver does for areaId 0.
@@ -165,7 +195,7 @@ fn feed_zone_events(
}
});
if let Some(a) = a_name.filter(|n| !n.is_empty()) {
- if a != subzone_text {
+ if whole_wmo_name_takes_the_zone(&a, &subzone_text) {
zone_text = a;
subzone_text = String::new();
}
@@ -197,39 +227,19 @@ fn feed_zone_events(
return;
}
- let zone_row = areas.0.get(zone);
- let template = factions
- .as_ref()
- .zip(self_store.single().ok())
- .and_then(|(f, store)| f.catalog().template(store.0.unit_faction_template()?))
- .map(|t| (t.friend_group_mask, t.enemy_group_mask));
- let realm_pvp = realm_pvp.is_some_and(|r| r.0);
- let (ty, is_arena) = zone_pvp_info(realm_pvp, leaf_row, zone_row, template);
- // factionName is FactionGroup.dbc's Name for the zone's mask bit.
- let pvp = ty.map(|ty| {
- let mask = zone_row.map_or(0, |r| r.faction_group_mask);
- let name = factions
- .as_ref()
- .and_then(|f| f.catalog().faction_group_name(mask))
- .unwrap_or("");
- (ty, name)
- });
- let pvp_type = pvp.map_or("", |(ty, _)| ty);
-
script.set_zone_texts(benilla_ui::script::ZoneTexts {
zone: signal.zone_text.clone(),
real_zone: real_zone_text,
subzone: signal.subzone_text.clone(),
minimap: minimap_text.clone(),
- pvp_type: pvp.map(|(ty, _)| ty.to_string()),
- pvp_faction: pvp_faction_text(pvp),
- is_arena,
+ pvp_zone: zone_pvp(areas.0.get(zone), factions.as_deref()),
+ is_arena: leaf_row.flags & 0x80 != 0,
});
if let Some(event) = event {
script.fire_event(event, vec![]);
debug!(
- "area: {event} → zone {:?} / sub {:?} ({pvp_type})",
+ "area: {event} → zone {:?} / sub {:?}",
signal.zone_text, signal.subzone_text
);
}
@@ -246,40 +256,24 @@ fn feed_zone_events(
})
}
-/// `GetZonePVPInfo`'s second value: with a type answered, the faction name is always a string,
-/// starting as the empty string (`0x48d633`, `0x882748`) and pushed by `lua_pushstring`
-/// (`0x48d68f`) whether or not a FactionGroup row supplied one; only the bail (`0x48d6b5`) pushes
-/// nil.
-fn pvp_faction_text(pvp: Option<(&str, &str)>) -> Option {
- pvp.map(|(_, faction)| faction.to_string())
-}
-
-/// `GetZonePVPInfo` (`0x48d540`): `(pvpType, isArena)`. isArena is the leaf's Flags `0x80`, read
-/// before any bail. The type is nil with no zone row, no faction template, or the display gate
-/// closed: it opens on a PvP realm ([`RealmPvp`]) or in a zone whose Flags carry `0x10`, the six
-/// capitals (`0x48d5c2`/`0x48d5cc`). Open, it is the zone's FactionGroupMask against the template's
-/// `(friend, enemy)` masks, "contested" when neither, never "arena".
-fn zone_pvp_info(
- realm_pvp: bool,
- leaf: &AreaTableRow,
+/// What `GetZonePVPInfo` (`0x48d540`) reads of the committed zone's row `zone`: the capital bit
+/// (Flags `0x10`, `0x48d5cc`), the `FactionGroupMask` (`+0x50`) and the faction name,
+/// `FactionGroup.dbc`'s for the mask, `""` when no row names one (`0x48d633`). `None` with no row
+/// (`0x48d5b4`).
+fn zone_pvp(
zone: Option<&AreaTableRow>,
- template: Option<(u32, u32)>,
-) -> (Option<&'static str>, bool) {
- let is_arena = leaf.flags & 0x80 != 0;
- let ty = zone
- .filter(|z| realm_pvp || z.flags & 0x10 != 0)
- .zip(template)
- .map(|(z, (friend, enemy))| {
- let mask = z.faction_group_mask;
- if mask & friend != 0 {
- "friendly"
- } else if mask & enemy != 0 {
- "hostile"
- } else {
- "contested"
- }
- });
- (ty, is_arena)
+ factions: Option<&Factions>,
+) -> Option {
+ let zone = zone?;
+ let mask = zone.faction_group_mask;
+ Some(benilla_ui::script::ZonePvp {
+ capital: zone.flags & 0x10 != 0,
+ faction_group_mask: mask,
+ faction_name: factions
+ .and_then(|f| f.catalog().faction_group_name(mask))
+ .unwrap_or("")
+ .to_string(),
+ })
}
/// `[0x88272c]`, the realm's PvP flag the display gate reads: the selected realm's
@@ -307,6 +301,12 @@ fn latched_realm_pvp(previous: bool, row_pvp: Option) -> bool {
row_pvp.unwrap_or(previous)
}
+/// Indoors the whole-WMO row's name replaces the zone text, and clears the subzone, only when it
+/// differs from the subzone text, ASCII case folded (`SStrCmpI` at `0x67e6e4`).
+fn whole_wmo_name_takes_the_zone(name: &str, subzone: &str) -> bool {
+ !name.eq_ignore_ascii_case(subzone)
+}
+
/// The shared area catalog and the zone-event feed.
pub(crate) struct AreaPlugin;
@@ -322,9 +322,10 @@ impl Plugin for AreaPlugin {
Update,
// After the leaf authority: leaf, indoor bit and names must come from one frame,
// as in the client's single-pass resolve (`0x67e510`), or a stale leaf fires a
- // spurious splash.
+ // spurious splash. After the unit feed too, by the sets: the commit's handlers read
+ // our template as the frame's packets left it.
feed_zone_events
- .after(crate::ui_script::UiInput)
+ .after(crate::ui_script::UiTick)
.after(benilla_world::terrain_stream::AreaAuthoritySet),
);
}
@@ -406,75 +407,22 @@ mod tests {
}
}
- /// An Alliance player's template: friend Alliance (2), enemy Horde (4).
- const ALLIANCE: Option<(u32, u32)> = Some((2, 4));
-
- /// The display gate (`0x48d5c2`/`0x48d5cc`): a PvE realm outside a capital gets no type; a
- /// capital's Flags `0x10` opens it there, and a PvP realm opens it everywhere.
+ /// The zone's row as the getter reads it: the capital bit, the mask and its faction name,
+ /// `""` for a mask no `FactionGroup` row names; no row, nothing to read.
#[test]
- fn the_pvp_type_shows_on_a_pvp_realm_or_in_a_capital() {
- let elwynn = row(0x40, 2);
- let stormwind = row(0x138, 2);
+ fn the_commit_pushes_the_zones_capital_bit_mask_and_faction_name() {
let orgrimmar = row(0x138, 4);
let stranglethorn = row(0x40, 0);
- let pvp =
- |realm_pvp, zone: &AreaTableRow| zone_pvp_info(realm_pvp, zone, Some(zone), ALLIANCE).0;
-
- assert_eq!(pvp(false, &elwynn), None, "PvE realm, outside a capital");
assert_eq!(
- pvp(false, &stranglethorn),
- None,
- "PvE realm, ownerless zone"
- );
- assert_eq!(
- pvp(false, &stormwind),
- Some("friendly"),
- "PvE realm, own capital"
- );
- assert_eq!(
- pvp(false, &orgrimmar),
- Some("hostile"),
- "PvE realm, enemy capital"
- );
-
- assert_eq!(pvp(true, &elwynn), Some("friendly"));
- assert_eq!(pvp(true, &stranglethorn), Some("contested"));
- assert_eq!(pvp(true, &orgrimmar), Some("hostile"));
- }
-
- /// An answered type always carries a faction string, `""` in an ownerless zone such as
- /// Stranglethorn Vale (`0x48d633`); no type, no string (`0x48d6b5`).
- #[test]
- fn an_answered_type_carries_an_empty_faction_name_not_nil() {
- assert_eq!(
- pvp_faction_text(Some(("contested", ""))),
- Some(String::new())
- );
- assert_eq!(
- pvp_faction_text(Some(("friendly", "Alliance"))),
- Some("Alliance".to_string())
- );
- assert_eq!(pvp_faction_text(None), None);
- }
-
- /// isArena is the leaf's `0x80`, read before any bail, so a closed gate keeps it.
- #[test]
- fn is_arena_survives_a_closed_gate() {
- let battle_ring = row(0xd0, 0);
- let stranglethorn = row(0x40, 0);
- assert_eq!(
- zone_pvp_info(false, &battle_ring, Some(&stranglethorn), ALLIANCE),
- (None, true)
- );
- assert_eq!(
- zone_pvp_info(true, &battle_ring, Some(&stranglethorn), ALLIANCE),
- (Some("contested"), true)
- );
- assert_eq!(
- zone_pvp_info(true, &battle_ring, Some(&stranglethorn), None),
- (None, true),
- "no faction template"
+ zone_pvp(Some(&orgrimmar), None),
+ Some(benilla_ui::script::ZonePvp {
+ capital: true,
+ faction_group_mask: 4,
+ faction_name: String::new(),
+ })
);
+ assert!(!zone_pvp(Some(&stranglethorn), None).unwrap().capital);
+ assert_eq!(zone_pvp(None, None), None);
}
/// A realm type with no row keeps what the last world entry stored.
@@ -486,15 +434,6 @@ mod tests {
assert!(latched_realm_pvp(false, Some(true)));
}
- /// No zone row is a bail, not an ownerless zone.
- #[test]
- fn a_missing_zone_row_has_no_pvp_type() {
- assert_eq!(
- zone_pvp_info(true, &row(0, 0), None, ALLIANCE),
- (None, false)
- );
- }
-
/// On the install's AreaTable the gate opens in exactly the six capitals for a PvE realm.
#[test]
fn the_six_capitals_are_the_zones_a_pve_realm_colours() {
@@ -503,9 +442,8 @@ mod tests {
let cat = benilla_formats::load_area_table_catalog(&mut chain).expect("AreaTable");
let open: Vec = (0..=u32::from(u16::MAX))
.filter(|&id| {
- cat.get(id).is_some_and(|r| {
- r.zone_id == 0 && zone_pvp_info(false, r, Some(r), ALLIANCE).0.is_some()
- })
+ cat.get(id)
+ .is_some_and(|r| r.zone_id == 0 && zone_pvp(Some(r), None).unwrap().capital)
})
.collect();
assert_eq!(open, [1497, 1519, 1537, 1637, 1638, 1657]);
@@ -544,4 +482,235 @@ mod tests {
"no named group rows — query B leaves the nulled subzone alone"
);
}
+
+ /// `GetZonePVPInfo` (`0x48d540`) reads, at the call, the zone the last commit stored
+ /// (`0xb4e314`) and the active player's faction template (`0x48d5b4`-`0x48d5fe`): a capital
+ /// entered before our template arrives answers once it is there, with no zone change between,
+ /// and the type follows a template that changes.
+ #[test]
+ fn the_zone_pvp_type_reads_our_template_at_the_call() {
+ use crate::net::{Guid, GuidIndex, NetCommands, ObjectStore, SelfGuid, SelfPlayer};
+ use crate::target::relations::fixture::{factions, HUMAN, ORC};
+ use benilla_protocol::messages::ObjectType;
+ use benilla_protocol::ObjectFields;
+ use benilla_ui::script::UiScript;
+ const ME: u64 = 0x7;
+ const ORGRIMMAR: u32 = 1637;
+ /// `UNIT_FIELD_FACTIONTEMPLATE`.
+ const TEMPLATE: u16 = 35;
+
+ let mut app = crate::game_plugins::schedule_tests::headless_client_unrun();
+ let world = app.world_mut();
+ benilla_world::world_point::init_world_point_resources(world);
+ let (tx, _rx) = crossbeam_channel::unbounded();
+ world.insert_resource(NetCommands(tx));
+ world.resource_mut::().0 = Some(ME);
+ world.insert_resource(factions());
+ world.insert_resource(AreaTableRes(AreaTableCatalog::from_rows(vec![(
+ ORGRIMMAR,
+ AreaTableRow {
+ name: "Orgrimmar".into(),
+ ..row(0x138, 4)
+ },
+ )])));
+ world.insert_resource(benilla_world::terrain_stream::CurrentArea(Some(ORGRIMMAR)));
+ world.insert_non_send_resource(UiScript::new().unwrap());
+ let store = |template: Option| {
+ let pairs: Vec<(u16, u32)> = template.map(|t| (TEMPLATE, t)).into_iter().collect();
+ ObjectStore(ObjectFields::from_pairs(&pairs).into_created(ObjectType::Player))
+ };
+ let me = world.spawn((SelfPlayer, Guid(ME), store(None))).id();
+ world.resource_mut::().0.insert(ME, me);
+ let pvp = |app: &mut App| {
+ let world = app.world_mut();
+ crate::ui_unit::run_feed_units_once(world);
+ // The poll's tenth tick (`0x5db906`).
+ for _ in 0..10 {
+ world.run_system_cached(feed_zone_events).unwrap();
+ }
+ world
+ .non_send_resource::()
+ .eval::<(Option, Option)>(
+ "local t, f = GetZonePVPInfo() return t, f",
+ )
+ .unwrap()
+ };
+ assert_eq!(pvp(&mut app), (None, None), "no template: nil");
+ app.world_mut().entity_mut(me).insert(store(Some(ORC)));
+ assert_eq!(pvp(&mut app).0.as_deref(), Some("friendly"));
+ app.world_mut().entity_mut(me).insert(store(Some(HUMAN)));
+ assert_eq!(pvp(&mut app).0.as_deref(), Some("hostile"));
+ }
+
+ /// A worldport frees our player with every object (`0x467700`) and its create comes after the
+ /// load. The zone poll reports only the active mover's, else the active player's, position
+ /// (`0x5db937`, `0x5db956`), and runs on the tick's category 5 after the category 6 packet
+ /// drain (`0x401ec0`, `0x403620`), so the commit `0x494780` waits for our player and follows
+ /// its arrival. A capital entered on a PvE realm answers its type inside the new area's event.
+ #[test]
+ fn a_worldport_commits_the_zone_once_our_player_is_back() {
+ use crate::net::{Guid, GuidIndex, NetCommands, ObjectStore, SelfGuid, SelfPlayer};
+ use crate::target::relations::fixture::{factions, ORC};
+ use benilla_protocol::messages::ObjectType;
+ use benilla_protocol::ObjectFields;
+ use benilla_ui::script::UiScript;
+ const ME: u64 = 0x7;
+ const ORGRIMMAR: u32 = 1637;
+ /// `UNIT_FIELD_FACTIONTEMPLATE`.
+ const TEMPLATE: u16 = 35;
+
+ let mut app = crate::game_plugins::schedule_tests::headless_client_unrun();
+ let world = app.world_mut();
+ benilla_world::world_point::init_world_point_resources(world);
+ let (tx, _rx) = crossbeam_channel::unbounded();
+ world.insert_resource(NetCommands(tx));
+ world.resource_mut::().0 = Some(ME);
+ world.insert_resource(factions());
+ world.insert_resource(AreaTableRes(AreaTableCatalog::from_rows(vec![(
+ ORGRIMMAR,
+ AreaTableRow {
+ name: "Orgrimmar".into(),
+ ..row(0x138, 4)
+ },
+ )])));
+ // The body is at the port's destination before our player's create arrives.
+ world.insert_resource(benilla_world::terrain_stream::CurrentArea(Some(ORGRIMMAR)));
+ let script = UiScript::new().unwrap();
+ script
+ .run(
+ r#"
+ Seen = {}
+ local f = CreateFrame("Frame")
+ f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
+ f:SetScript("OnEvent", function()
+ table.insert(Seen, tostring((GetZonePVPInfo())))
+ end)
+ "#,
+ )
+ .unwrap();
+ world.insert_non_send_resource(script);
+ let frame = |app: &mut App| {
+ let world = app.world_mut();
+ crate::ui_unit::run_feed_units_once(world);
+ // The poll's tenth tick (`0x5db906`).
+ for _ in 0..10 {
+ world.run_system_cached(feed_zone_events).unwrap();
+ }
+ let s = world.non_send_resource::();
+ let seen = s.eval::>("return Seen").unwrap();
+ s.run("Seen = {}").unwrap();
+ seen
+ };
+ assert_eq!(
+ frame(&mut app),
+ Vec::::new(),
+ "no player, no commit"
+ );
+ let store = ObjectStore(
+ ObjectFields::from_pairs(&[(TEMPLATE, ORC)]).into_created(ObjectType::Player),
+ );
+ let me = app.world_mut().spawn((SelfPlayer, Guid(ME), store)).id();
+ app.world_mut().resource_mut::().0.insert(ME, me);
+ assert_eq!(frame(&mut app), ["friendly"]);
+ }
+
+ /// The commit reads what the unit feed pushed of a player that arrived this frame.
+ #[test]
+ fn the_zone_commit_runs_after_the_unit_feed() {
+ let mut app = crate::game_plugins::schedule_tests::headless_client();
+ assert!(crate::ui_unit::feed_units_runs_before(
+ &mut app,
+ feed_zone_events
+ ));
+ }
+
+ /// The poll `0x5db900` counts its calls (`0xc4d790`) and reports the area only on the tenth
+ /// (`0x5db906`, `jl 0x5db975`), subtracting ten (`0x5db917`): the first commit lands on the
+ /// tenth tick, and a subzone crossed and recrossed between two polls signals nothing.
+ #[test]
+ fn the_area_commits_on_every_tenth_tick() {
+ use crate::net::{Guid, GuidIndex, ObjectStore, SelfGuid, SelfPlayer};
+ use benilla_protocol::messages::ObjectType;
+ use benilla_ui::script::UiScript;
+ use benilla_world::terrain_stream::CurrentArea;
+ const ME: u64 = 0x7;
+ const ELWYNN: u32 = 12;
+ const GOLDSHIRE: u32 = 87;
+
+ let mut app = crate::game_plugins::schedule_tests::headless_client_unrun();
+ let world = app.world_mut();
+ benilla_world::world_point::init_world_point_resources(world);
+ world.resource_mut::().0 = Some(ME);
+ world.insert_resource(AreaTableRes(AreaTableCatalog::from_rows(vec![
+ (
+ ELWYNN,
+ AreaTableRow {
+ name: "Elwynn Forest".into(),
+ ..row(0, 0)
+ },
+ ),
+ (
+ GOLDSHIRE,
+ AreaTableRow {
+ name: "Goldshire".into(),
+ zone_id: ELWYNN,
+ ..row(0, 0)
+ },
+ ),
+ ])));
+ world.insert_resource(CurrentArea(Some(ELWYNN)));
+ let script = UiScript::new().unwrap();
+ script
+ .run(
+ r#"
+ Seen = {}
+ local f = CreateFrame("Frame")
+ f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
+ f:RegisterEvent("ZONE_CHANGED")
+ f:SetScript("OnEvent", function() table.insert(Seen, event) end)
+ "#,
+ )
+ .unwrap();
+ world.insert_non_send_resource(script);
+ let store = ObjectStore(ObjectFields::from_pairs(&[]).into_created(ObjectType::Player));
+ let me = world.spawn((SelfPlayer, Guid(ME), store)).id();
+ world.resource_mut::().0.insert(ME, me);
+ let ticks = |app: &mut App, area: u32, n: usize| {
+ let world = app.world_mut();
+ world.insert_resource(CurrentArea(Some(area)));
+ for _ in 0..n {
+ world.run_system_cached(feed_zone_events).unwrap();
+ }
+ let s = world.non_send_resource::();
+ let seen = s.eval::>("return Seen").unwrap();
+ s.run("Seen = {}").unwrap();
+ seen
+ };
+ use benilla_protocol::ObjectFields;
+ assert!(ticks(&mut app, ELWYNN, 9).is_empty(), "nine ticks return");
+ assert_eq!(ticks(&mut app, ELWYNN, 1), ["ZONE_CHANGED_NEW_AREA"]);
+ assert!(ticks(&mut app, GOLDSHIRE, 3).is_empty());
+ assert!(
+ ticks(&mut app, ELWYNN, 7).is_empty(),
+ "Goldshire left before the next poll"
+ );
+ assert!(ticks(&mut app, GOLDSHIRE, 9).is_empty());
+ assert_eq!(ticks(&mut app, GOLDSHIRE, 1), ["ZONE_CHANGED"]);
+ }
+
+ /// `0x67e6e4` compares the whole-WMO name with the subzone by `SStrCmpI` (`0x64a4c0`, limit
+ /// `0x7fffffff`): a name that differs only in case keeps both texts.
+ #[test]
+ fn the_whole_wmo_name_compares_without_case() {
+ assert!(!whole_wmo_name_takes_the_zone(
+ "The Great Forge",
+ "the great forge"
+ ));
+ assert!(!whole_wmo_name_takes_the_zone("Ironforge", "Ironforge"));
+ assert!(whole_wmo_name_takes_the_zone(
+ "Ironforge",
+ "The Great Forge"
+ ));
+ assert!(whole_wmo_name_takes_the_zone("Ironforge", ""));
+ }
}
diff --git a/crates/benilla-app/src/bindings.rs b/crates/benilla-app/src/bindings.rs
index 2594f9f8d..ef604bb93 100644
--- a/crates/benilla-app/src/bindings.rs
+++ b/crates/benilla-app/src/bindings.rs
@@ -88,6 +88,8 @@ pub(crate) struct BindingsState {
fired: Vec,
/// Amount per one-shot this frame: a zoom's yards, else 1.0.
amounts: Vec<(Input, f32)>,
+ /// This frame's `MoveView*` calls in call order, `(axis, start)`, for the camera's axes.
+ view_calls: Vec<(script_input::ViewAxis, bool)>,
/// The keys we believe are down: a press of one is a repeat. The reference classifies
/// auto-repeat off its own list (`0x4248b3`), never the Win32 `lParam` repeat bit.
/// Normalized like [`latched`](Self::latched) and reconciled against `ButtonInput` every
@@ -157,6 +159,16 @@ impl BindingsState {
pub(crate) fn fired(&self, i: Input) -> bool {
self.fired.contains(&i)
}
+ /// Fire the one-shot `i` this frame, as a body's Lua call would.
+ #[cfg(test)]
+ pub(crate) fn fire_for_test(&mut self, i: Input) {
+ self.fired.push(i);
+ }
+ /// End the frame's one-shots.
+ #[cfg(test)]
+ pub(crate) fn clear_for_test(&mut self) {
+ self.fired.clear();
+ }
/// Total amount for a one-shot this frame (0.0 when idle): the camera zoom's yards.
pub(crate) fn amount(&self, i: Input) -> f32 {
self.amounts
@@ -165,6 +177,10 @@ impl BindingsState {
.map(|&(_, v)| v)
.sum()
}
+ /// This frame's `MoveView*` calls in call order, `(axis, start)`.
+ pub(crate) fn view_calls(&self) -> &[(script_input::ViewAxis, bool)] {
+ &self.view_calls
+ }
/// Both mouse bits held by their Lua Starts, the both-button run: MOVEANDSTEER's body
/// (`Bindings.xml:3-11`) runs `CameraOrSelectOrMoveStart` and `TurnOrActionStart`.
pub(crate) fn steering(&self) -> bool {
@@ -452,6 +468,7 @@ fn latch_and_dispatch(
state.just.clear();
state.fired.clear();
state.amounts.clear();
+ state.view_calls.clear();
// Deviation: latches die with the VM that made them, because a latch names a command of that
// VM's table and releasing it against a new one would run another load's up-half. The
@@ -1631,7 +1648,7 @@ mod tests {
}
/// The ungated one-shots fire as the keys do: `CameraZoomIn(yards)` carries its amount to the
- /// zoom (1.0 when absent, `0x50b42d`), `SitOrStand` and `ToggleSheath` fire.
+ /// zoom (1.0 when absent, `0x50b42d`), and `ToggleSheath` fires, one frame only.
#[test]
fn the_one_shot_functions_fire_their_inputs() {
let mut app = harness();
@@ -1652,11 +1669,10 @@ mod tests {
0.0,
"one frame only"
);
- run(&mut app, "SitOrStand()");
- assert!(state(&app).fired(Input::SitOrStand));
run(&mut app, "ToggleSheath()");
assert!(state(&app).fired(Input::ToggleSheath));
- assert!(!state(&app).fired(Input::SitOrStand));
+ run(&mut app, "CameraZoomOut()");
+ assert!(!state(&app).fired(Input::ToggleSheath));
}
/// Two keys on one command share its one bit: W and UP both run MOVEFORWARD's body, so the
@@ -1925,10 +1941,10 @@ mod tests {
state(&app).pressed(Input::MoveForward),
"the capture edge is not a release — holding W keeps you running while you type"
);
- press_key(&mut app, KeyCode::KeyX);
+ press_key(&mut app, KeyCode::KeyZ);
app.update();
assert!(
- !state(&app).fired(Input::SitOrStand),
+ !state(&app).fired(Input::ToggleSheath),
"typed keys are not bindings"
);
// Letting go still stops you, box focused or not.
@@ -1939,12 +1955,12 @@ mod tests {
"the release is delivered regardless of focus"
);
// Focus drops; keys work again.
- release_key(&mut app, KeyCode::KeyX);
+ release_key(&mut app, KeyCode::KeyZ);
app.world_mut().resource_mut::().typing = false;
app.update();
- press_key(&mut app, KeyCode::KeyX);
+ press_key(&mut app, KeyCode::KeyZ);
app.update();
- assert!(state(&app).fired(Input::SitOrStand));
+ assert!(state(&app).fired(Input::ToggleSheath));
}
/// A shown keyboard frame eating the key that closes it costs that key its binding and
@@ -1968,22 +1984,22 @@ mod tests {
// The eaten key loses its binding...
release_key(&mut app, KeyCode::KeyM);
app.update();
- frame_ate(&mut app, &[KeyCode::KeyX]);
- press_key(&mut app, KeyCode::KeyX);
+ frame_ate(&mut app, &[KeyCode::KeyZ]);
+ press_key(&mut app, KeyCode::KeyZ);
app.update();
assert!(
- !state(&app).fired(Input::SitOrStand),
+ !state(&app).fired(Input::ToggleSheath),
"the frame ate this key: its binding must not also fire"
);
// ...and only that key.
- release_key(&mut app, KeyCode::KeyX);
+ release_key(&mut app, KeyCode::KeyZ);
app.update();
frame_ate(&mut app, &[KeyCode::KeyM]);
- press_key(&mut app, KeyCode::KeyX);
+ press_key(&mut app, KeyCode::KeyZ);
app.update();
assert!(
- state(&app).fired(Input::SitOrStand),
+ state(&app).fired(Input::ToggleSheath),
"consumption is per key, not per frame"
);
assert!(
diff --git a/crates/benilla-app/src/bindings/script_input.rs b/crates/benilla-app/src/bindings/script_input.rs
index 42d0658ff..18852ee13 100644
--- a/crates/benilla-app/src/bindings/script_input.rs
+++ b/crates/benilla-app/src/bindings/script_input.rs
@@ -7,6 +7,8 @@
use benilla_ui::script::{BindingInput, FiredInput, HeldInput};
+pub(crate) use benilla_ui::script::ViewAxis;
+
use super::BindingsState;
/// One engine input a binding function drives: a held bit of `[InputControl+4]` or a one-shot.
@@ -28,14 +30,16 @@ pub(crate) enum Input {
TurnOrAction,
/// `CameraOrSelectOrMoveStart`/`Stop`, bit `0x2`.
CameraOrSelectOrMove,
+ /// `PitchUpStart`/`Stop`, bit `0x400`.
+ PitchUp,
+ /// `PitchDownStart`/`Stop`, bit `0x800`.
+ PitchDown,
/// `Jump()`.
Jump,
/// `ToggleRun()`, the walk toggle.
ToggleRun,
/// `ToggleAutoRun()`.
ToggleAutoRun,
- /// `SitOrStand()`.
- SitOrStand,
/// `ToggleSheath()`.
ToggleSheath,
/// `CameraZoomIn([yards])`, its yards in [`BindingsState::amount`].
@@ -55,6 +59,8 @@ fn held_input(input: HeldInput) -> Input {
HeldInput::StrafeRight => Input::StrafeRight,
HeldInput::TurnOrAction => Input::TurnOrAction,
HeldInput::CameraOrSelectOrMove => Input::CameraOrSelectOrMove,
+ HeldInput::PitchUp => Input::PitchUp,
+ HeldInput::PitchDown => Input::PitchDown,
}
}
@@ -64,7 +70,6 @@ fn fired_input(input: FiredInput) -> (Input, f32) {
FiredInput::Jump => (Input::Jump, 1.0),
FiredInput::ToggleRun => (Input::ToggleRun, 1.0),
FiredInput::ToggleAutoRun => (Input::ToggleAutoRun, 1.0),
- FiredInput::SitOrStand => (Input::SitOrStand, 1.0),
FiredInput::ToggleSheath => (Input::ToggleSheath, 1.0),
FiredInput::CameraZoomIn(yards) => (Input::CameraZoomIn, yards),
FiredInput::CameraZoomOut(yards) => (Input::CameraZoomOut, yards),
@@ -98,6 +103,10 @@ impl BindingsState {
self.just.push(i);
self.amounts.push((i, amount));
}
+ // The camera's axes are its own state (`[cam+0x128]`), not `[InputControl+4]`:
+ // passed through in call order for the camera to apply.
+ BindingInput::ViewStart(axis) => self.view_calls.push((axis, true)),
+ BindingInput::ViewStop(axis) => self.view_calls.push((axis, false)),
}
}
}
@@ -111,6 +120,7 @@ impl BindingsState {
state.just.clear();
state.fired.clear();
state.amounts.clear();
+ state.view_calls.clear();
state.apply_script_input(now);
state
}
diff --git a/crates/benilla-app/src/capture/fixtures.rs b/crates/benilla-app/src/capture/fixtures.rs
index 1d3bfd99e..380dc7aaf 100644
--- a/crates/benilla-app/src/capture/fixtures.rs
+++ b/crates/benilla-app/src/capture/fixtures.rs
@@ -2,6 +2,7 @@
use super::*;
use benilla_protocol::messages::trainer_spell_state;
+use benilla_ui::script::UiScript;
/// The `vplates` fixture's wolf, the reference screenshot's subject (vmangos `creature_template`
/// 69 "Timber Wolf": level 2, faction template 32, display 604), at the scenario's look point.
@@ -105,20 +106,24 @@ pub(super) fn seed_ui_fixture(
ResMut<'static, crate::ui_bank::BankOpen>,
MessageWriter<'static, AppExit>,
ResMut<'static, crate::loading_screen::LoadingScreen>,
+ ResMut<'static, crate::ui_gossip::GossipState>,
+ ResMut<'static, crate::ui_quest::QuestGiver>,
),
)>,
mut ctx: ResMut,
mut commands: Commands,
progress: Res,
- mut gossip: ResMut,
- mut quest: ResMut,
mut quest_log: ResMut,
mut trainer: ResMut,
icons: Option>,
) {
- vm.turn(|mut script, parts| {
+ let icons = icons.as_deref();
+ // The seed's Lua (its pushes, chunks and hovers) runs once the turn's world writes are in,
+ // with the host lent: what it fires runs in place, and what it calls applies inside the verb.
+ let mut lua: Option> = None;
+ vm.turn(|script, parts| {
let (mut merchant, mut loot, mut names, mut selection, mut player, store, rest) = parts;
- let (mut actions, mut bank, mut exit, mut loading) = rest;
+ let (mut actions, mut bank, mut exit, mut loading, mut gossip, mut quest) = rest;
let (mut items, mut index, mut home_bind) = store;
// A glue-screen capture has no world scenario, and no glue screen opens a UI fixture.
let Some(scenario) = ctx.scenario else {
@@ -268,14 +273,14 @@ pub(super) fn seed_ui_fixture(
merchant.open(NPC_GUID, rows);
// The usable gate's player half, by hand: with no SelfPlayer in capture,
// `feed_player_req` never runs to overwrite it. A level-12 human warrior.
- if let Some(s) = script.as_mut() {
+ lua = Some(Box::new(move |s: &mut UiScript| {
s.set_player_req_state(benilla_ui::script::PlayerReqState {
level: 12,
class_id: 1,
race_id: 1,
..Default::default()
});
- }
+ }));
}
UiFixture::Trainer(list) => {
// The seed's rows are the wire list: its copper costs, level gates and the states
@@ -302,21 +307,6 @@ pub(super) fn seed_ui_fixture(
}),
);
home_bind.0 = Some(seed.bind);
- let Some(script) = script.as_mut() else {
- return;
- };
- // The window's title and portrait read `UnitName("npc")`; no session seats it here.
- script.set_unit(
- "npc",
- Some(benilla_ui::script::UnitState {
- exists: true,
- name: Some(seed.name.into()),
- level: 12,
- ..Default::default()
- }),
- );
- // A purse large enough for every cost above, so the money frame renders white.
- script.set_money(10_000);
let services: Vec = seed
.rows
.iter()
@@ -333,6 +323,21 @@ pub(super) fn seed_ui_fixture(
})
.collect();
trainer.open(NPC_GUID, seed.trainer_type, services, seed.greeting.into());
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // The window's title and portrait read `UnitName("npc")`; no session seats it
+ // here.
+ script.set_unit(
+ "npc",
+ Some(benilla_ui::script::UnitState {
+ exists: true,
+ name: Some(seed.name.into()),
+ level: 12,
+ ..Default::default()
+ }),
+ );
+ // A purse large enough for every cost above, so the money frame renders white.
+ script.set_money(10_000);
+ }));
}
UiFixture::Gossip => {
names.insert_creature(
@@ -482,19 +487,18 @@ pub(super) fn seed_ui_fixture(
// Opens bank bag 1 once its container feed lands (`GetContainerNumSlots(5) > 0`);
// `BankFrameBag1`'s `GetID()` is 5, the container id its handler passes to
// `ToggleBag`.
- if let Some(s) = script.as_mut() {
- if let Err(e) = s.run(
- "BankFrame:SetScript(\"OnUpdate\", function()\n\
- if not benillaBankPopoutDone and GetContainerNumSlots(5) > 0 then\n\
- benillaBankPopoutDone = 1\n\
- this = getglobal(\"BankFrameBag1\")\n\
- BankFrameItemButtonBag_OnClick(\"LeftButton\")\n\
- end\n\
- end)",
- ) {
+ let popout = "BankFrame:SetScript(\"OnUpdate\", function()\n\
+ if not benillaBankPopoutDone and GetContainerNumSlots(5) > 0 then\n\
+ benillaBankPopoutDone = 1\n\
+ this = getglobal(\"BankFrameBag1\")\n\
+ BankFrameItemButtonBag_OnClick(\"LeftButton\")\n\
+ end\n\
+ end)";
+ lua = Some(Box::new(move |s: &mut UiScript| {
+ if let Err(e) = s.run(popout) {
warn!("capture: ui-bank popout hook failed: {e}");
}
- }
+ }));
}
UiFixture::Quest => {
names.insert_creature(
@@ -744,11 +748,11 @@ pub(super) fn seed_ui_fixture(
));
// The L binding's path; the feed pushes over the settle window.
- if let Some(s) = script.as_mut() {
+ lua = Some(Box::new(move |s: &mut UiScript| {
if let Err(e) = s.run("ToggleQuestLog()") {
warn!("capture: ui-questlog seed failed to open the log: {e}");
}
- }
+ }));
}
UiFixture::Loot => {
items.insert_template(90_117, Some(template("Chipped Boar Tusk", 0)));
@@ -778,201 +782,195 @@ pub(super) fn seed_ui_fixture(
);
}
UiFixture::Bag => {
- let Some(script) = script else {
- return;
- };
- seed_bag_window(script, icons.as_deref());
- seed_equipped_bags(script, icons.as_deref());
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ seed_bag_window(script, icons);
+ seed_equipped_bags(script, icons);
+ }));
}
UiFixture::Cooldown => {
- let Some(script) = script else {
- return;
- };
- seed_cooldown_filmstrip(script, icons.as_deref());
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ seed_cooldown_filmstrip(script, icons);
+ }));
}
UiFixture::CooldownShine => {
- let Some(script) = script else {
- return;
- };
- seed_cooldown_filmstrip(script, icons.as_deref());
- // The pet bar's autocast shine, raised by hand, as no pet is fed.
- if let Err(e) = script.run(
- "PetActionBarFrame:Show()\n\
- for i = 1, 4 do\n\
- local b = getglobal(\"PetActionButton\"..i)\n\
- if b then b:Show(); getglobal(b:GetName()..\"AutoCast\"):Show() end\n\
- end",
- ) {
- warn!("capture: ui-cooldown-shine failed to raise the autocast shine: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ seed_cooldown_filmstrip(script, icons);
+ // The pet bar's autocast shine, raised by hand, as no pet is fed.
+ if let Err(e) = script.run(
+ "PetActionBarFrame:Show()\n\
+ for i = 1, 4 do\n\
+ local b = getglobal(\"PetActionButton\"..i)\n\
+ if b then b:Show(); getglobal(b:GetName()..\"AutoCast\"):Show() end\n\
+ end",
+ ) {
+ warn!("capture: ui-cooldown-shine failed to raise the autocast shine: {e}");
+ }
+ }));
}
UiFixture::WorldMap => {
- let Some(script) = script else {
- return;
- };
// At the default origin the player is off every zone rect and the arrow hides, so
// park it at the scenario's Northshire spot.
player.pos = benilla_assets::coords::wow_to_bevy(scenario.eye);
- // Alternating explore bits, so about half of each zone's overlays reveal.
- script.set_world_map_explored(vec![0x5555_5555; 64]);
- // The Elwynn zone map: continent 2, zone 10 in the alphabetical zone list.
- if let Err(e) = script.run("ToggleWorldMap(); SetMapZoom(2, 10)") {
- warn!("capture: ui-worldmap seed failed to open the map: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // Alternating explore bits, so about half of each zone's overlays reveal.
+ script.set_world_map_explored(vec![0x5555_5555; 64]);
+ // The Elwynn zone map: continent 2, zone 10 in the alphabetical zone list.
+ if let Err(e) = script.run("ToggleWorldMap(); SetMapZoom(2, 10)") {
+ warn!("capture: ui-worldmap seed failed to open the map: {e}");
+ }
+ }));
}
UiFixture::PartyInvite => {
- let Some(script) = script else {
- return;
- };
- // Raised through the real `StaticPopupDialogs` entry, as a real invite is.
- if let Err(e) = script.run(r#"StaticPopup_Show("PARTY_INVITE", "Brisca")"#) {
- warn!("capture: ui-partyinvite seed failed to raise the dialog: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // Raised through the real `StaticPopupDialogs` entry, as a real invite is.
+ if let Err(e) = script.run(r#"StaticPopup_Show("PARTY_INVITE", "Brisca")"#) {
+ warn!("capture: ui-partyinvite seed failed to raise the dialog: {e}");
+ }
+ }));
}
UiFixture::Tooltip => {
- let Some(script) = script else {
- return;
- };
- seed_bag_window(script, icons.as_deref());
- // The hovered shield's full template and a player under its level requirement:
- // quality name, bind, slot and type, armor and block, stats, durability, a red
- // requirement, a long green Use: line that wraps, a charges line after it, and the
- // flavor text.
- script.set_player_req_state(benilla_ui::script::PlayerReqState {
- level: 12,
- class_id: 1,
- race_id: 1,
- skills: Default::default(),
- ..Default::default()
- });
- script.set_item_template(
- 2362,
- benilla_ui::script::ItemTemplateView {
- name: "Small Shield".into(),
- quality: 2,
- class: 4,
- subclass: 6,
- inventory_type: 14,
- bonding: 2,
- stats: vec![(7, 3)],
- armor: 85,
- block: 4,
- max_durability: 45,
- required_level: 20,
- spell_lines: vec![benilla_ui::script::ItemSpellLine {
- trigger: 0,
- spell_id: 72,
- text: "Restores 243 health over 21 sec. Must remain seated while \
- eating."
- .into(),
- charges: 1,
- block: 0,
- recipe: None,
- }],
- description: "A stout little shield of Northshire pine.".into(),
- sell_price: 152,
- item_set: 161,
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ seed_bag_window(script, icons);
+ // The hovered shield's full template and a player under its level requirement:
+ // quality name, bind, slot and type, armor and block, stats, durability, a red
+ // requirement, a long green Use: line that wraps, a charges line after it, and
+ // the flavor text.
+ script.set_player_req_state(benilla_ui::script::PlayerReqState {
+ level: 12,
+ class_id: 1,
+ race_id: 1,
+ skills: Default::default(),
..Default::default()
- },
- );
- // The item-set block (`0x52b650`), Defias Leather with one of 5 equipped: the gold
- // "(1/5)" header, the member ladder, a green (2) bonus and a gray (4) one.
- let mut inv: benilla_ui::script::InventorySlots = Default::default();
- inv[4] = Some(benilla_ui::script::InvSlotView {
- durability: None,
- item_id: 6303,
- ..Default::default()
- });
- script.set_inventory_slots(inv);
- script.set_item_set(
- 161,
- benilla_ui::script::ItemSetView {
- name: "Defias Leather".into(),
- members: vec![
- (6303, Some("Defias Mark".into())),
- (6304, Some("Defias Belt".into())),
- (6305, Some("Defias Gloves".into())),
- (6306, Some("Defias Trousers".into())),
- (6307, Some("Defias Boots".into())),
- ],
- bonuses: vec![
- (2, "Increases movement speed slightly.".into()),
- (
- 4,
- "Immune to Defias Pillager and Defias Looter spells.".into(),
- ),
- ],
+ });
+ script.set_item_template(
+ 2362,
+ benilla_ui::script::ItemTemplateView {
+ name: "Small Shield".into(),
+ quality: 2,
+ class: 4,
+ subclass: 6,
+ inventory_type: 14,
+ bonding: 2,
+ stats: vec![(7, 3)],
+ armor: 85,
+ block: 4,
+ max_durability: 45,
+ required_level: 20,
+ spell_lines: vec![benilla_ui::script::ItemSpellLine {
+ trigger: 0,
+ spell_id: 72,
+ text: "Restores 243 health over 21 sec. Must remain seated while \
+ eating."
+ .into(),
+ charges: 1,
+ block: 0,
+ recipe: None,
+ }],
+ description: "A stout little shield of Northshire pine.".into(),
+ sell_price: 152,
+ item_set: 161,
+ ..Default::default()
+ },
+ );
+ // The item-set block (`0x52b650`), Defias Leather with one of 5 equipped: the
+ // gold "(1/5)" header, the member ladder, a green (2) bonus and a gray (4) one.
+ let mut inv: benilla_ui::script::InventorySlots = Default::default();
+ inv[4] = Some(benilla_ui::script::InvSlotView {
+ durability: None,
+ item_id: 6303,
..Default::default()
- },
- );
- // Opens the tooltip over the top-left button (`Item16`, game slot 1, the Small
- // Shield) through the hover's OnEnter path. `IsBagOpen` names the backpack's
- // window, as the twelve `ContainerFrame`s are recycled across containers.
- if let Err(e) = script.run(
- "local i = IsBagOpen(0)\n\
- if i then\n\
- local button = getglobal(\"ContainerFrame\"..i..\"Item16\")\n\
- ContainerFrameItemButton_OnEnter(button)\n\
- end",
- ) {
- warn!("capture: ui-tooltip seed failed to open the tooltip: {e}");
- }
+ });
+ script.set_inventory_slots(inv);
+ script.set_item_set(
+ 161,
+ benilla_ui::script::ItemSetView {
+ name: "Defias Leather".into(),
+ members: vec![
+ (6303, Some("Defias Mark".into())),
+ (6304, Some("Defias Belt".into())),
+ (6305, Some("Defias Gloves".into())),
+ (6306, Some("Defias Trousers".into())),
+ (6307, Some("Defias Boots".into())),
+ ],
+ bonuses: vec![
+ (2, "Increases movement speed slightly.".into()),
+ (
+ 4,
+ "Immune to Defias Pillager and Defias Looter spells.".into(),
+ ),
+ ],
+ ..Default::default()
+ },
+ );
+ // Opens the tooltip over the top-left button (`Item16`, game slot 1, the Small
+ // Shield) through the hover's OnEnter path. `IsBagOpen` names the backpack's
+ // window, as the twelve `ContainerFrame`s are recycled across containers.
+ if let Err(e) = script.run(
+ "local i = IsBagOpen(0)\n\
+ if i then\n\
+ local button = getglobal(\"ContainerFrame\"..i..\"Item16\")\n\
+ ContainerFrameItemButton_OnEnter(button)\n\
+ end",
+ ) {
+ warn!("capture: ui-tooltip seed failed to open the tooltip: {e}");
+ }
+ }));
}
UiFixture::TooltipWorld => {
- let Some(script) = script else {
- return;
- };
- // A PvP-flagged friendly guard under the cursor, pushed as the mouseover feed does,
- // then the call `drive_mouseover_tooltip` makes. The subject is the placement, the
- // `GameTooltip_SetDefaultAnchor` corner (`GameTooltip.lua:73-77`).
- script.set_unit(
- "mouseover",
- Some(benilla_ui::script::UnitState {
- exists: true,
- // A unit is found by its guid; the builder hides for guid 0 (`0x52a04e`).
- guid: 0xF130_0000_0044_0001,
- name: Some("Stormwind Guard".into()),
- health: 38,
- max_health: 50,
- level: 25,
- reaction: 5,
- creature_type_name: Some("Humanoid".into()),
- // The faction-name line, white, between level and PvP.
- faction_name: Some("Stormwind".into()),
- pvp: true,
- ..Default::default()
- }),
- );
- if !script.world_tooltip_unit("mouseover") {
- warn!("capture: ui-tooltip-world seed failed to open the tooltip");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // A PvP-flagged friendly guard under the cursor, pushed as the mouseover feed
+ // does, then the call `drive_mouseover_tooltip` makes. The subject is the
+ // placement, the `GameTooltip_SetDefaultAnchor` corner
+ // (`GameTooltip.lua:73-77`).
+ script.set_unit(
+ "mouseover",
+ Some(benilla_ui::script::UnitState {
+ exists: true,
+ // A unit is found by its guid; the builder hides for guid 0
+ // (`0x52a04e`).
+ guid: 0xF130_0000_0044_0001,
+ name: Some("Stormwind Guard".into()),
+ health: 38,
+ max_health: 50,
+ level: 25,
+ reaction: 5,
+ creature_type_name: Some("Humanoid".into()),
+ // The faction-name line, white, between level and PvP.
+ faction_name: Some("Stormwind".into()),
+ pvp: true,
+ ..Default::default()
+ }),
+ );
+ if !script.world_tooltip_unit("mouseover") {
+ warn!("capture: ui-tooltip-world seed failed to open the tooltip");
+ }
+ }));
}
UiFixture::TooltipRank => {
- let Some(script) = script else {
- return;
- };
- // A ranked player under the cursor, pushed as the mouseover feed does, then the
- // call `drive_mouseover_tooltip` makes: the title is `0x609370`'s rank leg over the
- // name, "Sergeant Bob".
- script.set_unit(
- "mouseover",
- Some(benilla_ui::script::UnitState {
- exists: true,
- guid: 0x0000_0000_0000_0B0B,
- is_player: true,
- name: Some("Bob".into()),
- level: 60,
- reaction: 5,
- pvp: true,
- pvp_rank: 7,
- pvp_team: 1,
- sex: 2,
- ..Default::default()
- }),
- );
- if !script.world_tooltip_unit("mouseover") {
- warn!("capture: ui-tooltip-rank seed failed to open the tooltip");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // A ranked player under the cursor, pushed as the mouseover feed does, then the
+ // call `drive_mouseover_tooltip` makes: the title is `0x609370`'s rank leg over
+ // the name, "Sergeant Bob".
+ script.set_unit(
+ "mouseover",
+ Some(benilla_ui::script::UnitState {
+ exists: true,
+ guid: 0x0000_0000_0000_0B0B,
+ is_player: true,
+ name: Some("Bob".into()),
+ level: 60,
+ reaction: 5,
+ pvp: true,
+ pvp_rank: 7,
+ pvp_team: 1,
+ sex: 2,
+ ..Default::default()
+ }),
+ );
+ if !script.world_tooltip_unit("mouseover") {
+ warn!("capture: ui-tooltip-rank seed failed to open the tooltip");
+ }
+ }));
}
UiFixture::Character => {
// A synthetic self player carrying the full stat block, which the `ui_char` feed
@@ -1081,11 +1079,11 @@ pub(super) fn seed_ui_fixture(
));
// The C binding's path; the feed pushes over the settle window.
- if let Some(s) = script.as_mut() {
+ lua = Some(Box::new(move |s: &mut UiScript| {
if let Err(e) = s.run("ToggleCharacter(\"PaperDollFrame\")") {
warn!("capture: ui-char seed failed to open the window: {e}");
}
- }
+ }));
}
UiFixture::VPlates => {
use benilla_protocol::messages::ObjectFields;
@@ -1146,122 +1144,123 @@ pub(super) fn seed_ui_fixture(
))
.id();
// As the V binding does, so FrameXML's replay at `PLAYER_ENTERING_WORLD` agrees.
- set_enemy_plates(script.as_deref(), true);
- // The wolf is the target, so its plate draws lit with the target ring.
+ lua = Some(Box::new(|script: &mut UiScript| {
+ set_enemy_plates(Some(script), true)
+ }));
+ // The wolf is the target, so its plate draws lit with the target ring: indexed
+ // under its guid, the object the selection's tracker keeps, and lit as
+ // `SetSelection` lights its object (`0x493701`).
+ index.0.insert(WOLF_GUID, wolf);
selection.target = Some(wolf);
selection.guid = Some(WOLF_GUID);
+ selection.lit = Some(wolf);
}
UiFixture::Options => {
- let Some(script) = script else {
- return;
- };
- // Opened through the live panel path, with Controls selected by its OnShow.
- if let Err(e) = script.run("ShowUIPanel(BenillaOptionsFrame)") {
- warn!("capture: ui-options seed failed to open the window: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // Opened through the live panel path, with Controls selected by its OnShow.
+ if let Err(e) = script.run("ShowUIPanel(BenillaOptionsFrame)") {
+ warn!("capture: ui-options seed failed to open the window: {e}");
+ }
+ }));
}
UiFixture::OptionsAudio => {
- let Some(script) = script else {
- return;
- };
- // The Audio page: the real CVar set first, so the rows read real values, then the
- // live open and select paths.
- script.register_cvars(crate::cvars::registered_pairs());
- if let Err(e) = script.run(
- "ShowUIPanel(BenillaOptionsFrame); \
- BenillaOptionsFrameCategoryListRowAudio:Click()",
- ) {
- warn!("capture: ui-options-audio seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // The Audio page: the real CVar set first, so the rows read real values, then
+ // the live open and select paths.
+ script.register_cvars(crate::cvars::registered_pairs());
+ if let Err(e) = script.run(
+ "ShowUIPanel(BenillaOptionsFrame); \
+ BenillaOptionsFrameCategoryListRowAudio:Click()",
+ ) {
+ warn!("capture: ui-options-audio seed failed: {e}");
+ }
+ }));
}
UiFixture::OptionsGraphics => {
- let Some(script) = script else {
- return;
- };
- // The Graphics page, as the Audio fixture.
- script.register_cvars(crate::cvars::registered_pairs());
- if let Err(e) = script.run(
- "ShowUIPanel(BenillaOptionsFrame); \
- BenillaOptionsFrameCategoryListRowGraphics:Click()",
- ) {
- warn!("capture: ui-options-graphics seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // The Graphics page, as the Audio fixture.
+ script.register_cvars(crate::cvars::registered_pairs());
+ if let Err(e) = script.run(
+ "ShowUIPanel(BenillaOptionsFrame); \
+ BenillaOptionsFrameCategoryListRowGraphics:Click()",
+ ) {
+ warn!("capture: ui-options-graphics seed failed: {e}");
+ }
+ }));
}
UiFixture::OptionsChat => {
- let Some(script) = script else {
- return;
- };
- // The Chat page, as the Audio fixture. Its Remove Chat Hover Delay row reads a
- // saved variable `ChatFrame.xml` declares, so it paints unchecked, the shipped "0".
- script.register_cvars(crate::cvars::registered_pairs());
- if let Err(e) = script.run(
- "ShowUIPanel(BenillaOptionsFrame); \
- BenillaOptionsFrameCategoryListRowChat:Click()",
- ) {
- warn!("capture: ui-options-chat seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // The Chat page, as the Audio fixture. Its Remove Chat Hover Delay row reads a
+ // saved variable `ChatFrame.xml` declares, so it paints unchecked, the shipped
+ // "0".
+ script.register_cvars(crate::cvars::registered_pairs());
+ if let Err(e) = script.run(
+ "ShowUIPanel(BenillaOptionsFrame); \
+ BenillaOptionsFrameCategoryListRowChat:Click()",
+ ) {
+ warn!("capture: ui-options-chat seed failed: {e}");
+ }
+ }));
}
UiFixture::ColorPicker => {
- let Some(script) = script else {
- return;
- };
- // An addon's usual opening: set the colour, ask for opacity, show the window. The
- // colour puts both markers off their defaults, so a mirrored axis shows.
- if let Err(e) = script.run(
- "ColorPickerFrame.hasOpacity = 1; ColorPickerFrame.opacity = 0.3; \
- ColorPickerFrame:SetColorRGB(0.15, 0.55, 0.75); \
- ShowUIPanel(ColorPickerFrame)",
- ) {
- warn!("capture: ui-color-picker seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // An addon's usual opening: set the colour, ask for opacity, show the window.
+ // The colour puts both markers off their defaults, so a mirrored axis shows.
+ if let Err(e) = script.run(
+ "ColorPickerFrame.hasOpacity = 1; ColorPickerFrame.opacity = 0.3; \
+ ColorPickerFrame:SetColorRGB(0.15, 0.55, 0.75); \
+ ShowUIPanel(ColorPickerFrame)",
+ ) {
+ warn!("capture: ui-color-picker seed failed: {e}");
+ }
+ }));
}
UiFixture::OptionsDropdownList => {
- let Some(script) = script else {
- return;
- };
- // The Camera Following Style list open. Its width lands inside the opening click:
- // `UIDropDownMenu_Refresh` sizes buttons from `normalText:GetWidth() + 60`
- // (`UIDropDownMenu.lua:405`), which the engine answers in the same call.
- script.register_cvars(crate::cvars::registered_pairs());
- if let Err(e) = script.run(
- "ShowUIPanel(BenillaOptionsFrame); \
- BenillaOptionsFrameCategoryListRowControls:Click(); \
- BenillaOptionsFrameContainerBodyControlsRowCameraFollowStyleDropdownButton\
- :Click()",
- ) {
- warn!("capture: ui-options-dropdown seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // The Camera Following Style list open. Its width lands inside the opening
+ // click: `UIDropDownMenu_Refresh` sizes buttons from
+ // `normalText:GetWidth() + 60` (`UIDropDownMenu.lua:405`), which the engine
+ // answers in the same call.
+ script.register_cvars(crate::cvars::registered_pairs());
+ if let Err(e) = script.run(
+ "ShowUIPanel(BenillaOptionsFrame); \
+ BenillaOptionsFrameCategoryListRowControls:Click(); \
+ BenillaOptionsFrameContainerBodyControlsRowCameraFollowStyleDropdownButton\
+ :Click()",
+ ) {
+ warn!("capture: ui-options-dropdown seed failed: {e}");
+ }
+ }));
}
UiFixture::KeyBindings => {
- let Some(script) = script else {
- return;
- };
- // The Keybindings page over the commands the load registered: the real CVar set
- // first, then the live open path, with Movement expanded to show a header row and
- // the default bindings.
- script.register_cvars(crate::cvars::registered_pairs());
- if let Err(e) = script.run(
- "ShowUIPanel(BenillaOptionsFrame); \
- BenillaOptionsFrameCategoryListRowKeybindings:Click(); \
- BenillaKeyBindings_ExpandSection(1, true); BenillaKeyBindingsPage_Update()",
- ) {
- warn!("capture: ui-keybindings seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // The Keybindings page over the commands the load registered: the real CVar set
+ // first, then the live open path, with Movement expanded to show a header row
+ // and the default bindings.
+ script.register_cvars(crate::cvars::registered_pairs());
+ if let Err(e) = script.run(
+ "ShowUIPanel(BenillaOptionsFrame); \
+ BenillaOptionsFrameCategoryListRowKeybindings:Click(); \
+ BenillaKeyBindings_ExpandSection(1, true); \
+ BenillaKeyBindingsPage_Update()",
+ ) {
+ warn!("capture: ui-keybindings seed failed: {e}");
+ }
+ }));
}
UiFixture::OptionsSearch => {
- let Some(script) = script else {
- return;
- };
- // Mid-search: "volume" gathers the four volume sliders under the Audio head. The
- // box is focused, so the caret shows at the text's end.
- script.register_cvars(crate::cvars::registered_pairs());
- if let Err(e) = script.run(
- "ShowUIPanel(BenillaOptionsFrame); \
- BenillaOptionsFrameSearchBox:SetText(\"volume\"); \
- BenillaOptionsFrameSearchBox:SetFocus()",
- ) {
- warn!("capture: ui-options-search seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // Mid-search: "volume" gathers the four volume sliders under the Audio head.
+ // The box is focused, so the caret shows at the text's end.
+ script.register_cvars(crate::cvars::registered_pairs());
+ if let Err(e) = script.run(
+ "ShowUIPanel(BenillaOptionsFrame); \
+ BenillaOptionsFrameSearchBox:SetText(\"volume\"); \
+ BenillaOptionsFrameSearchBox:SetFocus()",
+ ) {
+ warn!("capture: ui-options-search seed failed: {e}");
+ }
+ }));
}
UiFixture::SpellBook => {
// A human warrior who also knows two cross-class spells. The book resolves through
@@ -1292,9 +1291,6 @@ pub(super) fn seed_ui_fixture(
let mut sword = template("Militia Shortsword", 2);
sword.display_info_id = DISP_SWORD;
items.insert_template(93_011, Some(sword));
- let Some(script) = script.as_mut() else {
- return;
- };
actions.spells.extend([
// The auto-attack shows the equipped sword's icon, not the placeholder of spell
// 6603, in General (no skill line).
@@ -1315,14 +1311,13 @@ pub(super) fn seed_ui_fixture(
9078, // Cloth proficiency
]);
// The P binding's path; the feed pushes over the settle window.
- if let Err(e) = script.run("ToggleSpellBook(BOOKTYPE_SPELL)") {
- warn!("capture: ui-spellbook seed failed to open the book: {e}");
- }
+ lua = Some(Box::new(|script: &mut UiScript| {
+ if let Err(e) = script.run("ToggleSpellBook(BOOKTYPE_SPELL)") {
+ warn!("capture: ui-spellbook seed failed to open the book: {e}");
+ }
+ }));
}
UiFixture::Macro | UiFixture::MacroPopup => {
- let Some(script) = script.as_mut() else {
- return;
- };
// Made through the live `CreateMacro` path, so `UPDATE_MACROS` reaches the window
// as a player's edit does; icons index `SpellIcon.dbc`. The bodies: a plain
// `/cast`, a multi-line macro, and a `/script` line the bar's bound-spell resolve
@@ -1351,118 +1346,112 @@ pub(super) fn seed_ui_fixture(
if fixture == UiFixture::MacroPopup {
seed.push_str("MacroEditButton:Click()\n");
}
- if let Err(e) = script.run(&seed) {
- warn!("capture: ui-macro seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ if let Err(e) = script.run(&seed) {
+ warn!("capture: ui-macro seed failed: {e}");
+ }
+ }));
}
UiFixture::Social => {
// Nothing to seed: an empty friends list opens the same frames a full one does.
- let Some(script) = script.as_mut() else {
- return;
- };
- if let Err(e) = script.run("ToggleFriendsFrame(1)") {
- warn!("capture: ui-social seed failed to open the pane: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ if let Err(e) = script.run("ToggleFriendsFrame(1)") {
+ warn!("capture: ui-social seed failed to open the pane: {e}");
+ }
+ }));
}
UiFixture::ChatEdit => {
- let Some(script) = script.as_mut() else {
- return;
- };
- // Say and yell lines behind the open edit box, opened through the live path;
- // `chat_edit_live` then drives the header and the `15 + headerWidth` insets as
- // in-game.
- for (text, r, g, b) in [
- ("[One] says: testing the box", 1.0, 1.0, 1.0),
- ("[One] says: a second line to stack", 1.0, 1.0, 1.0),
- ("[One] yells: FUU", 1.0, 64.0 / 255.0, 64.0 / 255.0),
- ] {
- script.add_chat_message("ChatFrame1", text, r, g, b);
- }
- script.focus_editbox("ChatFrameEditBox");
- // A draft with "northshire" selected: the gray selection highlight (`0xFF606060`)
- // under the glyphs and the caret at its end. The tab and window tint follow the
- // cursor in `FCF_OnUpdate`, so a fixed-reveal OnUpdate pins them; it calls
- // `PanelTemplates_TabResize` every frame until the label's measure lands.
- if let Err(e) = script.run(
- "ChatFrameEditBox:SetText(\"hello northshire\")\n\
- ChatFrameEditBox:HighlightText(6, 16)\n\
- ChatFrame1:SetScript('OnUpdate', function()\n\
- PanelTemplates_TabResize(10, ChatFrame1Tab)\n\
- ChatFrame1Tab:SetAlpha(1.0)\n\
- FCF_SetWindowAlpha(ChatFrame1, 0.25, 1)\n\
- end)",
- ) {
- warn!("capture: ui-chatedit seed failed: {e}");
- }
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // Say and yell lines behind the open edit box, opened through the live path;
+ // `chat_edit_live` then drives the header and the `15 + headerWidth` insets as
+ // in-game.
+ for (text, r, g, b) in [
+ ("[One] says: testing the box", 1.0, 1.0, 1.0),
+ ("[One] says: a second line to stack", 1.0, 1.0, 1.0),
+ ("[One] yells: FUU", 1.0, 64.0 / 255.0, 64.0 / 255.0),
+ ] {
+ script.add_chat_message("ChatFrame1", text, r, g, b);
+ }
+ script.focus_editbox("ChatFrameEditBox");
+ // A draft with "northshire" selected: the gray selection highlight
+ // (`0xFF606060`) under the glyphs and the caret at its end. The tab and window
+ // tint follow the cursor in `FCF_OnUpdate`, so a fixed-reveal OnUpdate pins
+ // them; it calls `PanelTemplates_TabResize` every frame until the label's
+ // measure lands.
+ if let Err(e) = script.run(
+ "ChatFrameEditBox:SetText(\"hello northshire\")\n\
+ ChatFrameEditBox:HighlightText(6, 16)\n\
+ ChatFrame1:SetScript('OnUpdate', function()\n\
+ PanelTemplates_TabResize(10, ChatFrame1Tab)\n\
+ ChatFrame1Tab:SetAlpha(1.0)\n\
+ FCF_SetWindowAlpha(ChatFrame1, 0.25, 1)\n\
+ end)",
+ ) {
+ warn!("capture: ui-chatedit seed failed: {e}");
+ }
+ }));
}
UiFixture::ChatTabHover => {
- let Some(script) = script.as_mut() else {
- return;
- };
- // Lines for content, the Combat Log selected, and the cursor on the General tab: an
- // unselected tab's hover. A capture can hover, as the OS cursor only reaches the VM
- // on a non-synthetic run, so a fed `mouse_move` stands.
- for (text, r, g, b) in [
- ("[One] says: hello northshire", 1.0, 1.0, 1.0),
- ("[One] says: a second line to stack", 1.0, 1.0, 1.0),
- ] {
- script.add_chat_message("ChatFrame1", text, r, g, b);
- }
- // `$WOW_TABHOVER` picks one of five dock states for an A/B:
- // 1 (default) Combat Log selected, hovering General
- // 3 General selected, hovering Combat Log
- // 2 Combat Log selected, hovering Combat Log (the selected tab)
- // 0 revealed, hovering neither tab (no glow)
- // 9 cursor off the dock (bare scene, the baseline)
- let mode = std::env::var("WOW_TABHOVER").unwrap_or_else(|_| "1".into());
- let select = if mode == "3" { 1 } else { 2 };
- if let Err(e) = script.run(&format!("FCF_SelectDockFrame(ChatFrame{select})")) {
- warn!("capture: ui-chat-tabhover select failed: {e}");
- }
- script.resolve();
- // Each in the root's units the cursor is fed in: the frame's own times its scale.
- let expr = match mode.as_str() {
- "2" | "3" => {
- "local x, y = ChatFrame2Tab:GetCenter() \
- local k = ChatFrame2Tab:GetEffectiveScale() return x * k, y * k"
+ lua = Some(Box::new(move |script: &mut UiScript| {
+ // Lines for content, the Combat Log selected, and the cursor on the General
+ // tab: an unselected tab's hover. A capture can hover, as the OS cursor only
+ // reaches the VM on a non-synthetic run, so a fed `mouse_move` stands.
+ for (text, r, g, b) in [
+ ("[One] says: hello northshire", 1.0, 1.0, 1.0),
+ ("[One] says: a second line to stack", 1.0, 1.0, 1.0),
+ ] {
+ script.add_chat_message("ChatFrame1", text, r, g, b);
}
- "0" => {
- "local k = ChatFrame2:GetEffectiveScale() \
- return (ChatFrame2:GetLeft() + ChatFrame2:GetRight()) / 2 * k, \
- (ChatFrame2:GetBottom() + ChatFrame2:GetTop()) / 2 * k"
+ // `$WOW_TABHOVER` picks one of five dock states for an A/B:
+ // 1 (default) Combat Log selected, hovering General
+ // 3 General selected, hovering Combat Log
+ // 2 Combat Log selected, hovering Combat Log (the selected tab)
+ // 0 revealed, hovering neither tab (no glow)
+ // 9 cursor off the dock (bare scene, the baseline)
+ let mode = std::env::var("WOW_TABHOVER").unwrap_or_else(|_| "1".into());
+ let select = if mode == "3" { 1 } else { 2 };
+ if let Err(e) = script.run(&format!("FCF_SelectDockFrame(ChatFrame{select})")) {
+ warn!("capture: ui-chat-tabhover select failed: {e}");
}
- // 9: park far away, so the dock conceals itself.
- "9" => "return 2000, 2000",
- _ => {
- "local x, y = ChatFrame1Tab:GetCenter() \
- local k = ChatFrame1Tab:GetEffectiveScale() return x * k, y * k"
- }
- };
- let centre: Result<(f32, f32), _> = script.eval(expr);
- match centre {
- Ok((x, y)) => {
- script.mouse_move(x, y);
- // Settle the reveal ramp without waiting on the app's own frames.
- for _ in 0..40 {
- if let Err(e) = script.run("FCF_OnUpdate(0.05)") {
- warn!("capture: ui-chat-tabhover pump failed: {e}");
- break;
- }
- script.resolve();
+ script.resolve();
+ // Each in the root's units the cursor is fed in: the frame's own times its
+ // scale.
+ let expr = match mode.as_str() {
+ "2" | "3" => {
+ "local x, y = ChatFrame2Tab:GetCenter() \
+ local k = ChatFrame2Tab:GetEffectiveScale() return x * k, y * k"
}
+ "0" => {
+ "local k = ChatFrame2:GetEffectiveScale() \
+ return (ChatFrame2:GetLeft() + ChatFrame2:GetRight()) / 2 * k, \
+ (ChatFrame2:GetBottom() + ChatFrame2:GetTop()) / 2 * k"
+ }
+ // 9: park far away, so the dock conceals itself.
+ "9" => "return 2000, 2000",
+ _ => {
+ "local x, y = ChatFrame1Tab:GetCenter() \
+ local k = ChatFrame1Tab:GetEffectiveScale() return x * k, y * k"
+ }
+ };
+ let centre: Result<(f32, f32), _> = script.eval(expr);
+ match centre {
+ Ok((x, y)) => {
+ script.mouse_move(x, y);
+ // Settle the reveal ramp without waiting on the app's own frames.
+ for _ in 0..40 {
+ if let Err(e) = script.run("FCF_OnUpdate(0.05)") {
+ warn!("capture: ui-chat-tabhover pump failed: {e}");
+ break;
+ }
+ script.resolve();
+ }
+ }
+ Err(e) => warn!("capture: ui-chat-tabhover centre failed: {e}"),
}
- Err(e) => warn!("capture: ui-chat-tabhover centre failed: {e}"),
- }
+ }));
}
UiFixture::NameWater => {
use benilla_protocol::messages::ObjectFields;
- // The subject is an NPC's overhead name, and `UnitNameNPC` defaults to "0"; set
- // through Lua as a player would, so the sync drains it into `NameConfig`.
- if let Some(script) = script.as_deref_mut() {
- if let Err(e) = script.run("SetCVar(\"UnitNameNPC\", \"1\")") {
- warn!("capture: name fixture could not enable UnitNameNPC: {e}");
- }
- }
// The self player at the eye; the name colour is its reaction to the wolf.
const SELF_GUID: u64 = 0x51;
names.insert_player(SELF_GUID, "Benilla".into(), None);
@@ -1513,8 +1502,16 @@ pub(super) fn seed_ui_fixture(
},
Visibility::default(),
));
- // A plated unit draws no floating name, so enemy plates go off.
- set_enemy_plates(script.as_deref(), false);
+ lua = Some(Box::new(|script: &mut UiScript| {
+ // The subject is an NPC's overhead name, and `UnitNameNPC` defaults to "0";
+ // set through Lua as a player would, so the sync drains it into
+ // `NameConfig`.
+ if let Err(e) = script.run("SetCVar(\"UnitNameNPC\", \"1\")") {
+ warn!("capture: name fixture could not enable UnitNameNPC: {e}");
+ }
+ // A plated unit draws no floating name, so enemy plates go off.
+ set_enemy_plates(Some(script), false);
+ }));
}
UiFixture::NameRank => {
use benilla_protocol::messages::ObjectFields;
@@ -1559,7 +1556,9 @@ pub(super) fn seed_ui_fixture(
Visibility::default(),
));
// A plated unit draws no floating name, so enemy plates go off.
- set_enemy_plates(script.as_deref(), false);
+ lua = Some(Box::new(|script: &mut UiScript| {
+ set_enemy_plates(Some(script), false)
+ }));
}
// The lighting matrix: one spawn with a streamed entity's component set, anonymous and
// with plates off, so no glyph rides over the body.
@@ -1603,10 +1602,19 @@ pub(super) fn seed_ui_fixture(
));
}
}
- set_enemy_plates(script.as_deref(), false);
+ lua = Some(Box::new(|script: &mut UiScript| {
+ set_enemy_plates(Some(script), false)
+ }));
}
}
- })
+ });
+ if let Some(lua) = lua {
+ vm.run(|script| {
+ if let Some(script) = script {
+ lua(script);
+ }
+ });
+ }
}
/// The `GetTime()` the cooldown filmstrip pins the VM's session clock at, seconds. Large, as
@@ -1639,6 +1647,7 @@ fn seed_cooldown_filmstrip(
slots.insert(
slot,
benilla_ui::script::ContainerSlot {
+ uncached_link: None,
use_fork: Default::default(),
item_class: None,
petition: None,
@@ -1704,6 +1713,7 @@ fn seed_bag_window(
};
let slot = |disp: u32, count: u32, id: u32, name: &str, quality: u32| {
benilla_ui::script::ContainerSlot {
+ uncached_link: None,
use_fork: Default::default(),
item_class: None,
petition: None,
@@ -1803,6 +1813,7 @@ fn seed_equipped_bags(
};
let slot =
|disp: u32, count: u32, name: &str, quality: u32| benilla_ui::script::ContainerSlot {
+ uncached_link: None,
use_fork: Default::default(),
item_class: None,
petition: None,
diff --git a/crates/benilla-app/src/capture/probe_auction.rs b/crates/benilla-app/src/capture/probe_auction.rs
index 94972fdc7..8dbdf71ca 100644
--- a/crates/benilla-app/src/capture/probe_auction.rs
+++ b/crates/benilla-app/src/capture/probe_auction.rs
@@ -366,15 +366,17 @@ fn error_name(error: u32) -> &'static str {
fn auction_probe(
time: ProbeClock,
mut probe: ResMut,
- auction: Res,
- mut hosted_vm: crate::script_calls::HostedVm,
+ mut vm: crate::script_calls::VmWith>,
self_player: Query<&ObjectStore, With>,
player: Res,
units: Query<(&Guid, &NetEntity, &ObjectStore, &Transform), Without>,
net: Res,
mut exit: MessageWriter,
) {
- hosted_vm.run(|script| {
+ // The house as this frame found it: the verbs the probe's Lua calls apply in the call, through
+ // the host, which holds the house while it does.
+ let auction = vm.own().clone();
+ vm.run(|script| {
let Ok(store) = self_player.single() else {
return; // not in-world yet
};
diff --git a/crates/benilla-app/src/capture/probe_bank.rs b/crates/benilla-app/src/capture/probe_bank.rs
index d4f17d6cd..69eff2e45 100644
--- a/crates/benilla-app/src/capture/probe_bank.rs
+++ b/crates/benilla-app/src/capture/probe_bank.rs
@@ -156,9 +156,8 @@ fn find_bank_slot(store: &ObjectStore, guid: u64) -> Option {
fn bank_probe(
time: ProbeClock,
mut probe: ResMut,
- open: Res,
prices: Option>,
- mut hosted_vm: crate::script_calls::HostedVm,
+ mut hosted_vm: crate::script_calls::VmWith>,
self_player: Query<(), With>,
self_store: Query<&ObjectStore, With>,
player: Res,
@@ -166,6 +165,7 @@ fn bank_probe(
net: Res,
mut exit: MessageWriter,
) {
+ let bank_open = hosted_vm.own().is_open();
hosted_vm.run(|script| {
if self_player.is_empty() {
return; // not in-world yet
@@ -241,7 +241,7 @@ fn bank_probe(
}
}
Phase::Activating { sent_at } => {
- if open.is_open() {
+ if bank_open {
info!(
"PROBE_BANK: PASS (2 activate) — BankOpen is_open (SMSG_SHOW_BANK \
landed)"
diff --git a/crates/benilla-app/src/capture/probe_binder.rs b/crates/benilla-app/src/capture/probe_binder.rs
index 54ca9fe69..43da750b6 100644
--- a/crates/benilla-app/src/capture/probe_binder.rs
+++ b/crates/benilla-app/src/capture/probe_binder.rs
@@ -179,21 +179,39 @@ fn vm_bind_location(script: &UiScript) -> String {
.unwrap_or_default()
}
+/// The gossip menu as the step reads it, taken outside the VM: the gossip verbs write the state
+/// in the host, which the step's Lua runs with.
+struct Menu {
+ npc: Option,
+ options: Vec,
+}
+
+impl Menu {
+ fn of(gossip: &GossipState) -> Self {
+ Menu {
+ npc: gossip.npc,
+ options: gossip.options.clone(),
+ }
+ }
+}
+
fn binder_probe(
time: ProbeClock,
mut probe: ResMut,
- gossip: Res,
binder: Res,
mut home: ResMut,
areas: Option>,
- mut hosted_vm: crate::script_calls::HostedVm,
+ // The gossip slots, read outside the VM: the gossip verbs write them in the host.
+ mut vm: crate::script_calls::VmWith>,
self_player: Query<(), With>,
player: Res,
units: Query<(&Guid, &NetEntity, &ObjectStore, &Transform), Without>,
net: Res,
mut exit: MessageWriter,
) {
- hosted_vm.run(|script| {
+ // The step's Lua runs with the host lent, so the calls it makes apply inside their verbs.
+ let gossip = Menu::of(&vm.own());
+ vm.run(|script| {
if self_player.is_empty() {
return; // not in-world yet
}
@@ -436,7 +454,7 @@ fn binder_probe(
/// Steps 3 and 4: the bind row's icon, then the click. Sets `probe.phase` on every path.
fn assert_icon_and_select(
probe: &mut BinderProbe,
- gossip: &GossipState,
+ gossip: &Menu,
script: &UiScript,
net: &NetCommands,
innkeeper: u64,
@@ -515,6 +533,7 @@ fn assert_icon_and_select(
let _ = net.0.send(ClientCommand::GossipSelectOption {
guid: innkeeper,
option: opt.index,
+ code: None,
});
info!(
"PROBE_BINDER: (4 select) GossipSelectOption({innkeeper:#x}, wire index {}) sent for {:?}",
diff --git a/crates/benilla-app/src/capture/probe_book.rs b/crates/benilla-app/src/capture/probe_book.rs
index b42349dd7..5886e1201 100644
--- a/crates/benilla-app/src/capture/probe_book.rs
+++ b/crates/benilla-app/src/capture/probe_book.rs
@@ -214,7 +214,10 @@ fn book_probe(
net: Res,
mut exit: MessageWriter,
) {
- vm.turn(|script, mut reader| {
+ // The step's Lua runs with the host lent, so the calls it makes apply inside their verbs; the
+ // reader opens outside it, once it has run.
+ let mut open_pages = None;
+ vm.run(|script| {
if self_player.is_empty() {
return; // not in-world yet
}
@@ -286,7 +289,7 @@ fn book_probe(
"PROBE_BOOK: opening the reader on {guid:#x} (the right-click's own \
route — `ItemTextOpen::read_pages`)"
);
- reader.read_pages(guid);
+ open_pages = Some(guid);
probe.phase = Phase::WaitReady { since: now };
}
}
@@ -342,5 +345,8 @@ fn book_probe(
});
}
}
- })
+ });
+ if let Some(guid) = open_pages {
+ vm.own().read_pages(guid);
+ }
}
diff --git a/crates/benilla-app/src/capture/probe_charter.rs b/crates/benilla-app/src/capture/probe_charter.rs
index f2a78a375..e863b9fc3 100644
--- a/crates/benilla-app/src/capture/probe_charter.rs
+++ b/crates/benilla-app/src/capture/probe_charter.rs
@@ -323,21 +323,45 @@ fn probe_guild_name(prefix: &str) -> String {
format!("{prefix} {secs:08}")
}
+/// The gossip menu as the step reads it, taken outside the VM: the gossip verbs write the state
+/// in the host, which the step's Lua runs with.
+struct Menu {
+ npc: Option,
+ options: Vec,
+}
+
+impl Menu {
+ fn of(gossip: &GossipState) -> Self {
+ Menu {
+ npc: gossip.npc,
+ options: gossip.options.clone(),
+ }
+ }
+}
+
fn charter_probe(
time: ProbeClock,
mut probe: ResMut,
- gossip: Res,
- registrar: Res,
objects: Objects,
items: Res,
- mut hosted_vm: crate::script_calls::HostedVm,
+ // The gossip slots and the registrar's, read outside the VM: their verbs write them in the
+ // host.
+ mut vm: crate::script_calls::VmWith<(
+ Res<'static, GossipState>,
+ Res<'static, GuildRegistrarState>,
+ )>,
self_q: Query<&ObjectStore, With>,
player: Res,
units: Query<(&Guid, &NetEntity, &ObjectStore, &Transform), Without>,
net: Res,
mut exit: MessageWriter,
) {
- hosted_vm.run(|script| {
+ // The step's Lua runs with the host lent, so the calls it makes apply inside their verbs.
+ let (gossip, registrar_npc) = {
+ let (gossip, registrar) = vm.own();
+ (Menu::of(&gossip), registrar.npc())
+ };
+ vm.run(|script| {
let Ok(store) = self_q.single() else {
return; // not in-world yet
};
@@ -540,7 +564,7 @@ fn charter_probe(
probe.phase = Phase::Done;
return;
};
- let parked = registrar.npc() == Some(npc);
+ let parked = registrar_npc == Some(npc);
let visible = vm_visible(script, "GuildRegistrarFrame");
let cost = vm_charter_cost(script);
if parked && visible && cost == CHARTER_COST_COPPER {
@@ -592,7 +616,7 @@ fn charter_probe(
An SMSG_PETITION_SHOWLIST with no parse arm at all \
falls through to ServerPacket::Other — that is what this reading looks \
like. Lines seen: {:?}",
- registrar.npc(),
+ registrar_npc,
probe_lines(script)
),
);
@@ -1067,7 +1091,7 @@ fn hop(probe: &mut CharterProbe, net: &NetCommands, now: f64) {
/// select by the row's wire index, never its list position. Sets `probe.phase` on every path.
fn assert_icon_and_select(
probe: &mut CharterProbe,
- gossip: &GossipState,
+ gossip: &Menu,
script: &UiScript,
net: &NetCommands,
npc: u64,
@@ -1165,6 +1189,7 @@ fn assert_icon_and_select(
let _ = net.0.send(ClientCommand::GossipSelectOption {
guid: npc,
option: opt.index,
+ code: None,
});
info!(
"PROBE_CHARTER: 4 (registrar) GossipSelectOption({npc:#x}, wire index {}) sent for {:?}",
diff --git a/crates/benilla-app/src/capture/probe_chest.rs b/crates/benilla-app/src/capture/probe_chest.rs
index e33b96741..13d716565 100644
--- a/crates/benilla-app/src/capture/probe_chest.rs
+++ b/crates/benilla-app/src/capture/probe_chest.rs
@@ -125,7 +125,20 @@ fn target() -> [f32; 4] {
}
/// Whether `LootFrame` is shown (after `LOOT_OPENED`), else the app-side loot session.
-fn window_open(script: &UiScript, loot: &LootState) -> bool {
+/// The loot window's source as the step reads it, taken outside the VM: the loot verbs write the
+/// state in the host, which the step's Lua runs with.
+struct LootView(Option);
+
+impl LootView {
+ fn source(&self) -> Option {
+ self.0
+ }
+}
+
+/// The loot latch's guid ([`LootLatch`]), taken as [`LootView`] is.
+struct LatchView(Option);
+
+fn window_open(script: &UiScript, loot: &LootView) -> bool {
script
.eval::("return LootFrame:IsShown() and 1 or nil")
.unwrap_or_else(|_| loot.source().is_some())
@@ -178,7 +191,12 @@ fn chest_probe(
net: Res,
mut exit: MessageWriter,
) {
- vm.turn(|script, (loot, latch)| {
+ // The step's Lua runs with the host lent, so the calls it makes apply inside their verbs.
+ let (loot, latch) = {
+ let (loot, latch) = vm.own();
+ (LootView(loot.source()), LatchView(latch.0))
+ };
+ vm.run(|script| {
let Ok(driver) = self_q.single() else {
return; // not in-world yet
};
diff --git a/crates/benilla-app/src/capture/probe_clam.rs b/crates/benilla-app/src/capture/probe_clam.rs
index c2a726a32..129cc1655 100644
--- a/crates/benilla-app/src/capture/probe_clam.rs
+++ b/crates/benilla-app/src/capture/probe_clam.rs
@@ -54,7 +54,16 @@ pub(crate) struct ProbeClamPlugin;
impl Plugin for ProbeClamPlugin {
fn build(&self, app: &mut App) {
app.init_resource::()
- .add_systems(Update, clam_probe);
+ .add_systems(Update, (hold_auto_loot_off, clam_probe).chain());
+ }
+}
+
+/// The window must survive to be looked at: with auto-loot on, the single row is taken at the open
+/// edge and the last-row auto-release shuts it again immediately. Its own system, as the VM's call
+/// host reads the config the probe writes.
+fn hold_auto_loot_off(mut cfg: ResMut) {
+ if cfg.auto_loot {
+ cfg.auto_loot = false;
}
}
@@ -143,7 +152,20 @@ fn slot_grey(script: &UiScript, slot: u32) -> bool {
/// Whether the live `LootFrame` is shown, which needs `LOOT_OPENED` to have fired; falls back to
/// the app-side session when the frame cannot be read.
-fn window_open(script: &UiScript, loot: &LootState) -> bool {
+/// The loot window's source as the step reads it, taken outside the VM: the loot verbs write the
+/// state in the host, which the step's Lua runs with.
+struct LootView(Option);
+
+impl LootView {
+ fn source(&self) -> Option {
+ self.0
+ }
+}
+
+/// The loot latch's guid ([`LootLatch`]), taken as [`LootView`] is.
+struct LatchView(Option);
+
+fn window_open(script: &UiScript, loot: &LootView) -> bool {
script
.eval::("return LootFrame:IsShown() and 1 or nil")
.unwrap_or_else(|_| loot.source().is_some())
@@ -182,11 +204,15 @@ fn clam_probe(
self_store: Query<&ObjectStore, With>,
objects: Objects,
items: Res,
- mut cfg: ResMut,
net: Res,
mut exit: MessageWriter,
) {
- vm.turn(|script, (loot, latch)| {
+ // The step's Lua runs with the host lent, so the calls it makes apply inside their verbs.
+ let (loot, latch) = {
+ let (loot, latch) = vm.own();
+ (LootView(loot.source()), LatchView(latch.0))
+ };
+ vm.run(|script| {
let Ok(store) = self_store.single() else {
return; // not in-world yet
};
@@ -198,9 +224,6 @@ fn clam_probe(
match probe.phase {
Phase::Wait => {
- // The window must survive to be looked at: with auto-loot on, the single row is
- // taken at the open edge and the last-row auto-release shuts it again immediately.
- cfg.auto_loot = false;
info!(
"PROBE_CLAM: stocking one openable item (entry {entry}) — auto-loot forced off"
);
diff --git a/crates/benilla-app/src/capture/probe_crossing.rs b/crates/benilla-app/src/capture/probe_crossing.rs
index 031646d85..39cb10f16 100644
--- a/crates/benilla-app/src/capture/probe_crossing.rs
+++ b/crates/benilla-app/src/capture/probe_crossing.rs
@@ -148,7 +148,7 @@ fn crossing_probe(
continue;
}
let sample = transport.sample_at(anchor, map);
- if sample.map != map || sample.moving {
+ if sample.map != map || sample.moving() {
continue;
}
// Only a nearby ferry: after a cross-continent `.go` the departed surroundings'
@@ -214,7 +214,7 @@ fn crossing_probe(
transports.iter().find(|(g, ..)| g.0 == boat)
{
let sample = transport.sample_at(anchor, map);
- if sample.map == to_map && !sample.moving {
+ if sample.map == to_map && !sample.moving() {
info!(
"PROBE crossing: SUCCESS — docked on map {to_map} still aboard {boat:#x}"
);
diff --git a/crates/benilla-app/src/capture/probe_guard_poi.rs b/crates/benilla-app/src/capture/probe_guard_poi.rs
index e4e707c2c..4080b6733 100644
--- a/crates/benilla-app/src/capture/probe_guard_poi.rs
+++ b/crates/benilla-app/src/capture/probe_guard_poi.rs
@@ -133,6 +133,7 @@ fn guard_poi_probe(
let _ = net.0.send(ClientCommand::GossipSelectOption {
guid: guard,
option,
+ code: None,
});
probe.phase = Phase::Asked { sent_at: now };
} else if now - sent_at > 8.0 {
diff --git a/crates/benilla-app/src/capture/probe_mail.rs b/crates/benilla-app/src/capture/probe_mail.rs
index 41de4a1f6..1a94f3ad0 100644
--- a/crates/benilla-app/src/capture/probe_mail.rs
+++ b/crates/benilla-app/src/capture/probe_mail.rs
@@ -140,20 +140,41 @@ enum Phase {
Done,
}
+/// The inbox as the step reads it, taken outside the VM: the mail verbs write the session in the
+/// host, which the step's Lua runs with.
+struct Inbox {
+ mails: Vec,
+ /// The bodies the rows' `item_text_id`s have, as the cache holds them.
+ bodies: std::collections::HashMap,
+}
+
+impl Inbox {
+ fn of(mail: &MailOpen) -> Self {
+ Inbox {
+ mails: mail.mails.clone(),
+ bodies: mail
+ .mails
+ .iter()
+ .filter_map(|e| Some((e.item_text_id, mail.bodies.get(e.item_text_id)?.clone())))
+ .collect(),
+ }
+ }
+}
+
/// The first row matching `pred`, by its stable `message_id`.
-fn find_by(mail: &MailOpen, pred: impl Fn(&MailListEntry) -> bool) -> Option {
+fn find_by(mail: &Inbox, pred: impl Fn(&MailListEntry) -> bool) -> Option {
mail.mails.iter().find(|e| pred(e)).map(|e| e.message_id)
}
/// The 1-based display index a `message_id` currently sits at, `None` once it is gone.
-fn index_of(mail: &MailOpen, mail_id: u32) -> Option {
+fn index_of(mail: &Inbox, mail_id: u32) -> Option {
mail.mails
.iter()
.position(|e| e.message_id == mail_id)
.map(|i| i as u32 + 1)
}
-fn entry_of(mail: &MailOpen, mail_id: u32) -> Option<&MailListEntry> {
+fn entry_of(mail: &Inbox, mail_id: u32) -> Option<&MailListEntry> {
mail.mails.iter().find(|e| e.message_id == mail_id)
}
@@ -174,16 +195,19 @@ fn last_event(script: &UiScript) -> String {
fn mail_probe(
time: ProbeClock,
mut probe: ResMut,
- mail: Res,
mut windows: Commands,
- mut hosted_vm: crate::script_calls::HostedVm,
+ // The session is the call host's too ([`crate::ui_mail::MailVerbs`]), so it is read outside
+ // the VM.
+ mut vm: crate::script_calls::VmWith>,
self_player: Query<(), With>,
player: Res,
objects: Query<(&Guid, &NetEntity, &ObjectStore, &Transform), Without>,
net: Res,
mut exit: MessageWriter,
) {
- hosted_vm.run(|script| {
+ // The step's Lua runs with the host lent, so the calls it makes apply inside their verbs.
+ let mail = Inbox::of(&vm.own());
+ vm.run(|script| {
if self_player.is_empty() {
return; // not in-world yet
}
@@ -355,7 +379,7 @@ fn mail_probe(
};
let landed = entry_of(&mail, letter_id).and_then(|e| {
(e.item_text_id != 0)
- .then(|| mail.bodies.get(e.item_text_id).cloned())
+ .then(|| mail.bodies.get(&e.item_text_id).cloned())
.flatten()
.map(|body| (body, e.checked & CHECKED_READ != 0))
});
diff --git a/crates/benilla-app/src/capture/probe_partner.rs b/crates/benilla-app/src/capture/probe_partner.rs
index a221e8359..7570d0885 100644
--- a/crates/benilla-app/src/capture/probe_partner.rs
+++ b/crates/benilla-app/src/capture/probe_partner.rs
@@ -16,8 +16,9 @@ impl Plugin for ProbePartnerPlugin {
}
}
-/// Accept a pending invite the frame it lands; taking `pending_invite` keeps the invite popup
-/// from arming, and a racing `DeclineGroup` is a no-op once grouped (`GroupHandler.cpp:200`).
+/// Accept each invite the frame it lands, by the inviter [`GroupState::pending_invite`] keeps for
+/// this probe. The invite popup still shows, and a `DeclineGroup` it sends later is a no-op once
+/// grouped (`GroupHandler.cpp:200`).
fn partner_probe(
self_player: Query<(), With>,
mut group: ResMut,
diff --git a/crates/benilla-app/src/capture/probe_service.rs b/crates/benilla-app/src/capture/probe_service.rs
index 6fac8f1b6..e25123821 100644
--- a/crates/benilla-app/src/capture/probe_service.rs
+++ b/crates/benilla-app/src/capture/probe_service.rs
@@ -281,13 +281,18 @@ fn open_window(
None
}
+/// The NPC windows' cells the probe reads, lent with the VM since the host holds them.
+type ServiceWindows = (
+ ResMut<'static, MerchantOpen>,
+ ResMut<'static, GossipState>,
+ ResMut<'static, QuestGiver>,
+ ResMut<'static, TrainerOpen>,
+);
+
fn service_probe(
- mut vm: crate::script_calls::VmWith>,
+ mut vm: crate::script_calls::VmWith,
time: ProbeClock,
mut probe: ResMut,
- mut gossip: ResMut,
- mut giver: ResMut,
- mut trainer: ResMut,
// `[0xb4e2d0]`'s mirror, what the re-click gate reads: armed by a window and only by one.
interact: Res,
objects: crate::net::Objects,
@@ -300,12 +305,16 @@ fn service_probe(
) {
// The cursor legs pick up through the binding and read the bags through Lua, with the host
// lent so a call that Lua makes applies inside its verb; the rest is an engine turn over the
- // merchant window.
+ // merchant, gossip and questgiver windows.
let lent = matches!(
probe.phase,
Phase::VendorArm { .. } | Phase::VendorSell { .. }
);
- let mut step = |script: Option<&mut UiScript>, mut merchant: Option<&mut MerchantOpen>| {
+ let mut step = |script: Option<&mut UiScript>,
+ mut merchant: Option<&mut MerchantOpen>,
+ mut gossip: Option<&mut GossipState>,
+ mut giver: Option<&mut QuestGiver>,
+ mut trainer: Option<&mut TrainerOpen>| {
if self_player.is_empty() {
return; // not in-world yet
}
@@ -316,6 +325,13 @@ fn service_probe(
hop(&mut probe, &net, 0, 0, now);
}
Phase::Hop { i, hop: h, sent_at } => {
+ let (Some(gossip), Some(giver), Some(trainer)) = (
+ gossip.as_deref_mut(),
+ giver.as_deref_mut(),
+ trainer.as_deref_mut(),
+ ) else {
+ return;
+ };
if now - sent_at < SETTLE_SECS {
return;
}
@@ -454,6 +470,15 @@ fn service_probe(
let _ = net.0.send(cmd);
named
}
+ // `TalkToTrainer`'s asked guid (`0x5df69f`), which the list's open tests, and
+ // its send; no trainer is open here for its close.
+ ServiceAction::TalkToTrainer => {
+ trainer.asked = guid;
+ let cmd = ClientCommand::TrainerList { trainer: guid };
+ let named = format!("{cmd:?}");
+ let _ = net.0.send(cmd);
+ named
+ }
// No leg here takes a dialog arm; if one ever does, say so rather than hang.
other => {
let why: &str = match other {
@@ -463,9 +488,9 @@ fn service_probe(
"adopts the area spirit healer; the packet leaves from the cache"
}
ServiceAction::Silent(w) => w,
- ServiceAction::Send(_) | ServiceAction::SellFromCursor(_) => {
- unreachable!()
- }
+ ServiceAction::Send(_)
+ | ServiceAction::SellFromCursor(_)
+ | ServiceAction::TalkToTrainer => unreachable!(),
};
warn!(
"PROBE_SERVICE: SKIP ({}) — arm {arm:?} opens no window from a packet \
@@ -490,8 +515,15 @@ fn service_probe(
};
}
Phase::Await { i, since, guid } => {
+ let (Some(gossip), Some(giver), Some(trainer)) = (
+ gossip.as_deref_mut(),
+ giver.as_deref_mut(),
+ trainer.as_deref_mut(),
+ ) else {
+ return;
+ };
let leg = &LEGS[i];
- match open_window(guid, &gossip, &giver, &trainer) {
+ match open_window(guid, gossip, giver, trainer) {
Some(open) if open == leg.want_window => {
info!(
"PROBE_SERVICE: PASS ({}) — {:?} window open on {guid:#x}{}",
@@ -576,6 +608,13 @@ fn service_probe(
}
// ── The vendor fork ──────────────────────────────────────────────────
Phase::VendorHop { sent_at } => {
+ let (Some(gossip), Some(giver), Some(trainer)) = (
+ gossip.as_deref_mut(),
+ giver.as_deref_mut(),
+ trainer.as_deref_mut(),
+ ) else {
+ return;
+ };
if now - sent_at < SETTLE_SECS {
return;
}
@@ -807,9 +846,19 @@ fn service_probe(
}
};
if lent {
- vm.run(|script| step(script, None));
+ vm.run(|script| step(script, None, None, None, None));
} else {
- vm.turn(|script, mut merchant| step(script, Some(&mut *merchant)));
+ vm.turn(
+ |script, (mut merchant, mut gossip, mut giver, mut trainer)| {
+ step(
+ script,
+ Some(&mut *merchant),
+ Some(&mut *gossip),
+ Some(&mut *giver),
+ Some(&mut *trainer),
+ )
+ },
+ );
}
}
diff --git a/crates/benilla-app/src/capture/probe_vendor_swap.rs b/crates/benilla-app/src/capture/probe_vendor_swap.rs
index bb9d819e0..d580cdd5d 100644
--- a/crates/benilla-app/src/capture/probe_vendor_swap.rs
+++ b/crates/benilla-app/src/capture/probe_vendor_swap.rs
@@ -142,8 +142,7 @@ fn clear_log(script: &UiScript) {
fn vendor_swap_probe(
time: ProbeClock,
mut probe: ResMut,
- merchant: Res,
- mut hosted_vm: crate::script_calls::HostedVm,
+ mut hosted_vm: crate::script_calls::VmWith>,
names: Res,
panes: Res,
images: Res,
@@ -153,6 +152,8 @@ fn vendor_swap_probe(
net: Res,
mut exit: MessageWriter,
) {
+ // The cell as the frame found it; a call inside the run below writes it through the host.
+ let vendor = hosted_vm.own().vendor;
hosted_vm.run(|script| {
if self_player.is_empty() {
return; // not in-world yet
@@ -235,7 +236,7 @@ fn vendor_swap_probe(
.resolve_unit(brog, None, Ask::Read)
.unwrap_or("")
.to_string();
- match (merchant.vendor == Some(brog), first_show(script)) {
+ match (vendor == Some(brog), first_show(script)) {
(true, Some((npc, title))) => {
if npc == expect && title == expect {
info!(
@@ -256,7 +257,7 @@ fn vendor_swap_probe(
error!(
"PROBE_VENDOR_SWAP: open FAIL — no merchant window + MERCHANT_SHOW on \
Brog within {WINDOW_TIMEOUT_SECS}s (vendor = {:?})",
- merchant.vendor
+ vendor
);
probe.fails += 1;
probe.phase = Phase::Done;
@@ -296,7 +297,7 @@ fn vendor_swap_probe(
.resolve_unit(dobbins, None, Ask::Read)
.unwrap_or("")
.to_string();
- match (merchant.vendor == Some(dobbins), first_show(script)) {
+ match (vendor == Some(dobbins), first_show(script)) {
(true, Some((npc, title))) => {
if npc == expect && title == expect {
info!(
@@ -317,7 +318,7 @@ fn vendor_swap_probe(
error!(
"PROBE_VENDOR_SWAP: swap FAIL — no window swap + MERCHANT_SHOW on \
Dobbins within {WINDOW_TIMEOUT_SECS}s (vendor = {:?})",
- merchant.vendor
+ vendor
);
probe.fails += 1;
probe.phase = Phase::Done;
@@ -357,7 +358,7 @@ fn vendor_swap_probe(
}
Phase::Clear { since, closed_at } => {
match closed_at {
- None if merchant.vendor.is_none() => {
+ None if vendor.is_none() => {
probe.phase = Phase::Clear {
since,
closed_at: Some(now),
@@ -367,7 +368,7 @@ fn vendor_swap_probe(
error!(
"PROBE_VENDOR_SWAP: clear FAIL — the session never cleared after \
HideUIPanel (vendor = {:?})",
- merchant.vendor
+ vendor
);
probe.fails += 1;
probe.phase = Phase::Done;
diff --git a/crates/benilla-app/src/capture/probes/lift_census.rs b/crates/benilla-app/src/capture/probes/lift_census.rs
index dcdefe9e0..409e2d249 100644
--- a/crates/benilla-app/src/capture/probes/lift_census.rs
+++ b/crates/benilla-app/src/capture/probes/lift_census.rs
@@ -134,7 +134,7 @@ fn fire_lift_census(
net.display_id.unwrap_or(0),
transport.map_or(0, Transport::period_ms),
cycle.map_or_else(|| "-".into(), |c| c.to_string()),
- sample.map_or(0, |s| u8::from(s.moving)),
+ sample.map_or(0, |s| u8::from(s.moving())),
vis.map_or_else(|| "absent".into(), |v| format!("{v:?}")),
inherited.map_or(0, |i| u8::from(i.get())),
u8::from(attached),
diff --git a/crates/benilla-app/src/capture/probes/reveal.rs b/crates/benilla-app/src/capture/probes/reveal.rs
index a9e3b31e3..d9ee8f44b 100644
--- a/crates/benilla-app/src/capture/probes/reveal.rs
+++ b/crates/benilla-app/src/capture/probes/reveal.rs
@@ -2,7 +2,15 @@
//! worldport), naming every term that decides whether the destination is drawn. Residency columns
//! (`res`, `focus`, `scene`, `place`, `coll`, `merge`, `gx`) are the terms behind
//! [`WorldLoadProgress::presentable`], which the cover waits on; draw columns (`drawn`, `hid`,
-//! `sel`, `room`, `win`, `pvslag`) are what the frame put on screen.
+//! `sel`, `room`, `win`, `pvslag`) are what the frame put on screen, and `pres` the frames the
+//! window has presented since the snap ([`crate::loading_screen::hold::Presents`]).
+//!
+//! At the settle release one `REVEAL_SUM` line closes the window from the snap to residency:
+//! `frames`, the frames it took; `presented`, how many the window presented (counted at the
+//! release frame, so the release frame's own present is not in it); and `drawn` and `wmo`, the
+//! submeshes and retained-pass WMOs that came on screen after the first frame shown, the sum of
+//! each shown frame's growth over the last one shown (a frame
+//! [`crate::loading_screen::hold::PresentHold`] holds is not shown).
//!
//! Runs in `Last`: visibility, the exterior-scene gate and the retained pass settle in
//! `PostUpdate`, so an `Update` line would report them a frame late.
@@ -22,6 +30,20 @@ struct RevealAudit {
n: Option,
/// [`ProbeClock`] seconds at the arming snap, the base of the `t=` column.
since: f32,
+ /// The snap-to-residency window's tally, `None` once its summary is printed.
+ window: Option,
+}
+
+/// One snap's tally up to the settle release, for the `REVEAL_SUM` line.
+struct RevealWindow {
+ /// [`crate::loading_screen::hold::Presents`] at the snap.
+ presents_at_snap: u64,
+ frames: u32,
+ /// Submeshes and WMOs drawn in the last frame shown, the baseline for growth.
+ last_drawn: Option<(usize, usize)>,
+ /// What came on screen in frames shown.
+ drawn_grew: usize,
+ wmo_grew: usize,
}
pub(crate) struct RevealAuditPlugin;
@@ -36,6 +58,7 @@ impl Plugin for RevealAuditPlugin {
frames,
n: None,
since: 0.0,
+ window: None,
})
// `Last`: after residency, the loading screen and `PostUpdate`'s visibility.
.add_systems(Last, drive_reveal_audit);
@@ -51,22 +74,33 @@ fn drive_reveal_audit(
census: WorldCensus,
cam: Query<&GlobalTransform, With>,
time: ProbeClock,
+ presents: Option>,
+ hold: Option>,
mut teleports: MessageReader,
mut worldports: MessageReader,
) {
let now = time.elapsed_secs();
+ let presented = presents
+ .as_deref()
+ .map_or(0, crate::loading_screen::hold::Presents::count);
if teleports.read().next().is_some() || worldports.read().next().is_some() {
audit.n = Some(0);
audit.since = now;
+ audit.window = Some(RevealWindow {
+ presents_at_snap: presented,
+ frames: 0,
+ last_drawn: None,
+ drawn_grew: 0,
+ wmo_grew: 0,
+ });
}
- let Some(n) = audit.n else {
- return;
- };
- if n >= audit.frames {
- audit.n = None;
+ // The per-frame lines run for `frames` after the snap; the summary's tally runs to the release.
+ let in_window = audit.n.is_some_and(|n| n < audit.frames);
+ let n = audit.n.unwrap_or(0);
+ audit.n = in_window.then_some(n + 1);
+ if !in_window && audit.window.is_none() {
return;
}
- audit.n = Some(n + 1);
let (collected, published, selected) = gx
.as_deref()
@@ -75,6 +109,39 @@ fn drive_reveal_audit(
.as_deref()
.map_or((0, 0, 0), benilla_world::static_gx::StaticGx::draw_census);
let seen = census.take();
+ let settling = player.as_ref().is_some_and(|p| p.settling);
+ let since = audit.since;
+ if let Some(w) = audit.window.as_mut() {
+ w.frames += 1;
+ // A held frame never reaches the window, so what it drew is not on screen.
+ if !hold
+ .as_deref()
+ .is_some_and(crate::loading_screen::hold::PresentHold::held)
+ {
+ let shown = (seen.drawn, wmo_drawn);
+ if let Some((d, g)) = w.last_drawn {
+ w.drawn_grew += shown.0.saturating_sub(d);
+ w.wmo_grew += shown.1.saturating_sub(g);
+ }
+ w.last_drawn = Some(shown);
+ }
+ // A snap the stream already holds releases on its own frame: `frames=1`.
+ if !settling {
+ info!(
+ "REVEAL_SUM frames={} t={:.0}ms presented={} drawn={} wmo={} cover={}",
+ w.frames,
+ (now - since) * 1000.0,
+ presented - w.presents_at_snap,
+ w.drawn_grew,
+ w.wmo_grew,
+ u8::from(screen.covering()),
+ );
+ audit.window = None;
+ }
+ }
+ if !in_window {
+ return;
+ }
// Distance from the visibility authority's eye to the drawn camera: ~0 in steady play.
let pvs_lag = match (seen.pvs_eye, cam.iter().next()) {
(Some(eye), Some(now_eye)) => eye.distance(now_eye.translation()),
@@ -82,7 +149,7 @@ fn drive_reveal_audit(
};
info!(
"REVEAL n={n} t={:.0}ms cover={} res={}/{} focus={} scene={} place={} coll={} merge={} \
- gx={} wmo={collected}/{published}/{selected} settling={} | drawn={}/{} hid={}/{} \
+ gx={} wmo={collected}/{published}/{selected} settling={} pres={} | drawn={}/{} hid={}/{} \
sel={cells_drawn}/{wmo_drawn}/{groups_drawn} room={} win={} pvslag={pvs_lag:.0}",
(now - audit.since) * 1000.0,
u8::from(screen.covering()),
@@ -94,7 +161,11 @@ fn drive_reveal_audit(
progress.colliders_pending,
progress.merge_pending,
progress.gx_pending,
- u8::from(player.is_some_and(|p| p.settling)),
+ u8::from(settling),
+ audit
+ .window
+ .as_ref()
+ .map_or(0, |w| presented - w.presents_at_snap),
seen.drawn,
seen.submeshes,
seen.hidden,
diff --git a/crates/benilla-app/src/chat_bubble.rs b/crates/benilla-app/src/chat_bubble.rs
index 5838f928e..a66ead169 100644
--- a/crates/benilla-app/src/chat_bubble.rs
+++ b/crates/benilla-app/src/chat_bubble.rs
@@ -9,7 +9,8 @@
//! 20 yd (3-D). Self is not excluded. A new line replaces the old bubble, never queues.
//! - Lifetime and fade (`0x4b0c30`): a 250 ms fade in, the line's [`duration_ms`], a 250 ms fade
//! out, then the frame goes back to the pool. Out of range, or with the speaker not drawn in the
-//! last render ([`speaker_drawn`]), it fades out and hides, and fades back in on return.
+//! last render ([`crate::entities::SceneDrawn`]), it fades out and hides, and fades back in on
+//! return.
//! - Anchor (`0x4b0c30`): unit z + height × model scale + 0.7, the text's BOTTOM on the projected
//! point (`0x4b157a`), growing upward. The height is the Stand sequence box's Z extent from the
//! model header (`0x711a20`), not the posed attachment the overhead name reads (`0x608640`),
@@ -312,22 +313,6 @@ struct Bubble {
depth: Option,
}
-/// Whether the speaker was drawn in the last render: the reference's scene-node test `0x6704c0`
-/// (`node && [node+0x94] == 0`, read at `0x4b0cab`). Every frame sets `[node+0x94]` on every node
-/// in the scene list `[0xca7d70]` (`0x698a07`) and clears it only for a node that passes the
-/// frustum test `0x682ef0` and the horizon test `0x686000` (`0x6833dd`-`0x6833ec`, and
-/// `0x68359b`-`0x6835aa` in WMO groups). Here it is any of the unit's meshes passing last frame's
-/// visibility check; benilla has no horizon cull yet, so that is the frustum verdict alone.
-fn speaker_drawn(
- unit: Entity,
- children: &Query<&Children>,
- meshes: &Query<&ViewVisibility, With>,
-) -> bool {
- children
- .get(unit)
- .is_ok_and(|kids| kids.iter().any(|c| meshes.get(c).is_ok_and(|v| v.get())))
-}
-
/// The live bubbles by speaker guid, at most one per unit, their stacking, and the next line's
/// number.
#[derive(Resource, Default)]
@@ -419,8 +404,8 @@ fn drive_bubbles(
time: Res