Death, logout and the taxi flag read live and signal at their packets (#2796)

Three windows still answered from a copy a feed refreshed once a frame, and fired their events there.

**Reference**
- The cursor's control gate reads our unit's taxi bit at the call (`0x494b97`-`0x494ba6`).
- PLAYER_CAMPING, PLAYER_QUITING, LOGOUT_CANCEL and the logout-failed line are raised by their packets' handlers (`0x5aaf17`, `0x5aaf72`, `0x5aaf26`).
- The death signals fire at their packets, and the corpse range is checked each frame (`0x492130`).

**Changed**
- The taxi gate reads the flag off our object.
- The logout replies go on the notice lane at their handlers.
- The death getters (GetCorpseRecoveryDelay and the rest) read live, and the death signals fire at their packets.
- `feed_on_taxi`, `feed_logout` and `feed_death` are gone.

The fake world server logs a session before answering its authentication, which a loaded test run read behind.

**Tests:** each getter read between two feeds, and each event between its neighbouring packets' events.

Part of #2168 and #2217.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sam Sung
2026-10-29 11:55:07 +07:00
committed by GitHub
parent 5d1f7ad395
commit d12054da65
33 changed files with 1050 additions and 784 deletions
+254 -472
View File
@@ -1,21 +1,24 @@
//! Death and resurrection: the wire-fed stores, the events into the Lua UI and the intents back
//! to the wire. Dead is health 0 and ghost is `PLAYER_FLAGS` bit 0x10, read off the self
//! descriptor each frame. The death state signals (`PLAYER_DEAD` or `PLAYER_ALIVE`) inside our
//! own death's handler ([`signal_death_state`]) and after each arrival's world-enter cascade
//! ([`feed_death`]), and `PLAYER_ALIVE` on release and on a pre-release res. The
//! cascade releases a body it finds dead ([`repop_on_world_enter`]).
//! `PLAYER_UNGHOST` is the ghost state's (`0x5de9c0`), signalled where it runs: the ghost bit's
//! clear ([`crate::field_watch`]) and an alive arrival (`crate::ui_unit`).
//! to the wire. Dead is health 0 and ghost is `PLAYER_FLAGS` bit 0x10. The getters read the
//! stores through the host as they run ([`DeathView`]). The death state signals (`PLAYER_DEAD` or
//! `PLAYER_ALIVE`) inside our own death's handler and after each arrival's world-enter cascade
//! ([`signal_death_state`]), and `PLAYER_ALIVE` in the health watcher's revive arm, on release
//! and on a res ([`crate::field_watch`]). The offers and the corpse-range signals that packets
//! raise go on the dialogs' lane at their handlers ([`net`]); the corpse range's own poll runs in
//! the world frame's update ([`poll_corpse`]). The cascade releases a body it finds dead
//! ([`repop_on_world_enter`]). `PLAYER_UNGHOST` is the ghost state's (`0x5de9c0`), signalled where
//! it runs: the ghost bit's clear ([`crate::field_watch`]) and an alive arrival (`crate::ui_unit`).
use bevy::prelude::*;
use benilla_assets::coords::wow_to_bevy;
use benilla_ui::script::{DeathAction, DeathUiState, ScriptValue, UiScript};
use benilla_ui::script::{
DeathAction, DeathQuery, DeathUiState, ResSicknessLevelQuery, ScriptValue, UiScript,
};
use crate::net::{ClientCommand, NetCommands, ObjectStore, Objects, SelfGuid, SelfPlayer};
use crate::query_cache::Ask;
use crate::ui_action::Spells;
use crate::ui_script::UiFeed;
pub(crate) mod net;
@@ -42,6 +45,9 @@ pub(crate) struct ResurrectOffer {
pub(crate) sickness: bool,
/// The reclaim-delay gate still holds: RESURRECT, not RESURRECT_NO_TIMER.
pub(crate) has_timer: bool,
/// The caster's name was asked with the callback `0x5e7ca0` (`0x5e7c82`), whose answer shows
/// the offer or forgets it.
pub(crate) waits_name: bool,
}
/// The release timer our own death arms (`0x5e99b0`, `0xb4e340` and its no-timer byte
@@ -69,22 +75,15 @@ pub(crate) struct DeathNet {
pub(crate) release: ReleaseTimer,
/// When the corpse becomes reclaimable: `SMSG_CORPSE_RECLAIM_DELAY` anchored at arrival.
pub(crate) reclaim_at: Option<f64>,
/// Bumped per `SMSG_CORPSE_RECLAIM_DELAY`: the 1.12 client's handler re-fires the range
/// events on each.
pub(crate) reclaim_generation: u32,
/// The last `MSG_CORPSE_QUERY` answer; a not-found drops it.
pub(crate) corpse: Option<CorpsePoint>,
/// A pending resurrection offer; cleared when answered or when the popup times out.
/// A pending resurrection offer (`[0xc4d760]`); cleared when answered, or by a refused name.
pub(crate) resurrect: Option<ResurrectOffer>,
/// Bumped per `SMSG_RESURRECT_REQUEST`: the offer announces per message (`0x5e7bc0` through
/// `0x5ded50`), because the stock UI can hide the popup without answering it.
pub(crate) resurrect_generation: u32,
/// Our streamed corpse object's guid, which `CMSG_RECLAIM_CORPSE` carries like the 1.12 client.
pub(crate) corpse_guid: Option<u64>,
/// The spirit healer awaiting the XP-loss answer; Accept sends `CMSG_SPIRIT_HEALER_ACTIVATE`.
/// The spirit healer awaiting the XP-loss answer (`[0xc4d798]`); Accept sends
/// `CMSG_SPIRIT_HEALER_ACTIVATE`.
pub(crate) spirit_healer: Option<u64>,
/// Bumped per ask: a Cancel clears nothing, so only a fresh ask re-shows the dialog.
pub(crate) confirm_generation: u32,
/// Water-walking is granted on our mover; mirrored, not applied: walking on the water surface
/// is not built.
#[allow(dead_code)]
@@ -107,61 +106,85 @@ impl DeathNet {
pub(crate) fn zero_release(&mut self) {
self.release = ReleaseTimer::Unset;
}
/// Arm the spirit healer's XP-loss question. The reference raises it on the click with no
/// packet (`0x5df730`), and vmangos also pushes `SMSG_SPIRIT_HEALER_CONFIRM`; both come here.
pub(crate) fn ask_spirit_healer(&mut self, npc: u64) {
self.spirit_healer = Some(npc);
self.confirm_generation = self.confirm_generation.wrapping_add(1);
}
}
/// The feed's memory in two scopes: the body's state survives a `/reload`, while what the VM was
/// told dies with the VM.
/// The interface's death globals beside the stores, world-scoped and cleared at the session's end:
/// the body's last state, which the corpse asks' edges compare, and the corpse-range latch. A
/// `/reload` keeps both.
#[derive(Resource, Default)]
pub(crate) struct DeathFeedState {
/// World-scoped: the last `(guid, dead, ghost)` the self body showed.
pub(crate) struct DeathLatches {
/// The last `(guid, dead, ghost)` the self body showed.
mirror: Option<(u64, bool, bool)>,
/// World-scoped: the corpse-range latch `[0xb4e324]`, the last verdict signalled
/// The corpse-range latch `[0xb4e324]`: whether the last verdict signalled was in range
/// (`0x4920f0`), which the cascade's corpse step zeroes into whichever VM is live.
corpse_range: Option<CorpseRange>,
/// A fresh reclaim delay re-fires the range events, as the 1.12 client does (`0x4962d0`),
/// so RECOVER_CORPSE re-shows with the new delay.
reclaim_generation: u32,
/// VM-scoped: the announce latches.
vm: crate::ui_script::VmMemo<DeathAnnounced>,
corpse_in_range: bool,
}
impl DeathFeedState {
impl DeathLatches {
/// The corpse-range latch set, as a ghost in range of its corpse left it.
#[cfg(test)]
pub(crate) fn latch_corpse_in_range_for_test(&mut self) {
self.corpse_range = Some(CorpseRange::In);
self.corpse_in_range = true;
}
/// `SetCorpseInRange 0x4920f0`: on a change (`0x4920f6`), the latch stored and its signal,
/// [`CorpseSignal::in_range`] for in range, `CORPSE_OUT_OF_RANGE` (399, `0x49211f`) for out.
fn set_in_range(
&mut self,
in_range: bool,
corpse: Option<&CorpsePoint>,
) -> Option<CorpseSignal> {
if std::mem::replace(&mut self.corpse_in_range, in_range) == in_range {
return None;
}
Some(if in_range {
CorpseSignal::in_range(corpse)
} else {
CorpseSignal::Out
})
}
}
/// What the live VM has been told. A fresh VM's first sight of the body is no edge: a `/reload`'s
/// cascade signals no death state (`0x490168` never reaches `0x495850`), and an arrival signals it
/// after its cascade (`0x5deb65`, [`signal_death_state`]).
#[derive(Default)]
struct DeathAnnounced {
/// The last `(guid, dead, ghost)` this VM was given an event for.
last: Option<(u64, bool, bool)>,
/// Held back while a player caster's name is still resolving.
offer_generation: u32,
/// The offer whose caster's name was looked up as its packet's (`0x5e7c82`, callback
/// `0x5e7ca0`): the frames that wait on it read.
offer_asked: u32,
/// A fresh ask re-fires `CONFIRM_XP_LOSS`.
confirm_generation: u32,
/// A corpse-range event, each argumentless (`0x703e50`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum CorpseSignal {
/// `CORPSE_IN_RANGE` (397).
In,
/// `CORPSE_IN_INSTANCE` (398).
InInstance,
/// `CORPSE_OUT_OF_RANGE` (399).
Out,
}
/// The corpse-range verdicts the reference's events distinguish.
#[derive(Clone, Copy, PartialEq, Eq)]
enum CorpseRange {
Out,
In,
InInstance,
impl CorpseSignal {
/// The in-range event for the cached corpse: [`Self::InInstance`] when the cache's display
/// map is not the corpse's own, a dungeon's entrance (`0x492102`-`0x492114`,
/// `0x4962f5`-`0x496307`).
fn in_range(corpse: Option<&CorpsePoint>) -> Self {
if corpse.is_some_and(|c| u32::try_from(c.display_map) != Ok(c.corpse_map)) {
Self::InInstance
} else {
Self::In
}
}
/// Signalled in place.
fn fire(self, script: &mut UiScript) {
match self {
Self::In => script.fire_event("CORPSE_IN_RANGE", vec![]),
Self::InInstance => script.fire_event("CORPSE_IN_INSTANCE", vec![]),
Self::Out => script.fire_event("CORPSE_OUT_OF_RANGE", vec![]),
}
}
/// Queued on the dialogs' lane at a handler's place.
fn queue(self, lane: &mut crate::ui_dialog_verbs::DialogLane) {
match self {
Self::In => lane.event("CORPSE_IN_RANGE", vec![]),
Self::InInstance => lane.event("CORPSE_IN_INSTANCE", vec![]),
Self::Out => lane.event("CORPSE_OUT_OF_RANGE", vec![]),
}
}
}
/// The corpse-range dialog radius, 40 yd inclusive: the 1.12 client compares d² ≤ `[0xb4e2ac]`
@@ -172,8 +195,8 @@ const CORPSE_RANGE_SQ: f32 = 40.0 * 40.0;
/// The spirit-healer dialog range: `CheckSpiritHealerDist` compares d² ≤ `[0xc4c28c]` (30.864).
const SPIRIT_HEALER_RANGE_SQ: f32 = 5.5556 * 5.5556;
/// What the death snapshot reads ([`DeathView::snapshot`]): the self body, the death stores and
/// what `HasSoulstone()` walks.
/// What the death getters read through the host as they run ([`DeathQuery`]): the self body, the
/// death stores and what `HasSoulstone()` walks.
#[derive(bevy::ecs::system::SystemParam)]
pub(crate) struct DeathView<'w, 's> {
self_q: Query<'w, 's, (&'static ObjectStore, &'static Transform), With<SelfPlayer>>,
@@ -200,9 +223,9 @@ impl DeathView<'_, '_> {
Some((guid, store, self_t))
}
/// The snapshot the death verbs read, pushed before an event fires so its handlers read
/// current values.
fn snapshot(&self, script: &UiScript, store: &ObjectStore, self_t: &Transform) -> DeathUiState {
/// The death state as the getters read it now: the timers off the stores, and what reads
/// the live body (the healer's range, the self-res) while one is held.
fn state(&self) -> DeathUiState {
let now = self.time.elapsed_secs_f64();
let death_net = &self.death_net;
let release_remaining = match death_net.release {
@@ -214,71 +237,77 @@ impl DeathView<'_, '_> {
let recovery_delay = death_net
.reclaim_at
.map_or(0.0, |at| (at - now).max(0.0) as f32);
let spirit_healer_in_range = death_net.spirit_healer.is_some_and(|npc| {
self.objects
.entity(npc)
.and_then(|e| self.transforms.get(e).ok())
.is_some_and(|t| {
t.translation.distance_squared(self_t.translation) <= SPIRIT_HEALER_RANGE_SQ
})
let body = self.body();
let spirit_healer_in_range = body.is_some_and(|(_, _, self_t)| {
death_net.spirit_healer.is_some_and(|npc| {
self.objects
.entity(npc)
.and_then(|e| self.transforms.get(e).ok())
.is_some_and(|t| {
t.translation.distance_squared(self_t.translation) <= SPIRIT_HEALER_RANGE_SQ
})
})
});
let sickness = sickness_duration(
store.0.unit_level().unwrap_or(0),
benilla_ui::strings::Strings::Vm(script.lua()),
);
DeathUiState {
release_remaining,
recovery_delay,
resurrect_sickness: death_net.resurrect.as_ref().is_some_and(|o| o.sickness),
resurrect_has_timer: death_net.resurrect.as_ref().is_some_and(|o| o.has_timer),
spirit_healer_in_range,
sickness_duration: sickness,
// Worded by the getter off [`ResSicknessLevelQuery`].
sickness_duration: None,
// `HasSoulstone()`; the dead gate is first, so the inventory walk runs only while dead.
self_res_label: resolve_self_res(
&store.0,
&self.objects,
&self.items,
self.spells.as_deref(),
)
.map(|r| r.label().to_owned()),
self_res_label: body.and_then(|(_, store, _)| {
resolve_self_res(&store.0, &self.objects, &self.items, self.spells.as_deref())
.map(|r| r.label().to_owned())
}),
}
}
}
/// Derive the death state from the self descriptor, push the snapshot, and fire the death events
/// on its edges. Our player's arrival signals the death state itself, after its world-enter
/// cascade (`0x5deb65` → `0x495850`, [`signal_death_state`]): a login, a reconnect or a worldport
/// to a dead body hears `PLAYER_DEAD`, any other `PLAYER_ALIVE`.
pub(crate) fn feed_death(
// The death stores, which the death calls write: an engine turn, its events signalled after.
mut vm: crate::script_calls::VmWith<DeathView<'static, 'static>>,
mut feed: ResMut<DeathFeedState>,
names: Res<crate::names::NameCache>,
net: Res<NetCommands>,
map: Option<Res<benilla_world::world_map::CurrentMap>>,
// Our player's create this frame, which runs no watcher (`0x465d80`): its death state is the
// arrival's own signal, not an edge.
arrivals: Query<(), Added<SelfPlayer>>,
) {
let arrived = !arrivals.is_empty();
vm.turn(|script, view| {
let Some(script) = script else {
/// The death getters' family of the host's live reads.
impl crate::script_calls::live::LiveFamily for DeathView<'_, '_> {
fn answer(&mut self, ask: &mut benilla_ui::script::live::LiveAsk<'_>) -> bool {
ask.answer(|_: &DeathQuery| Some(self.state()))
|| ask.answer(|_: &ResSicknessLevelQuery| {
self.body()
.map(|(_, store, _)| store.0.unit_level().unwrap_or(0))
})
}
}
/// What the corpse poll reads and writes beside the host: the self body and the session, the
/// death stores, the latches and the map shown.
type CorpsePoll = (
Query<'static, 'static, (&'static ObjectStore, &'static Transform), With<SelfPlayer>>,
Res<'static, SelfGuid>,
Res<'static, crate::net::NetStatus>,
Res<'static, DeathNet>,
ResMut<'static, DeathLatches>,
Option<Res<'static, benilla_world::world_map::CurrentMap>>,
);
/// `CheckCorpseRange 0x492130`, which the world frame's update runs every frame after its pick
/// (`0x4818c5`, in `0x481790`'s unconditional tail): a ghost on the map shown within 40 yards of
/// the cached corpse is in range (`0x492196`), and `SetCorpseInRange` signals a change in place
/// ([`DeathLatches::set_in_range`]). Ahead of it, the corpse asks of the ghost bit's edges, which
/// a `/reload` must not repeat.
pub(crate) fn poll_corpse(mut vm: crate::script_calls::VmWith<CorpsePoll>, net: Res<NetCommands>) {
let signal = {
let (self_q, self_guid, status, death_net, mut latches, map) = vm.own();
// A disconnect keeps the self avatar with its frozen descriptor; only a live session's
// body counts.
let body = self_guid
.0
.filter(|_| status.connected)
.and_then(|guid| Some((guid, self_q.single().ok()?)));
let Some((guid, (store, self_t))) = body else {
return;
};
let Some((guid, store, self_t)) = view.body() else {
return;
};
let death_net = &view.death_net;
let dead = store.0.unit_is_dead();
let ghost = store.0.player_is_ghost();
// ── The snapshot, set before the events fire so their handlers read current values ──
let snapshot = view.snapshot(script, store, self_t);
script.set_death(snapshot);
// ── The world edges: the corpse asks, which a `/reload` must not repeat.
let prev = feed.mirror.filter(|&(g, ..)| g == guid);
feed.mirror = Some((guid, dead, ghost));
let prev = latches.mirror.filter(|&(g, ..)| g == guid);
latches.mirror = Some((guid, dead, ghost));
match (prev, dead, ghost) {
// Dead to ghost (released): ask where the corpse is.
(Some((_, true, false)), _, true) => {
@@ -294,116 +323,52 @@ pub(crate) fn feed_death(
}
_ => {}
}
// ── The VM edges: a fresh VM's memo is empty, and its first sight is no edge.
let memo = feed.vm.get(script);
let prev = memo.last.filter(|&(g, ..)| g == guid && !arrived);
memo.last = Some((guid, dead, ghost));
fire_vm_edges(script, prev.map(|(_, d, g)| (d, g)), dead, ghost);
// ── The offer and confirm announcements ──
let ask = Ask::at(
std::mem::replace(&mut memo.offer_asked, death_net.resurrect_generation)
!= death_net.resurrect_generation,
&net,
);
if let Some(name) =
offer_announcement(memo, death_net, store.0.is_dead_or_ghost(), |offer| {
// A player caster's name is empty on the wire; hold the popup until the cache
// resolves it.
if offer.name.is_empty() {
names.resolve_player(offer.caster, ask).map(str::to_owned)
} else {
Some(offer.name.clone())
}
})
{
script.fire_event("RESURRECT_REQUEST", vec![ScriptValue::Str(name)]);
}
if death_net.spirit_healer.is_some()
&& memo.confirm_generation != death_net.confirm_generation
{
memo.confirm_generation = death_net.confirm_generation;
// `arg1` is the XP the res costs: `PLAYER_NEXT_LEVEL_XP` × 0.05, truncated
// (`0x5df837`), and 0 without the field, as `0x5df806` pushes 0 for a non-local object.
// No stock FrameXML reads it; `UIParent.lua:399` asks `GetResSicknessDuration()`.
let xp_cost = store
.0
.player_next_level_xp()
.map_or(0, |next| (f64::from(next) * 0.05) as i64);
script.fire_event("CONFIRM_XP_LOSS", vec![ScriptValue::Int(xp_cost)]);
}
// ── The corpse-run range gate: only a ghost, against the query's display position; the
// coordinate transform is isometric, so the Bevy-space compare is in yards.
let range = if ghost {
death_net.corpse.map(|cp| {
// Within range on the display map: IN_RANGE when it is the corpse's map, else
// IN_INSTANCE, at a dungeon's entrance (`0x492130`, `0x4920f0`).
// Against the query's display position; the coordinate transform is isometric, so the
// Bevy-space compare is in yards. The ghost test stands in for the ghost flag's clear of
// the corpse cache, which is not built (`0x5eeac1` → `0x491f50`, #392).
let corpse = death_net.corpse.as_ref();
let in_range = ghost
&& corpse.is_some_and(|cp| {
// Deviation: `0x492130` compares the positions whatever map we stand on, so a
// ghost on another map at the corpse's coordinates reads in range for a reclaim
// the server refuses; here only the corpse's display map counts.
let on_display_map = map
.as_ref()
.is_some_and(|m| m.0 == u32::try_from(cp.display_map).unwrap_or(u32::MAX));
let near = on_display_map
on_display_map
&& wow_to_bevy(cp.position).distance_squared(self_t.translation)
<= CORPSE_RANGE_SQ;
let same_map = u32::try_from(cp.display_map) == Ok(cp.corpse_map);
match (near, same_map) {
(false, _) => CorpseRange::Out,
(true, true) => CorpseRange::In,
(true, false) => CorpseRange::InInstance,
}
})
} else {
None
};
if feed.reclaim_generation != death_net.reclaim_generation {
feed.reclaim_generation = death_net.reclaim_generation;
feed.corpse_range = None; // re-announce whatever holds now
}
if range != feed.corpse_range {
match range {
Some(CorpseRange::In) => script.fire_event("CORPSE_IN_RANGE", vec![]),
Some(CorpseRange::InInstance) => script.fire_event("CORPSE_IN_INSTANCE", vec![]),
// Leaving range and the ghost state ending both fire the one hide event.
Some(CorpseRange::Out) | None if feed.corpse_range.is_some() => {
script.fire_event("CORPSE_OUT_OF_RANGE", vec![]);
}
_ => {}
<= CORPSE_RANGE_SQ
});
latches.set_in_range(in_range, corpse)
};
if let Some(signal) = signal {
vm.run(|script| {
if let Some(script) = script {
signal.fire(script);
}
feed.corpse_range = range;
}
})
});
}
}
/// `SignalDeathState 0x495850`, where our own death's `PresentUnitDeath` ends (`0x6251cc`, for
/// the active player alone, `0x5fa6d0` at `0x6251c2`): with our health 0 or less (`jg` at
/// `0x495876`) `PLAYER_DEAD` (`0x113`, `0x49587d`), its handlers reading the timer the death armed,
/// then `ClearCursor(1, 1)` (`0x495889` → `0x495190`); else `PLAYER_ALIVE` (`0x112`, `0x495893`).
/// The VM's memo takes the state, so the feed signals no edge of it again.
pub(crate) fn signal_death(
mut vm: crate::script_calls::VmWith<DeathView<'static, 'static>>,
mut feed: ResMut<DeathFeedState>,
) {
signal(&mut vm, &mut feed);
/// Its handlers read the timer the death armed through the host.
pub(crate) fn signal_death(mut vm: crate::script_calls::VmWith<DeathView<'static, 'static>>) {
signal(&mut vm);
}
/// [`signal_death`]'s body; false with no VM or no live body, which signals nothing.
fn signal(
vm: &mut crate::script_calls::VmWith<DeathView<'static, 'static>>,
feed: &mut DeathFeedState,
) -> bool {
fn signal(vm: &mut crate::script_calls::VmWith<DeathView<'static, 'static>>) -> bool {
let dead = {
let (Some(script), set) = vm.parts() else {
let (Some(_), set) = vm.parts() else {
return false;
};
let view = set.p0();
let Some((guid, store, self_t)) = view.body() else {
let Some((_, store, _)) = view.body() else {
return false;
};
let snapshot = view.snapshot(script, store, self_t);
script.set_death(snapshot);
let memo = feed.vm.get(script);
memo.last = Some((guid, store.0.unit_is_dead(), store.0.player_is_ghost()));
store.0.unit_health().unwrap_or(0) as i32 <= 0
};
// `0x495850`: the signal's listeners run before the cursor clears (`0x49587d`, `0x495889`).
@@ -449,14 +414,14 @@ fn send_repop_request(store: &benilla_protocol::ObjectFields, net: &NetCommands)
/// The corpse cache and the range latch, beside the host.
type CorpseStores = (
Option<ResMut<'static, DeathNet>>,
Option<ResMut<'static, DeathFeedState>>,
Option<ResMut<'static, DeathLatches>>,
);
/// `QueryCorpse 0x491f50` in the world-enter cascade (`0x490a28`), after its other sends: the
/// corpse cache reset (`0x491f74` → `0x492010(-1, …)`), the range latch zeroed (`0x491f7b` →
/// `0x4920f0(0)`), which signals `CORPSE_OUT_OF_RANGE` from a set latch, then, for a ghost
/// (`PLAYER_FLAGS` bit 4, `0x491fad`), `MSG_CORPSE_QUERY` (`0x491fb2`). The flags watcher's
/// release and revive asks are [`feed_death`]'s.
/// release and revive asks are [`poll_corpse`]'s.
pub(crate) fn query_corpse_on_world_enter(
self_q: Query<&ObjectStore, With<SelfPlayer>>,
mut vm: crate::script_calls::VmWith<CorpseStores>,
@@ -466,12 +431,7 @@ pub(crate) fn query_corpse_on_world_enter(
if let Some(mut death_net) = death_net {
death_net.corpse = None;
}
let was_in = feed.is_some_and(|mut feed| {
matches!(
feed.corpse_range.take(),
Some(CorpseRange::In | CorpseRange::InInstance)
)
});
let was_in = feed.is_some_and(|mut latches| std::mem::take(&mut latches.corpse_in_range));
if was_in {
vm.run(|script| {
if let Some(script) = script {
@@ -594,26 +554,6 @@ fn self_res(
})
}
/// The sickness a spirit-healer res applies at `level`, per vmangos `Player::ResurrectPlayer`:
/// none below 11, `level - 10` minutes through 19, 10 minutes from 20. Worded with `GENERIC_MIN`,
/// the minute arm of the reference's formatter (`0x51a3a0` into `0x52fa50`).
///
/// Deviation: the minutes come from the server's table, not from spell 15007's `Spell.dbc`
/// duration, because the aura the server applies is what the dialog must warn about.
fn sickness_duration(level: u32, strings: benilla_ui::strings::Strings<'_>) -> Option<String> {
let minutes = match level {
0..=10 => return None,
11..=19 => level - 10,
_ => 10,
};
// `GetText(token, nil, ordinal)`, the VM's own.
let template = benilla_ui::strings::plural("GENERIC_MIN", Some(minutes), strings)?;
Some(benilla_ui::strings::fill(
&template,
&[benilla_ui::strings::Arg::D(i64::from(minutes))],
))
}
/// Drive the FFXDeath screen pass off `PLAYER_FLAGS_GHOST`, instant both ways; in the reference
/// the flag's watcher `0x5ee990` also drives the death light and ambience.
fn drive_death_look(
@@ -830,131 +770,90 @@ impl DeathSteps<'_, '_> {
}
}
/// Clear [`DeathFeedState`]'s world scope on `DisconnectedMessage`, the edge [`DeathNet`] resets
/// on: a relog as a ghost must find no mirror, or the corpse query is never re-sent.
fn end_session_death_feed(
mut msgs: MessageReader<crate::net::DisconnectedMessage>,
mut feed: ResMut<DeathFeedState>,
) {
if msgs.read().next().is_some() {
*feed = DeathFeedState::default();
/// `SpiritHealerDialog 0x5df730(npc)` asking: for a ghost (`PLAYER_FLAGS` bit 0x10, `0x5df74a`),
/// the healer `npc` held as a unit (`0x5df77a`) within the interaction range (`0x5df7c1`,
/// `[0xc4c28c]`) is remembered (`0x5df7e6`), and `CONFIRM_XP_LOSS` (396, `0x5df837`) is owed with
/// the XP the res costs, `PLAYER_NEXT_LEVEL_XP` × 0.05 truncated (`0x5df815`-`0x5df827`). No stock
/// FrameXML reads the cost; `UIParent.lua:399` asks `GetResSicknessDuration()`.
#[derive(bevy::ecs::system::SystemParam)]
pub(crate) struct SpiritHealerAsk<'w, 's> {
death_net: ResMut<'w, DeathNet>,
me: Query<'w, 's, (&'static ObjectStore, &'static Transform), With<SelfPlayer>>,
objects: Objects<'w, 's>,
transforms: Query<'w, 's, &'static Transform>,
}
impl SpiritHealerAsk<'_, '_> {
/// The ask for `npc`; the cost the signal carries when its gates pass, else nothing is
/// remembered and nothing signals.
pub(crate) fn ask(&mut self, npc: u64) -> Option<i64> {
let (store, self_t) = self.me.single().ok()?;
if !store.0.player_is_ghost() {
return None;
}
let healer = self
.objects
.entity(npc)
.filter(|_| self.objects.store(npc).is_some_and(|s| s.is_unit()))
.and_then(|e| self.transforms.get(e).ok())?;
if healer.translation.distance_squared(self_t.translation) > SPIRIT_HEALER_RANGE_SQ {
return None;
}
self.death_net.spirit_healer = Some(npc);
Some(
store
.0
.player_next_level_xp()
.map_or(0, |next| (f64::from(next) * 0.05) as i64),
)
}
}
/// The death stores, the feed into the UI, the intent drain and the root and water-walk messages.
/// [`SpiritHealerAsk`] from the click on a spirit healer, which the reference raises with no
/// packet (`0x5f0130` → `0x5df730`): `CONFIRM_XP_LOSS` signalled in place with the host.
pub(crate) fn ask_spirit_healer(
In(npc): In<u64>,
mut vm: crate::script_calls::VmWith<SpiritHealerAsk<'static, 'static>>,
) {
let Some(cost) = vm.own().ask(npc) else {
return;
};
vm.run(|script| {
if let Some(script) = script {
script.fire_event("CONFIRM_XP_LOSS", vec![ScriptValue::Int(cost)]);
}
});
}
/// The death stores, the corpse poll, the intent drain and the root and water-walk messages.
pub(crate) struct DeathPlugin;
impl Plugin for DeathPlugin {
fn build(&self, app: &mut App) {
net::register(app);
crate::ui_dialog_verbs::add_dialog_lane(app);
app.init_resource::<DeathNet>()
.init_resource::<DeathFeedState>()
.init_resource::<DeathLatches>()
.add_systems(
Update,
(
feed_death.in_set(UiFeed),
// The world frame's update, after its pick (`0x48184a`, then `0x4818c5`), as
// the area spirit healer's poll; gated, as the poll re-derives every frame.
poll_corpse
.after(crate::target::TargetUpdate)
.run_if(crate::ui_script::ingame_ui_up)
.in_set(crate::client_state::InWorldGated),
drive_death_look,
// Before the feed, so the frame a session ends carries no memory of it.
end_session_death_feed.before(feed_death),
),
);
}
}
/// The name `RESURRECT_REQUEST` fires with this frame, if any. Per message, and only while dead
/// or a ghost (`0x5ded50` gated on `0x605f30`); an unresolved name holds without consuming it.
fn offer_announcement(
memo: &mut DeathAnnounced,
death_net: &DeathNet,
dead_or_ghost: bool,
name_of: impl FnOnce(&ResurrectOffer) -> Option<String>,
) -> Option<String> {
if !dead_or_ghost || memo.offer_generation == death_net.resurrect_generation {
return None;
}
let name = name_of(death_net.resurrect.as_ref()?)?;
memo.offer_generation = death_net.resurrect_generation;
Some(name)
}
#[cfg(test)]
mod tests {
use super::*;
use bevy::ecs::system::RunSystemOnce;
fn offer(caster: u64, name: &str) -> ResurrectOffer {
ResurrectOffer {
caster,
name: name.into(),
sickness: false,
has_timer: true,
}
}
/// The offer's packet looks a player caster's name up with the callback `0x5e7ca0`
/// (`0x5e7c82`); the frames the popup waits through read. A refused name is asked by no frame
/// after it, only by the next offer.
#[test]
fn a_refused_resurrecter_is_asked_by_the_next_offer_never_by_a_frame() {
use benilla_protocol::messages::ObjectType;
use benilla_protocol::ObjectFields;
const ME: u64 = 0x7;
const CASTER: u64 = 0x9;
let (tx, rx) = crossbeam_channel::unbounded();
let mut app = App::new();
app.insert_resource(NetCommands(tx))
.insert_resource(crate::net::NetStatus {
connected: true,
last_reason: None,
})
.init_resource::<SelfGuid>()
.init_resource::<DeathNet>()
.init_resource::<DeathFeedState>()
.init_resource::<crate::names::NameCache>()
.init_resource::<crate::net::GuidIndex>()
.init_resource::<crate::items::Items>()
.init_resource::<Time<Real>>()
.add_systems(Update, feed_death);
app.insert_non_send_resource(UiScript::new().unwrap());
// `UNIT_FIELD_HEALTH` 0 of a `UNIT_FIELD_MAXHEALTH` 100: dead.
let dead = ObjectFields::from_pairs(&[(22, 0), (28, 100)]).into_created(ObjectType::Player);
let me = app
.world_mut()
.spawn((ObjectStore(dead), Transform::default(), SelfPlayer))
.id();
app.world_mut()
.resource_mut::<crate::net::GuidIndex>()
.0
.insert(ME, me);
app.world_mut().resource_mut::<SelfGuid>().0 = Some(ME);
let offer = |app: &mut App| {
net::resurrect_request_for_tests(
CASTER,
&mut app.world_mut().resource_mut::<DeathNet>(),
);
app.update();
};
app.update();
offer(&mut app);
assert_eq!(crate::query_cache::queries(&rx).len(), 1);
app.world_mut()
.resource_mut::<crate::names::NameCache>()
.insert_player(CASTER, String::new(), None);
for _ in 0..600 {
app.update();
}
assert!(
crate::query_cache::queries(&rx).is_empty(),
"no frame asks a refusal"
);
offer(&mut app);
assert_eq!(
crate::query_cache::queries(&rx).len(),
1,
"the next offer asks again"
);
}
/// `0x495850` signals `PLAYER_DEAD` (`0x49587d`) before it clears the cursor (`0x495889`): a
/// listener still finds the coins it held.
#[test]
@@ -971,7 +870,7 @@ mod tests {
})
.init_resource::<SelfGuid>()
.init_resource::<DeathNet>()
.init_resource::<DeathFeedState>()
.init_resource::<DeathLatches>()
.init_resource::<crate::net::GuidIndex>()
.init_resource::<crate::items::Items>()
.init_resource::<Time<Real>>();
@@ -1002,48 +901,6 @@ mod tests {
assert!(script.cursor_payload().is_none(), "then the clear");
}
/// PLAYER_UNGHOST hides the popup with `StaticPopup_Hide`, which runs no `OnCancel`, so no
/// Decline clears `resurrect`.
#[test]
fn every_resurrect_message_announces_while_dead_and_never_while_alive() {
let mut net = DeathNet::default();
let mut memo = DeathAnnounced::default();
let name = |o: &ResurrectOffer| Some(o.name.clone());
net.resurrect = Some(offer(1, "Healer"));
net.resurrect_generation += 1;
assert_eq!(
offer_announcement(&mut memo, &net, true, name).as_deref(),
Some("Healer")
);
assert_eq!(
offer_announcement(&mut memo, &net, true, name),
None,
"once per message"
);
// Alive with the offer unanswered: a fresh VM must not announce it.
let mut reloaded = DeathAnnounced::default();
assert_eq!(offer_announcement(&mut reloaded, &net, false, name), None);
// Dead again, a new priest offers.
net.resurrect = Some(offer(2, "Ptwo"));
net.resurrect_generation += 1;
assert_eq!(
offer_announcement(&mut memo, &net, true, name).as_deref(),
Some("Ptwo"),
"the second offer announces"
);
// A name still resolving holds the announcement without consuming it.
net.resurrect_generation += 1;
assert_eq!(offer_announcement(&mut memo, &net, true, |_| None), None);
assert_eq!(
offer_announcement(&mut memo, &net, true, name).as_deref(),
Some("Ptwo")
);
}
const STONE: u64 = 0x4000_0000_0000_5232;
const SELF_RES: u32 = 20707;
const FIREBALL: u32 = 133;
@@ -1492,37 +1349,27 @@ mod tests {
}
/// A `/reload` keeps the body's mirror, so it re-sends no corpse ask; a relog must clear it.
/// A `/logout` is a session edge although `session_over` is false for it.
#[test]
fn the_session_edge_clears_the_world_scoped_death_memory_and_nothing_else_does() {
let mut app = App::new();
app.add_message::<crate::net::DisconnectedMessage>()
.insert_resource(DeathFeedState {
mirror: Some((0x1234, true, true)),
..Default::default()
});
// No session edge: the memory stands.
app.world_mut()
.run_system_once(end_session_death_feed)
fn the_session_edge_clears_the_world_scoped_death_memory() {
let mut world = World::new();
world.init_resource::<DeathNet>();
world.insert_resource(DeathLatches {
mirror: Some((0x1234, true, true)),
corpse_in_range: true,
});
world
.run_system_cached_with(
net::on_session_end,
benilla_protocol::SessionEvent::Disconnected {
reason: "logged out".into(),
end: benilla_protocol::SessionEnd::LoggedOut,
},
)
.expect("the teardown runs");
assert_eq!(
app.world().resource::<DeathFeedState>().mirror,
Some((0x1234, true, true)),
"nothing but the session edge may clear the body's own state machine"
);
// A `/logout` is a session edge although `session_over` is false for it.
app.world_mut()
.write_message(crate::net::DisconnectedMessage::new(
"logged out".into(),
benilla_protocol::SessionEnd::LoggedOut,
));
app.world_mut()
.run_system_once(end_session_death_feed)
.expect("the teardown runs");
let feed = app.world().resource::<DeathFeedState>();
let latches = world.resource::<DeathLatches>();
assert!(
feed.mirror.is_none(),
latches.mirror.is_none() && !latches.corpse_in_range,
"a relog must find no mirror, or the login-while-ghost arm cannot fire"
);
}
@@ -1530,7 +1377,7 @@ mod tests {
/// `PLAYER_FIELD_BYTES`, whose bit 0x8 our own death's timer reads (`0x5e9a27`).
const BYTES: u16 = 1222;
/// A world with our player at `health`, the release-timer bit set, the death feed and the
/// A world with our player at `health`, the release-timer bit set, the death stores and the
/// arrival's signal, and a VM that records each death-state event with the timer it reads.
fn arrival_app(health: u32) -> App {
use benilla_protocol::field::{FIELD_UNIT_HEALTH, FIELD_UNIT_MAXHEALTH};
@@ -1546,14 +1393,13 @@ mod tests {
})
.init_resource::<SelfGuid>()
.init_resource::<DeathNet>()
.init_resource::<DeathFeedState>()
.init_resource::<DeathLatches>()
.init_resource::<crate::names::NameCache>()
.init_resource::<crate::net::GuidIndex>()
.init_resource::<crate::items::Items>()
.init_resource::<Time<Real>>()
.insert_resource(State::new(crate::client_state::ClientState::InWorld))
.add_plugins(crate::ui_world_enter::WorldEnterPlugin)
.add_systems(Update, feed_death);
.add_plugins(crate::ui_world_enter::WorldEnterPlugin);
app.insert_non_send_resource(recording_vm());
let body = ObjectFields::from_pairs(&[
(FIELD_UNIT_HEALTH, health),
@@ -1632,70 +1478,6 @@ mod tests {
}
}
/// Run the death feed once on `world`, for a test of what it pushes.
#[cfg(test)]
pub(crate) fn run_feed_death_once(world: &mut World) {
use bevy::ecs::system::RunSystemOnce;
world
.run_system_once(feed_death)
.expect("the death feed runs");
}
/// The body's VM events between the last `(dead, ghost)` seen, if any, and this one.
fn fire_vm_edges(script: &mut UiScript, prev: Option<(bool, bool)>, dead: bool, ghost: bool) {
match (prev, dead, ghost) {
(Some((true, false)), d, g) if g || !d => {
// The health edge out of 0 (`0x6047f0`) unlocks every item (`0x5fefae`), then fires
// `PLAYER_ALIVE` (`0x5fefb8`).
script.unlock_all_items();
script.fire_event("PLAYER_ALIVE", vec![]);
}
_ => {}
}
}
#[cfg(test)]
mod edge_tests {
use benilla_ui::script::UiScript;
/// The revive edge unlocks every item, its one `ITEM_LOCK_CHANGED` ahead of `PLAYER_ALIVE`
/// (`0x5fefae`, `0x5fefb8`); the ghost's own revive, no health edge, unlocks nothing.
#[test]
fn the_revive_edge_unlocks_every_item_before_player_alive() {
const ITEM: u64 = 0x4000_0000_0000_0042;
let mut s = UiScript::new().unwrap();
s.run(
"SEEN = {} local f = CreateFrame('Frame') \
f:RegisterEvent('ITEM_LOCK_CHANGED') f:RegisterEvent('PLAYER_ALIVE') \
f:RegisterEvent('PLAYER_UNGHOST') \
f:SetScript('OnEvent', function() table.insert(SEEN, event) end)",
)
.unwrap();
let seen = |s: &UiScript| {
let out = s.eval::<Vec<String>>("return SEEN").unwrap();
s.run("SEEN = {}").unwrap();
out
};
s.lock_item(ITEM);
let _ = seen(&s);
super::fire_vm_edges(&mut s, Some((true, false)), true, true);
assert_eq!(
seen(&s),
["ITEM_LOCK_CHANGED", "PLAYER_ALIVE"],
"the release"
);
assert!(!s.item_locked(ITEM));
s.lock_item(ITEM);
let _ = seen(&s);
super::fire_vm_edges(&mut s, Some((true, true)), false, false);
assert!(
seen(&s).is_empty(),
"the corpse run's end: its event is the ghost bit's (`0x5de9c0`)"
);
assert!(s.item_locked(ITEM));
}
}
#[cfg(test)]
mod self_res_tests {
use std::collections::HashMap;
+120 -27
View File
@@ -1,11 +1,15 @@
//! The death packet handlers filling [`DeathNet`], the movement-mode forward for our own mover,
//! and the corpse-guid latch's hooks on the object lifecycle, called from the drain's object arms.
//! The death packet handlers filling [`DeathNet`], each signal they raise on the dialogs' lane at
//! the packet's place, the movement-mode forward for our own mover, and the corpse-guid latch's
//! hooks on the object lifecycle, called from the drain's object arms.
use benilla_protocol::{EntityKind, MoveMode, ObjectFields, SessionEvent, SessionEventKind};
use benilla_ui::script::ScriptValue;
use bevy::prelude::*;
use super::{CorpsePoint, DeathNet, ResurrectOffer};
use crate::net::{MoveModeMessage, NetHandlerApp, SelfGuid};
use super::{CorpsePoint, DeathLatches, DeathNet, ResurrectOffer};
use crate::net::{MoveModeMessage, NetHandlerApp, ObjectStore, SelfGuid, SelfPlayer};
use crate::query_cache::Ask;
use crate::ui_dialog_verbs::DialogLane;
/// Register the death handlers and the session-end listener.
pub(super) fn register(app: &mut App) {
@@ -19,7 +23,15 @@ pub(super) fn register(app: &mut App) {
.net_handler(K::Disconnected, on_session_end);
}
fn on_corpse_query(In(ev): In<SessionEvent>, mut death_net: ResMut<DeathNet>) {
/// `MSG_CORPSE_QUERY`'s two arms of `0x48f690`: a found corpse fills the cache
/// (`0x48f7d1` → `0x492010`); a not-found resets it (`0x48f800`) and lowers the range latch
/// (`0x48f807` → `0x4920f0(0)`), whose `CORPSE_OUT_OF_RANGE` signals at the packet when it was set.
fn on_corpse_query(
In(ev): In<SessionEvent>,
mut death_net: ResMut<DeathNet>,
mut latches: ResMut<DeathLatches>,
mut lane: ResMut<DialogLane>,
) {
if let SessionEvent::CorpseQuery {
found,
display_map,
@@ -28,20 +40,43 @@ fn on_corpse_query(In(ev): In<SessionEvent>, mut death_net: ResMut<DeathNet>) {
} = ev
{
corpse_query(found, display_map, position, corpse_map, &mut death_net);
if !found {
if let Some(signal) = latches.set_in_range(false, None) {
signal.queue(&mut lane);
}
}
}
}
/// `SMSG_CORPSE_RECLAIM_DELAY` (`0x48f828` → `SetCorpseReclaimDelay 0x4962d0`): the delay stored,
/// then the in-range event again while the latch is set (`0x4962ec`-`0x49630d`), at the packet, so
/// `RECOVER_CORPSE` re-shows over the new delay.
fn on_corpse_reclaim_delay(
In(ev): In<SessionEvent>,
mut death_net: ResMut<DeathNet>,
latches: Res<DeathLatches>,
mut lane: ResMut<DialogLane>,
real_clock: Res<Time<Real>>,
) {
if let SessionEvent::CorpseReclaimDelay { delay_ms } = ev {
corpse_reclaim_delay(delay_ms, real_clock.elapsed_secs_f64(), &mut death_net);
if latches.corpse_in_range {
super::CorpseSignal::in_range(death_net.corpse.as_ref()).queue(&mut lane);
}
}
}
fn on_resurrect_request(In(ev): In<SessionEvent>, mut death_net: ResMut<DeathNet>) {
/// `ReadResurrectRequest 0x5e7bc0`: the offer stored (`0x5e7c13`-`0x5e7c2d`); with the active
/// player held (`0x5e7c4a`), a name on the wire shows it at once (`0x5e7c56`), else the caster's
/// name is looked up with the callback `0x5e7ca0` (`0x5e7c82`), a cached one showing it at once.
fn on_resurrect_request(
In(ev): In<SessionEvent>,
mut death_net: ResMut<DeathNet>,
names: Res<crate::names::NameCache>,
net: Res<crate::net::NetCommands>,
me: Query<&ObjectStore, With<SelfPlayer>>,
mut lane: ResMut<DialogLane>,
) {
if let SessionEvent::ResurrectRequest {
caster,
name,
@@ -49,13 +84,79 @@ fn on_resurrect_request(In(ev): In<SessionEvent>, mut death_net: ResMut<DeathNet
has_timer,
} = ev
{
resurrect_request(caster, name, sickness, has_timer, &mut death_net);
resurrect_request(caster, name.clone(), sickness, has_timer, &mut death_net);
let Ok(me) = me.single() else {
return;
};
let name = if name.is_empty() {
names
.resolve_player(caster, Ask::Event(&net))
.map(str::to_owned)
} else {
Some(name)
};
match name {
Some(name) => show_resurrect_request(&me.0, &name, &mut lane),
None => {
if let Some(offer) = death_net.resurrect.as_mut() {
offer.waits_name = true;
}
}
}
}
}
fn on_spirit_healer_confirm(In(ev): In<SessionEvent>, mut death_net: ResMut<DeathNet>) {
/// The callback `0x5e7ca0` for `guid`'s answer, the offer's caster whose name it waited on: a found
/// name shows the offer while the active player is held (`0x5e7d02` → `0x5e7d09`), a refused one
/// forgets it (`0x5e7d19`-`0x5e7d2b`).
pub(crate) fn resurrecter_named(
death_net: &mut DeathNet,
me: Option<&ObjectStore>,
lane: &mut DialogLane,
guid: u64,
name: Option<&str>,
) {
let Some(offer) = death_net
.resurrect
.as_mut()
.filter(|o| o.waits_name && o.caster == guid)
else {
return;
};
offer.waits_name = false;
match name.filter(|n| !n.is_empty()) {
Some(name) => {
if let Some(me) = me {
show_resurrect_request(&me.0, name, lane);
}
}
None => death_net.resurrect = None,
}
}
/// `ShowResurrectRequest 0x5ded50`: `RESURRECT_REQUEST` with a non-empty `name` (`0x5ded5b`)
/// while the active player is dead or a ghost (`0x5ded60` → `0x605f30`).
fn show_resurrect_request(me: &ObjectFields, name: &str, lane: &mut DialogLane) {
if !name.is_empty() && me.is_dead_or_ghost() {
lane.event(
"RESURRECT_REQUEST",
vec![ScriptValue::Str(name.to_string())],
);
}
}
/// `SMSG_SPIRIT_HEALER_CONFIRM`'s arm of the notice handler (`0x5e38c0` → `0x5df730`): the
/// healer's gossip re-sends it on every ask, and each that passes the ask's gates signals at its
/// packet.
fn on_spirit_healer_confirm(
In(ev): In<SessionEvent>,
mut ask: super::SpiritHealerAsk,
mut lane: ResMut<DialogLane>,
) {
if let SessionEvent::SpiritHealerConfirm { npc } = ev {
spirit_healer_confirm(npc, &mut death_net);
if let Some(cost) = ask.ask(npc) {
lane.event("CONFIRM_XP_LOSS", vec![ScriptValue::Int(cost)]);
}
}
}
@@ -90,9 +191,15 @@ fn on_move_mode(
}
}
/// The death stores are session-scoped; a reconnect while dead re-sends the reclaim delay.
fn on_session_end(In(_): In<SessionEvent>, mut death_net: ResMut<DeathNet>) {
/// The death stores and latches are session-scoped; a reconnect while dead re-sends the reclaim
/// delay, and a relog as a ghost must find no mirror, or the corpse query is never re-sent.
pub(super) fn on_session_end(
In(_): In<SessionEvent>,
mut death_net: ResMut<DeathNet>,
mut latches: ResMut<DeathLatches>,
) {
*death_net = DeathNet::default();
*latches = DeathLatches::default();
}
/// Our corpse streaming in: latch its guid for the reclaim send. The reference's latch
@@ -161,11 +268,9 @@ fn corpse_query(
});
}
/// `SMSG_CORPSE_RECLAIM_DELAY`, anchored at arrival on the clock the feed reads. The 1.12 client
/// re-fires the corpse-range events on each (`0x4962d0`), hence the generation bump.
/// `SMSG_CORPSE_RECLAIM_DELAY`, anchored at arrival on the clock the getters read.
fn corpse_reclaim_delay(delay_ms: u32, now_secs: f64, death_net: &mut DeathNet) {
death_net.reclaim_at = Some(now_secs + f64::from(delay_ms) / 1000.0);
death_net.reclaim_generation = death_net.reclaim_generation.wrapping_add(1);
}
/// `SMSG_RESURRECT_REQUEST`, the RESURRECT popup's data.
@@ -181,20 +286,8 @@ fn resurrect_request(
name,
sickness,
has_timer,
waits_name: false,
});
death_net.resurrect_generation = death_net.resurrect_generation.wrapping_add(1);
}
/// A player caster's offer, its name empty on the wire, as [`resurrect_request`] records it.
#[cfg(test)]
pub(super) fn resurrect_request_for_tests(caster: u64, death_net: &mut DeathNet) {
resurrect_request(caster, String::new(), false, true, death_net);
}
/// `SMSG_SPIRIT_HEALER_CONFIRM`: the healer's gossip re-sends it on every ask, and the reference
/// fires `CONFIRM_XP_LOSS` per arrival.
fn spirit_healer_confirm(npc: u64, death_net: &mut DeathNet) {
death_net.ask_spirit_healer(npc);
}
/// `SMSG_DURABILITY_DAMAGE_DEATH`, the 10% death durability loss: a combat-log line at chat type
+27 -1
View File
@@ -182,6 +182,13 @@ pub(crate) enum FieldNotice {
/// VM's statics store the point, then `MINIMAP_PING` with the token the packet resolved
/// (`0x4ee48d`).
MinimapPing(crate::minimap::MemberPing),
/// The health watcher's revive arm on the active player (`0x6047ee` → `0x5fef70`): every item
/// unlocked with its one `ITEM_LOCK_CHANGED` (`0x5fefae` → `0x495460`), then `PLAYER_ALIVE`
/// (274, `0x5fefb8`).
Revived,
/// A packet handler's `DisplayError(id)` (`0x496720`): the message row's line, by its
/// `GlobalStrings` key, shown at once.
Line { key: &'static str },
}
/// The notice lane: each notice stamped as a handler writes it ([`crate::lanes::stamp`]), fired
@@ -305,6 +312,9 @@ pub(crate) mod id {
pub(crate) const PET_BAR_UPDATE: u16 = 353;
pub(crate) const AREA_SPIRIT_HEALER_IN_RANGE: u16 = 527;
pub(crate) const AREA_SPIRIT_HEALER_OUT_OF_RANGE: u16 = 528;
pub(crate) const PLAYER_CAMPING: u16 = 276;
pub(crate) const PLAYER_QUITING: u16 = 277;
pub(crate) const LOGOUT_CANCEL: u16 = 278;
}
/// `CGPlayer_C::RefreshGuildTag` (`0x5e08e0`) on the player `guid`: `TABARD_CANSAVE_CHANGED` bare
@@ -788,6 +798,17 @@ pub(crate) fn placed_values(
// The unit type watchers (`0x6041f0`), on every unit.
let mine = around.me == Some(guid);
// The health watcher's revive arm (`0x6047ee`-`0x6047f4`, a health of 0 or less rising above
// it) for the active player (`0x5fef9f`): `0x5fef70`'s unlock and `PLAYER_ALIVE`, ahead of the
// watcher's usable refresh.
if let Some(at) = at(UNIT_SECTION, HEALTH, List::Type).filter(|_| mine) {
let rose = block
.edge(UNIT_SECTION + HEALTH.0 / 4)
.is_some_and(|(old, new)| old as i32 <= 0 && new as i32 > 0);
if rose {
pass.push(at, FieldNotice::Revived);
}
}
// The health's and the powers' for the active player (`0x60483c`, `0x604868`), the aura
// state's for it or the target (`0x604898`-`0x6048b4`).
for (range, runs) in [
@@ -2435,8 +2456,13 @@ mod tests {
let mut me = player();
assert_eq!(
block(&mut me, Some(ME), ME, &[(22, 90)]),
[FieldNotice::Revived, R, bridge(ME, 16)],
"the health, out of none: the revive arm runs first (`0x6047ee`)"
);
assert_eq!(
block(&mut me, Some(ME), ME, &[(22, 80)]),
[R, bridge(ME, 16)],
"the health"
"the health, alive"
);
assert_eq!(
block(&mut me, Some(ME), ME, &[(23, 480)]),
+4 -9
View File
@@ -1777,9 +1777,6 @@ pub(crate) mod schedule_tests {
enum Because {
/// The consumed queue is filled only by Lua asking; a frameless VM asks for nothing.
FilledByVm,
/// Filled only by a server reply to a click in the interface, or (noted in the reason)
/// another player's act on us, which meets the login burst only by coincidence.
PlayerRoundTrip,
/// Consumed in the window or not, the state is re-asked or re-derived once the UI is up.
SelfHealing,
/// The publication is driven by a `VmMemo` diff, so a new VM re-derives and re-fires it.
@@ -1799,10 +1796,10 @@ pub(crate) mod schedule_tests {
"the drag probe: dev-only (`WOW_PROBE_DRAG`), it starts past `WOW_PROBE_DRAG_AT` with the \
player's body in the world, and its `.drain(..)` is of the VM's own script errors, \
raised by the gesture it just made"),
("death/mod.rs", "feed_death", Because::MemoLatched,
"`feed.vm: VmMemo<DeathAnnounced>`: a fresh memo takes the first snapshot as no edge and re-announces a held offer, confirm and corpse range, and skips the edges of our create's frame, whose arrival item signals the state itself"),
("death/mod.rs", "signal", Because::MemoLatched,
"the death state's signal: our death's leg (`signal_death`), run in its packet with the VM deferred, its `PLAYER_DEAD` parked for the deaths lane, whose drain runs only with the interface up (`ingame_ui_up`); and an arrival's, run by the arrival lane's firing inside the lanes' drain, which runs only with the interface up (`ingame_ui_up`). Its memo is `feed.vm`, a `VmMemo<DeathAnnounced>`"),
("death/mod.rs", "signal", Because::Deliberate,
"the death state's signal: our death's leg (`signal_death`), run in its packet with the VM deferred, its `PLAYER_DEAD` parked for the deaths lane, whose drain runs only with the interface up (`ingame_ui_up`); and an arrival's, run by the arrival lane's firing inside the lanes' drain, which runs only with the interface up (`ingame_ui_up`)"),
("death/mod.rs", "ask_spirit_healer", Because::Deliberate,
"no system: the spirit healer click's world edit runs it, inside the input pass's click legs, with the interface up"),
("death/mod.rs", "query_corpse_on_world_enter", Because::Deliberate,
"no system: a leg the arrival lane's firing runs, inside the drain, which runs only with the interface up; its take is the range latch, which it zeroes into the live VM"),
("net/objects/update.rs", "on_update_end", Because::Deliberate,
@@ -1828,8 +1825,6 @@ pub(crate) mod schedule_tests {
"`feed.vm: VmMemo<FollowFeedMemo>`; a fresh VM re-fires BEGIN for a follow in progress"),
("ui_guild/lane.rs", "fire_guild", Because::Deliberate,
"a lane's firing, run only by the drain, which runs only with the interface up (`ingame_ui_up`): the lane holds what the packets queue until a drain fires it, so the login's message of the day, which lands ahead of the interface, fires into the VM that comes up"),
("ui_logout.rs", "feed_logout", Because::PlayerRoundTrip,
"both packets answer the `CMSG_LOGOUT_REQUEST`/cancel the game menu sent"),
("ui_loot/mod.rs", "drain_loot", Because::Deliberate,
"its takes of `LootMoveStart` and `LootCloseAtRest` close on the engine's side and publish nothing to the VM, whose `LOOT_CLOSED` is the loot lane's; the at-rest sweep signals only on a disenchant window, which the interface's own cast opens"),
("ui_macro/mod.rs", "load_macros", Because::MemoLatched,
+4
View File
@@ -535,6 +535,8 @@ mod close_parked_tests;
#[cfg(test)]
mod cooldown_live_tests;
#[cfg(test)]
mod death_live_tests;
#[cfg(test)]
mod dialog_live_tests;
#[cfg(test)]
mod duration_live_tests;
@@ -561,6 +563,8 @@ mod item_tests;
#[cfg(test)]
mod item_text_live_tests;
#[cfg(test)]
mod logout_live_tests;
#[cfg(test)]
mod loot_live_tests;
#[cfg(test)]
mod loot_roll_live_tests;
@@ -958,7 +958,7 @@ fn the_cascades_corpse_step_signals_the_range_latch_out() {
);
c.app
.world_mut()
.resource_mut::<crate::death::DeathFeedState>()
.resource_mut::<crate::death::DeathLatches>()
.latch_corpse_in_range_for_test();
c.frame(vec![vec![me()]]);
c.frame(vec![]);
@@ -0,0 +1,175 @@
//! The death getters as a listener reads them, and the death signals at their packets. The
//! getters read the interface's death globals at the call (`GetCorpseRecoveryDelay` `0x48b5d0`);
//! the resurrect offer shows inside its packet or its caster's name answer (`0x5e7bc0`,
//! `0x5e7ca0` → `0x5ded50`), the revive's `PLAYER_ALIVE` inside the health watcher's run
//! (`0x6047ee` → `0x5fef70`), and the reclaim delay's range event inside its handler (`0x4962d0`).
use benilla_protocol::SessionEvent;
use benilla_ui::script::UiScript;
use bevy::prelude::*;
use super::unit_view_tests::{client, created, fall, frame, health, values};
/// [`client`]'s active player.
const ME: u64 = 0x7;
/// A fall's `UNIT_COMBAT` on our dead body, as [`client`]'s spy records it.
const FELL: &str = "UNIT_COMBAT:player:0";
const PRIEST: u64 = 0x51;
/// [`client`] with a spy on the death signals, each with what its listener reads: the offer's
/// name and timer, the corpse's delay.
fn death_client() -> App {
let mut app = client();
app.world_mut()
.non_send_resource_mut::<UiScript>()
.run(
r#"
local f = CreateFrame("Frame")
for _, e in ipairs({"RESURRECT_REQUEST", "PLAYER_ALIVE", "CORPSE_IN_RANGE",
"CONFIRM_XP_LOSS"}) do
f:RegisterEvent(e)
end
f:SetScript("OnEvent", function()
if event == "RESURRECT_REQUEST" then
table.insert(Seen, event .. ":" .. arg1 .. ":" .. tostring(ResurrectHasTimer()))
elseif event == "CORPSE_IN_RANGE" then
table.insert(Seen, event .. ":" .. GetCorpseRecoveryDelay())
else
table.insert(Seen, event)
end
end)
"#,
)
.unwrap();
app
}
/// [`death_client`] after our death's packet, the frame's signals taken.
fn dead_client() -> App {
let mut app = death_client();
frame(&mut app, vec![values(ME, &health(0))]);
app
}
fn offer(name: &str) -> SessionEvent {
SessionEvent::ResurrectRequest {
caster: PRIEST,
name: name.into(),
sickness: false,
has_timer: true,
}
}
/// With no frame after the reclaim delay's packet, `GetCorpseRecoveryDelay` reads the delay
/// through the host; the VM's copy, which nothing pushes, reads none.
#[test]
fn the_recovery_delay_reads_the_stores_at_the_call() {
let mut app = dead_client();
crate::net::handlers::dispatch(
app.world_mut(),
vec![SessionEvent::CorpseReclaimDelay { delay_ms: 30_000 }],
);
let chunk = "return GetCorpseRecoveryDelay()";
let live: f64 = crate::script_calls::with_hosted_vm(app.world_mut(), |s| {
s.expect("a VM").eval(chunk).expect("runs")
});
assert!((29.0..=30.0).contains(&live), "{live}");
let copy: f64 = crate::script_calls::eval_in_vm(app.world(), chunk);
assert_eq!(copy, 0.0);
}
/// An offer with its caster's name on the wire signals at its packet's place, between a fall's
/// `UNIT_COMBAT` on each side, its listener reading the offer's timer.
#[test]
fn resurrect_request_fires_between_neighbouring_packets_events() {
let mut app = dead_client();
let seen = frame(&mut app, vec![fall(5), offer("Bob"), fall(5)]);
assert_eq!(seen, [FELL, "RESURRECT_REQUEST:Bob:1", FELL]);
}
/// A player caster's offer waits on the name its packet asked (`0x5e7c82`): nothing at the offer,
/// then the show inside the name answer's packet.
#[test]
fn a_player_casters_offer_shows_at_its_name_answer() {
let mut app = dead_client();
assert!(frame(&mut app, vec![offer("")]).is_empty());
let named = SessionEvent::PlayerName {
guid: PRIEST,
name: "Ann".into(),
race: 1,
gender: 0,
class: 5,
};
let seen = frame(&mut app, vec![fall(5), named, fall(5)]);
assert_eq!(seen, [FELL, "RESURRECT_REQUEST:Ann:1", FELL]);
}
/// The revive's health rising above 0 runs the watcher's arm inside its packet: `PLAYER_ALIVE`,
/// then the bridge's `UNIT_HEALTH`, between the falls around it.
#[test]
fn player_alive_fires_at_the_revives_packet() {
let mut app = dead_client();
let seen = frame(&mut app, vec![fall(5), values(ME, &health(1)), fall(5)]);
assert_eq!(
seen,
[
FELL,
"PLAYER_ALIVE",
"UNIT_HEALTH:player:1",
"UNIT_COMBAT:player:1"
]
);
}
/// A reclaim delay while the range latch is set signals the in-range event again at its packet,
/// its listener reading the new delay (`0x4962da`, `0x49630d`).
#[test]
fn a_reclaim_delay_in_range_signals_at_its_packet() {
let mut app = dead_client();
app.world_mut()
.resource_mut::<crate::death::DeathLatches>()
.latch_corpse_in_range_for_test();
let delay = SessionEvent::CorpseReclaimDelay { delay_ms: 30_000 };
let seen = frame(&mut app, vec![fall(5), delay, fall(5)]);
assert_eq!(seen.len(), 3, "{seen:?}");
assert_eq!((seen[0].as_str(), seen[2].as_str()), (FELL, FELL));
let read: f64 = seen[1]
.strip_prefix("CORPSE_IN_RANGE:")
.and_then(|d| d.parse().ok())
.unwrap_or_else(|| panic!("{seen:?}"));
assert!((29.0..=30.0).contains(&read), "{read}");
}
/// A spirit healer's confirm signals `CONFIRM_XP_LOSS` at its packet's place for a ghost with the
/// healer in reach (`0x5df74a`, `0x5df7c1`, `0x5df837`), and nothing for the living.
#[test]
fn confirm_xp_loss_fires_at_its_packet_for_a_ghost_in_reach() {
use benilla_protocol::field::{FIELD_PLAYER_FLAGS, FIELD_UNIT_HEALTH, FIELD_UNIT_MAXHEALTH};
const HEALER: u64 = 0xF130_0000_1772_0050;
let confirm = || SessionEvent::SpiritHealerConfirm { npc: HEALER };
let mut app = death_client();
let healer = created(
HEALER,
benilla_protocol::EntityKind::Unit,
&[(FIELD_UNIT_HEALTH, 100), (FIELD_UNIT_MAXHEALTH, 100)],
);
frame(&mut app, vec![healer]);
let alive = "UNIT_COMBAT:player:100";
assert_eq!(
frame(&mut app, vec![fall(5), confirm(), fall(5)]),
[alive, alive],
"alive: no question"
);
frame(
&mut app,
vec![values(
ME,
&[(FIELD_UNIT_HEALTH, 1), (FIELD_PLAYER_FLAGS, 0x10)],
)],
);
let ghost = "UNIT_COMBAT:player:1";
assert_eq!(
frame(&mut app, vec![fall(5), confirm(), fall(5)]),
[ghost, "CONFIRM_XP_LOSS", ghost]
);
}
+22 -19
View File
@@ -90,23 +90,12 @@ pub(super) const NOT_YET_ON_A_LANE: &[(Row, &str, &str)] = &[
"the action slots, which `feed_actions` resolves; a handler's Lua writes them in its \
call, through the host's bar verbs",
),
(
Row::HostHeld,
"::ui_logout::LogoutState",
"the logout state, which `feed_logout` fires from; the session verbs, acting in their \
calls, hold it in the host",
),
(
Row::Queue,
"::ui_logout::SessionPosts",
"the exit and the cinematic stop a session verb posts, which nothing the script reads \
waits on",
),
(
Row::HostHeld,
"::death::DeathNet",
"the death stores, which `feed_death` fires the offers and the corpse range from; the death verbs, acting in their calls, hold them in the host",
),
(
Row::HostHeld,
"::items::Items",
@@ -306,6 +295,19 @@ pub(super) const HOST_HELD_UNREAD: &[&str] = &[
// the world frame's update, after the packets. `feed_interact_npc` copies it as
// `InteractNpc` right after the dispatch, for the engine's own token reads.
"::ui_session::latch::InteractLatch",
// Moved here from `NOT_YET_ON_A_LANE`, so neither list grew: the session verbs read and write
// the logout bytes through the host in their calls, and quiet: the replies' handlers signal on
// the notice lane at their packets.
"::ui_logout::LogoutState",
// Quiet: the connection's state, which the session's handlers write and the death getters'
// body test reads through the host; no feed fires off it.
"::net::NetStatus",
// Moved here from `NOT_YET_ON_A_LANE`, so neither list grew: the death getters read the stores
// through the host and the death verbs hold them in their calls, and quiet: the offers and the
// corpse-range signals packets raise go on the dialogs' lane at their handlers, the revive's
// on the notice lane, and the corpse poll runs in the world frame's update, after the packets
// (`0x4818c5`).
"::death::DeathNet",
// Read through the host by the taxi getters, and quiet: its events fire on the taxi lane at
// their handlers.
"::ui_taxi::TaxiState",
@@ -360,14 +362,10 @@ pub(super) const READS_FRAME_FINAL: &[(&str, &[&str])] = &[
// `SetCVar` moves it inside its call, and the build reads it as the frame left it.
"video::Widescreen"]),
("::death::feed_death", &["Transform", "death::DeathNet", "items::Countdowns", "items::Items",
"names::NameCache", "net::GuidIndex", "net::NetStatus", "net::ObjectStore",
"net::SelfGuid"]),
// The group's push, the party and raid getters' no-host fallback: the roster's cells, its
// members' names and objects as the frame left them; the tokens read live at the call.
("::ui_party::feed::feed_party", &["names::NameCache", "net::GuidIndex", "net::ObjectStore",
"ui_party::GroupState"]),
("::ui_logout::feed_logout", &["ui_logout::LogoutState"]),
// The engine's follow transitions, which a `FollowUnit` a handler's listener makes arms.
("::ui_follow::feed_follow", &["player::follow::FollowState", "ui_follow::FollowFeed"]),
// The ammo getters' hits fire after the push that carries their record, whenever it runs.
@@ -403,7 +401,6 @@ pub(super) const READS_FRAME_FINAL: &[(&str, &[&str])] = &[
("::ui_items::locks::forget_gone_item_locks", &["net::GuidIndex"]),
("::ui_items::feed::feed_item_stats", &["items::Items", "net::HomeBind", "net::ObjectStore",
"spell::mods::SpellModifiers"]),
("::ui_taxi::feed_on_taxi", &["net::ObjectStore"]),
// The getters' item callbacks, kept inside their calls, are spent as the frame left them.
("::ui_tradeskill::feed_trade_skill", &["items::Countdowns", "items::Items", "net::GuidIndex",
"net::ObjectStore", "spell::cooldowns::Cooldowns", "ui_action::PlayerActions",
@@ -472,6 +469,13 @@ pub(super) const READ_ONLY_TO_HANDLERS: &[&str] = &[
"::ui_items::ItemBagFamilies",
// `AuctionHouse.dbc`, whose deposit rate the hello's show hands the VM.
"::ui_auction::AuctionHouses",
// The corpse-range latch, which the reclaim delay's handler tests to signal again
// (`0x4962ec`); the corpse query's not-found handler and the corpse poll write it through
// their own `ResMut`.
"::death::DeathLatches",
// The connection's state, which the death getters' body test reads through the host; the
// socket's handlers write it through their own `ResMut`.
"::net::NetStatus",
// The login pick, which names the character the account-data sections belong to.
"::glue_session::roster::Roster",
// `0xb4e314`, which the party snapshot reads; only the zone feed commits it.
@@ -1776,9 +1780,8 @@ pub(super) const LANE_READS_FRAME_FINAL: &[(&str, &[&str])] = &[
("chat setup arrivals", &["ui_chat::edit::ChannelState"]),
// Our arrival's legs read and reset what later packets of its frame write, as the frame left
// it: the book the replay learns, the battlefield and stone it resets and asks again for, the
// death stores its death state reads and its corpse ask resets, the class family it sets and
// the connection the clock resync asks through.
("arrival", &["chat_bubble::BubbleConfig", "death::DeathNet", "net::NetStatus",
// corpse-range latch its corpse ask lowers, and the class family it sets.
("arrival", &["chat_bubble::BubbleConfig", "death::DeathLatches",
"spell::mods::SpellModifiers",
"ui_action::PlayerActions", "ui_battlefield::Battlefield",
"ui_dialog_verbs::MeetingStone"]),
@@ -43,8 +43,8 @@ use crate::game_plugins::schedule_tests::{census, type_names_available, SyncPoin
/// The most rows [`super::guard_tests::READS_FRAME_FINAL`] may hold, and the most inputs across
/// them: each only falls, so lower it when a row or an input goes.
const FRAME_FINAL_FEEDS: usize = 17;
const FRAME_FINAL_INPUTS: usize = 106;
const FRAME_FINAL_FEEDS: usize = 15;
const FRAME_FINAL_INPUTS: usize = 98;
/// The systems that may run after the dispatch (`apply_net_updates`) and run ahead of the drain
/// (`fire_in_order`), by a suffix of the system's name, with what each writes of the state a
@@ -100,9 +100,6 @@ const BETWEEN_THE_DISPATCH_AND_THE_DRAIN: &[(&str, &[&str], &str)] = &[
("::ui_item_text::apply_reads", &["ui_item_text::ItemTextOpen"],
"a click's or a bag use's read, queued in its input or its call, which the reference \
opens inside them (`0x5f58c0`, `0x4e32e0`), ahead of the packets (`0x420d23`)"),
("::ui_logout::feed_logout", &["ui_logout::LogoutState"],
"fires and clears the signals the logout replies queue, which the session verbs read in \
their calls, where the reference's handlers signal in place (`0x5aaef0`, `0x5aaf60`)"),
("::ui_macro::load_macros", &["ui_action::ActionSlots"],
"the macro reader (`LoadMacroFiles` `0x4f0600`), run as its sections settle, moves a \
character's buttons off benilla's older numbering through the bar verbs, a move with no \
@@ -0,0 +1,83 @@
//! The logout replies' signals at their packets. `SMSG_LOGOUT_RESPONSE`'s handler signals
//! `PLAYER_CAMPING` or `PLAYER_QUITING` in place (`0x5aaef0`, `0x5aaf17`), and
//! `SMSG_LOGOUT_CANCEL_ACK`'s `LOGOUT_CANCEL` while a request is pending (`0x5aaf60`, `0x5aaf72`),
//! so each fires between the events of the packets around it.
use benilla_protocol::SessionEvent;
use benilla_ui::script::UiScript;
use bevy::prelude::*;
use super::unit_view_tests::{client, fall, frame};
/// A fall's `UNIT_COMBAT`, as [`client`]'s spy records it.
const FELL: &str = "UNIT_COMBAT:player:100";
/// [`client`] with the world handle seated, a write channel kept, and a spy on the logout
/// signals.
fn logout_client() -> (App, crossbeam_channel::Receiver<crate::net::ClientCommand>) {
let mut app = client();
let (tx, rx) = crossbeam_channel::unbounded();
app.insert_resource(crate::net::NetCommands(tx));
app.world_mut()
.resource_mut::<crate::ui_logout::LogoutState>()
.seat_world_handle_for_test();
app.world_mut()
.non_send_resource_mut::<UiScript>()
.run(
r#"
local f = CreateFrame("Frame")
for _, e in ipairs({"PLAYER_CAMPING", "PLAYER_QUITING", "LOGOUT_CANCEL"}) do
f:RegisterEvent(e)
end
f:SetScript("OnEvent", function() table.insert(Seen, event) end)
"#,
)
.unwrap();
(app, rx)
}
/// Run `chunk` with the host lent.
fn run(app: &mut App, chunk: &str) {
crate::script_calls::with_hosted_vm(app.world_mut(), |s| s.expect("a VM").run(chunk))
.expect("runs");
}
/// The response's `PLAYER_CAMPING` fires at its packet's place, between a fall's `UNIT_COMBAT` on
/// each side.
#[test]
fn player_camping_fires_between_neighbouring_packets_events() {
let (mut app, _rx) = logout_client();
run(&mut app, "Logout()");
let response = SessionEvent::LogoutResponse {
reason: 0,
instant: false,
};
let seen = frame(&mut app, vec![fall(5), response, fall(5)]);
assert_eq!(seen, [FELL, "PLAYER_CAMPING", FELL]);
}
/// A quit's response signals `PLAYER_QUITING` at its packet, the quit byte its request stored
/// (`0x5ab053`) added to the id (`0x5aaf0c`).
#[test]
fn player_quiting_fires_at_its_packet() {
let (mut app, _rx) = logout_client();
run(&mut app, "Quit()");
let response = SessionEvent::LogoutResponse {
reason: 0,
instant: false,
};
let seen = frame(&mut app, vec![fall(5), response, fall(5)]);
assert_eq!(seen, [FELL, "PLAYER_QUITING", FELL]);
}
/// A cancel ack while a request is pending signals `LOGOUT_CANCEL` at its packet.
#[test]
fn logout_cancel_fires_at_the_acks_packet() {
let (mut app, _rx) = logout_client();
run(&mut app, "Logout()");
let seen = frame(
&mut app,
vec![fall(5), SessionEvent::LogoutCancelled, fall(5)],
);
assert_eq!(seen, [FELL, "LOGOUT_CANCEL", FELL]);
}
+7 -7
View File
@@ -681,13 +681,18 @@ pub(crate) fn world(listener: TcpListener, keys: Receiver<Key>) -> World {
let Some(key) = last else {
return;
};
// Held and counted before the client can see the session open, so a drop never misses
// it and `open` never reads behind the client's authentication.
// Held, counted and logged before the client can see the session open, so a drop never
// misses it and neither `open` nor `authentications` reads behind its authentication.
if let Ok(link) = s.try_clone() {
link_log.lock().unwrap().push(link);
}
let sessions = Arc::clone(&sessions);
sessions.fetch_add(1, Ordering::SeqCst);
let index = {
let mut all = session_log.lock().unwrap();
all.push(Vec::new());
all.len() - 1
};
let mut crypto = HeaderCrypto::from_session_key(key);
let reply = addon_reply.lock().unwrap().clone();
if let Some((body, false)) = &reply {
@@ -723,11 +728,6 @@ pub(crate) fn world(listener: TcpListener, keys: Receiver<Key>) -> World {
let refuse_flag = Arc::clone(&refuse_flag);
let refuse_wait = Arc::clone(&refuse_wait);
let trailing = Arc::clone(&trailing);
let index = {
let mut all = session_log.lock().unwrap();
all.push(Vec::new());
all.len() - 1
};
thread::spawn(move || {
while let Some(packet) = recv_packet(&mut s, Some(&mut crypto)) {
let op = u16::from_le_bytes([packet[2], packet[3]]);
+67 -8
View File
@@ -3574,16 +3574,75 @@ mod tests {
assert!(script.cursor_item().is_none());
}
/// A taxi passenger has no control but passes the gate (`0x494ba6`-`0x494ba9`).
/// `PickupContainerItem`'s control gate reads our taxi flag off the object as the call runs
/// (`0x4f9b87`-`0x4f9ba3`, the pair `0x494b97`-`0x494ba6` tests): without control, the store's
/// bit, written after every push, admits the pickup, and once cleared the next call is refused,
/// whatever the VM's copy says.
#[test]
fn the_pickup_gate_reads_the_taxi_flag_off_our_object_at_the_call() {
let mut f = frame(false);
with_bar_helm(&mut f, 0);
f.app
.world_mut()
.non_send_resource_mut::<UiScript>()
.set_player_control(false);
let me = f.app.world().resource::<GuidIndex>().0[&ME];
let flags = |f: &mut Frame, flags: u32| {
f.app
.world_mut()
.get_mut::<ObjectStore>(me)
.expect("our store")
.0
.merge(benilla_protocol::ObjectFields::from_pairs(&[(46, flags)]));
};
flags(&mut f, 0x8 | crate::player::UNIT_FLAG_TAXI_FLIGHT);
run(&mut f, "PickupContainerItem(0, 1)");
assert!(
f.app
.world()
.non_send_resource::<UiScript>()
.cursor_item()
.is_some(),
"on a taxi: picked up"
);
run(&mut f, "ClearCursor()");
flags(&mut f, 0x8);
f.app
.world_mut()
.non_send_resource_mut::<UiScript>()
.set_on_taxi(true);
run(&mut f, "PickupContainerItem(0, 1)");
assert!(
f.app
.world()
.non_send_resource::<UiScript>()
.cursor_item()
.is_none(),
"landed: refused, the VM's copy unread"
);
}
/// A taxi passenger has no control but passes the gate, which reads the flag off our object at
/// the call (`0x494b97`-`0x494ba9`): the store's bit, set after every push, passes it, and the
/// VM's copy says nothing while the host is lent.
#[test]
fn a_bar_equip_on_a_taxi_passes_the_control_gate() {
let mut f = frame(false);
with_bar_helm(&mut f, 0);
{
let mut script = f.app.world_mut().non_send_resource_mut::<UiScript>();
script.set_player_control(false);
script.set_on_taxi(true);
}
f.app
.world_mut()
.non_send_resource_mut::<UiScript>()
.set_player_control(false);
let me = f.app.world().resource::<GuidIndex>().0[&ME];
f.app
.world_mut()
.get_mut::<ObjectStore>(me)
.expect("our store")
.0
.merge(benilla_protocol::ObjectFields::from_pairs(&[(
46,
0x8 | crate::player::UNIT_FLAG_TAXI_FLIGHT,
)]));
run(&mut f, "UseAction(1, 0)");
let sent: Vec<_> = f.rx.try_iter().collect();
assert!(
@@ -4691,14 +4750,14 @@ mod tests {
);
let (writers, unhosted) = vm_writers_and_the_unhosted(&mut app);
// The census reads the client's systems: a hundred writers at least in either build, and
// where the build carries type names, a feed, a death feed and a frame poll among them.
// where the build carries type names, a feed and two frame polls among them.
assert!(
writers.len() >= 100,
"the census reads the client's VM writers: {} read",
writers.len()
);
if writers.iter().any(|w| w.contains("benilla_app::")) {
for name in ["feed_logout", "feed_death", "poll_area_spirit_healer"] {
for name in ["feed_framerate", "poll_corpse", "poll_area_spirit_healer"] {
assert!(
writers.iter().any(|w| w.contains(name)),
"the census reads the client's VM writers, `{name}` among them"
@@ -146,6 +146,9 @@ live_reads! {
loot: crate::ui_loot::LootLive<'static, 'static>,
/// The listed group loot rolls, their items' records and the clock their bars read.
loot_rolls: crate::ui_loot_roll::LootRollLive<'static>,
/// The death stores' timers, the offer, the healer's range and the self-res; absent in a
/// harness without the death stores.
death: Option<crate::death::DeathView<'static, 'static>>,
/// The game clock's hour and minute.
game_time: crate::net::GameTimeLive<'static>,
/// The joined-channel slot array.
@@ -269,6 +269,7 @@ fn the_death_verbs_send_inside_their_calls() {
name: "Priest".into(),
sickness: false,
has_timer: false,
waits_name: false,
});
}
eval::<()>(
@@ -303,7 +304,7 @@ fn accept_xp_loss_sends_inside_its_call_within_range() {
unit_at(&mut app, HEALER, yards);
app.world_mut()
.resource_mut::<crate::death::DeathNet>()
.ask_spirit_healer(HEALER);
.spirit_healer = Some(HEALER);
eval::<()>(&mut app, "AcceptXPLoss() RandomRoll(1, 2) AcceptXPLoss()");
let expected: &[&str] = if sends {
&[
+6 -2
View File
@@ -308,7 +308,6 @@ fn click_select(
pub(crate) struct ServiceArms<'w> {
/// The last `SMSG_QUESTGIVER_STATUS` per guid (`[unit+0xcb8]`), read by bit 1's `0x5df490`.
pub(crate) quest: Res<'w, crate::ui_quest::QuestGiver>,
pub(crate) death: ResMut<'w, crate::death::DeathNet>,
/// Bit 6 sends through the cache the proximity poll writes, so the two agree on the healer.
pub(crate) spirit: ResMut<'w, crate::ui_dialog_verbs::AreaSpiritHealer>,
/// The NPC whose window is open (`[0xb4e2d0]`), checked before the ladder.
@@ -1148,7 +1147,12 @@ impl Dispatch<'_, '_> {
debug!(
"right-click interact: {guid:#x} (spirit healer — CONFIRM_XP_LOSS, no packet)"
);
self.service.death.ask_spirit_healer(guid);
// `0x5df730` with the guid, its gates and its signal, with the world in hand.
self.feedback
.edits
.push_world(Box::new(move |world: &mut World| {
let _ = world.run_system_cached_with(crate::death::ask_spirit_healer, guid);
}));
}
ServiceAction::AcquireSpiritGuide => {
debug!("right-click interact: {guid:#x} (spirit guide — adopting, 0x2E2)");
+8 -16
View File
@@ -211,7 +211,7 @@ pub(super) struct Died<'w, 's> {
seam: AttackSeam<'w, 's>,
/// The release timer our own death arms.
death: ResMut<'w, crate::death::DeathNet>,
/// The real clock the release timer counts on, as the death feed reads it.
/// The real clock the release timer counts on, as the death getters read it.
time: Res<'w, Time<Real>>,
group: Res<'w, crate::ui_party::GroupState>,
names: Res<'w, crate::names::NameCache>,
@@ -631,9 +631,11 @@ mod tests {
let bit = |set: bool| u32::from(set) * 0x8;
c.values(ME, &[(FIELD_UNIT_HEALTH, 0), (BYTES, bit(armed))]);
c.values(ME, &[(BYTES, bit(!armed))]);
crate::death::run_feed_death_once(c.world());
let left: f64 =
crate::script_calls::eval_in_vm(c.world(), "return GetReleaseTimeRemaining()");
let left: f64 = crate::script_calls::with_hosted_vm(c.world(), |s| {
s.expect("a VM")
.eval("return GetReleaseTimeRemaining()")
.expect("runs")
});
let at_death = dead_reads(&mut c);
assert_eq!(at_death.len(), 1, "armed {armed}: {at_death:?}");
for read in [left, at_death[0]] {
@@ -648,9 +650,8 @@ mod tests {
/// Our own death's `PresentUnitDeath` (`0x6058ae`) ends in `SignalDeathState` for the active
/// player (`0x5fa6d0` at `0x6251c2`, `0x6251cc` → `0x495850`): `PLAYER_DEAD` inside the death's
/// packet, after `0x5e99b0` armed the timer, so its handlers read the whole window, and the
/// frame's feed signals it no second time. A second death past the first window reads a fresh
/// one.
/// packet, after `0x5e99b0` armed the timer, so its handlers read the whole window, and
/// nothing signals it a second time. A second death past the first window reads a fresh one.
#[test]
fn our_own_death_signals_player_dead_in_its_packet_over_the_timer_it_armed() {
let mut c = dying_client();
@@ -658,15 +659,8 @@ mod tests {
let first = dead_reads(&mut c);
assert_eq!(first.len(), 1, "PLAYER_DEAD in the packet: {first:?}");
assert!(first[0] > 359.0, "the whole window: {first:?}");
crate::death::run_feed_death_once(c.world());
assert_eq!(
dead_reads(&mut c).len(),
1,
"the feed signals it no second time"
);
c.values(ME, &[(FIELD_UNIT_HEALTH, 100)]);
crate::death::run_feed_death_once(c.world());
c.world()
.resource_mut::<Time<bevy::time::Real>>()
.update_with_duration(std::time::Duration::from_secs(400));
@@ -674,8 +668,6 @@ mod tests {
let second = dead_reads(&mut c);
assert_eq!(second.len(), 2, "{second:?}");
assert!(second[1] > 359.0, "a fresh window: {second:?}");
crate::death::run_feed_death_once(c.world());
assert_eq!(dead_reads(&mut c).len(), 2);
}
/// `SignalDeathState` clears the cursor after `PLAYER_DEAD` (`ClearCursor(1, 1)`, `0x495889`
+9 -2
View File
@@ -527,14 +527,18 @@ fn stone_notice(
/// it (`0x55f426`): each meeting-stone member line waiting on the name (`0x4ca510`), which a
/// refusal spends silently, and the duel's held challenge ([`crate::ui_duel`]).
#[derive(bevy::ecs::system::SystemParam)]
pub(crate) struct DialogNameAnswers<'w> {
pub(crate) struct DialogNameAnswers<'w, 's> {
/// Each absent in a harness without the dialogs.
lane: Option<ResMut<'w, DialogLane>>,
stone: Option<ResMut<'w, MeetingStone>>,
duel: Option<ResMut<'w, crate::ui_duel::DuelState>>,
/// The resurrect offer whose caster's name it waited on, and the active player its show
/// tests.
death: Option<ResMut<'w, crate::death::DeathNet>>,
me: Query<'w, 's, &'static ObjectStore, With<crate::net::SelfPlayer>>,
}
impl DialogNameAnswers<'_> {
impl DialogNameAnswers<'_, '_> {
/// `guid`'s answer just filed in `names`.
pub(crate) fn answered(&mut self, guid: u64, names: &NameCache) {
let Some(lane) = self.lane.as_deref_mut() else {
@@ -554,6 +558,9 @@ impl DialogNameAnswers<'_> {
if let Some(duel) = self.duel.as_deref_mut() {
crate::ui_duel::name_answered(duel, lane, guid, name);
}
if let Some(death) = self.death.as_deref_mut() {
crate::death::net::resurrecter_named(death, self.me.single().ok(), lane, guid, name);
}
}
}
+5
View File
@@ -279,6 +279,11 @@ fn answer_pending_equip(
// item, then the equip goes out ahead of its clear. A slot emptied under the dialog sends
// nothing (`0x5e18da`).
PendingEquip::AutoEquip { bag, slot, .. } => {
// The setter's control gate reads our taxi flag off the object (`0x494ba6`), here
// with the host out applying the accept.
script.set_on_taxi(
store.is_some_and(|s| s.0.unit_flags() & crate::player::UNIT_FLAG_TAXI_FLIGHT != 0),
);
script.auto_equip_slot(bag, slot, true);
}
}
@@ -160,10 +160,15 @@ impl RequirementsLive<'_, '_> {
Some(player_req_state(store, &inputs))
}
/// Seat the requirement state and the known spells in `script`, where the app's own reads
/// inside a call's apply, with no host to ask, find them: the item use's requirement gate
/// (`0x5d8e0e`) and the bar's equip question (`0x5e1650`).
/// Seat the requirement state, the known spells and our taxi flag in `script`, where the
/// app's own reads inside a call's apply, with no host to ask, find them: the item use's
/// requirement gate (`0x5d8e0e`), the bar's equip question (`0x5e1650`) and the cursor
/// setter's control gate, which reads the flag off our object (`0x494b97`-`0x494ba6`).
pub(crate) fn seat(&mut self, script: &mut benilla_ui::script::UiScript) {
script.set_on_taxi(
self.player()
.is_some_and(|s| s.0.unit_flags() & crate::player::UNIT_FLAG_TAXI_FLIGHT != 0),
);
script.set_player_req_state(self.req().unwrap_or_default());
if let Some(actions) = self.actions.as_deref() {
script.set_known_spells(actions.spells.iter().copied().collect());
+85 -86
View File
@@ -20,26 +20,47 @@ use bevy::ecs::system::SystemParam;
use bevy::prelude::*;
use crate::net::{ClientCommand, LoggedOutMessage, NetCommands, SelfGuid};
use crate::ui_script::UiFeed;
/// The refusal line for every non-zero reason, never `PLAYER_LOGOUT_FAILED_ERROR`: message `0x180`
/// of the `DisplayError` at `0x5aaf26`, a key so the player's `GlobalStrings.lua` supplies it.
const LOGOUT_FAILED_KEY: &str = "ERR_LOGOUT_FAILED";
/// What the wire told us to say next, queued because a cancel can land in its response's frame.
/// What a logout reply signals inside its handler, on the notice lane at the packet's place.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum LogoutSignal {
/// A timed logout started: `PLAYER_CAMPING`.
/// A timed logout started: `PLAYER_CAMPING` (276, `0x5aaf17`).
Camping,
/// The same for a quit: `PLAYER_QUITING`.
/// The same for a quit: `PLAYER_QUITING` (277), the quit byte added to the id (`0x5aaf0c`).
Quiting,
/// The logout was cancelled: `LOGOUT_CANCEL`.
/// The logout was cancelled: `LOGOUT_CANCEL` (278, `0x5aaf72`).
Cancelled,
/// Refused: an error line, no dialog.
/// Refused: the error line, no dialog (`0x5aaf26`).
Refused,
}
/// The pending session exit and the signals owed to the UI.
impl LogoutSignal {
/// The notice that signals it.
fn notice(self) -> crate::field_watch::FieldNotice {
use crate::field_watch::{id, FieldNotice};
match self {
Self::Camping => FieldNotice::Global {
id: id::PLAYER_CAMPING,
},
Self::Quiting => FieldNotice::Global {
id: id::PLAYER_QUITING,
},
Self::Cancelled => FieldNotice::Global {
id: id::LOGOUT_CANCEL,
},
Self::Refused => FieldNotice::Line {
key: LOGOUT_FAILED_KEY,
},
}
}
}
/// The session's logout bytes, which the replies' handlers and the session verbs read and write
/// in place.
#[derive(Resource, Default)]
pub(crate) struct LogoutState {
/// The reference's `[session+0x1b1c]`, the one bit the wire lacks, as a quit is also
@@ -56,7 +77,6 @@ pub(crate) struct LogoutState {
/// the quit byte (`0x5ab020`-`0x5ab02a`), so a `Logout()` on a worldport's loading screen sends
/// nothing.
world_handle: bool,
signals: Vec<LogoutSignal>,
}
impl LogoutState {
@@ -65,38 +85,38 @@ impl LogoutState {
self.pending
}
/// `SMSG_LOGOUT_RESPONSE`, the module doc's table; an instant logout signals nothing.
pub(crate) fn apply_response(&mut self, reason: u32, instant: bool) {
/// `SMSG_LOGOUT_RESPONSE` (`0x5aaef0`), the module doc's table: what it signals, nothing for
/// an instant logout.
fn apply_response(&mut self, reason: u32, instant: bool) -> Option<LogoutSignal> {
// Logged: the server's inputs (combat, resting, account level) are invisible from here.
info!("logout: server answered reason={reason} instant={instant}");
if reason != 0 {
// `0x5aaf21`: the error line, and the pending flag clears so the player can retry.
self.pending = false;
self.signals.push(LogoutSignal::Refused);
return;
return Some(LogoutSignal::Refused);
}
if instant {
return;
return None;
}
self.signals.push(if self.quitting {
Some(if self.quitting {
LogoutSignal::Quiting
} else {
LogoutSignal::Camping
});
})
}
/// `SMSG_LOGOUT_CANCEL_ACK` (`0x5b4680`, then `0x5aaf60`). `CancelLogout` clears the pending
/// byte as it sends (`0x5aafc2`), so the ack of the player's own cancel fires nothing.
pub(crate) fn apply_cancelled(&mut self) {
self.call_off();
/// byte as it sends (`0x5aafc2`), so the ack of the player's own cancel signals nothing.
fn apply_cancelled(&mut self) -> Option<LogoutSignal> {
self.call_off()
}
/// The world left, `0x5aae70(0)`: by a world load (`0x401bd4`), by the logout's completion
/// (`0x5aaeb3` → `0x5aaf4f`, ahead of the teardown at `0x5aaeca`), and by a refused login
/// (`0x5aad76` → `0x5aaf4f`). A completed logout that was not forced fires `LOGOUT_CANCEL`.
pub(crate) fn apply_left_world(&mut self) {
/// (`0x5aad76` → `0x5aaf4f`). A completed logout that was not forced signals `LOGOUT_CANCEL`.
fn apply_left_world(&mut self) -> Option<LogoutSignal> {
self.world_handle = false;
self.call_off();
self.call_off()
}
/// The world handle seated, as a test of the verbs in the world needs it.
@@ -107,41 +127,11 @@ impl LogoutState {
/// `LOGOUT_CANCEL` only while a request is pending (`0x5aaf63`-`0x5aaf6b`,
/// `0x5aae88`-`0x5aae90`), then the byte clears (`0x5aaf77`, `0x5aae9c`).
fn call_off(&mut self) {
if std::mem::take(&mut self.pending) {
self.signals.push(LogoutSignal::Cancelled);
}
fn call_off(&mut self) -> Option<LogoutSignal> {
std::mem::take(&mut self.pending).then_some(LogoutSignal::Cancelled)
}
}
/// Fire the signals in wire order: the events the stock CAMP and QUIT dialogs hang off, and the
/// refusal line.
fn feed_logout(
mut vm: crate::script_calls::VmWith<ResMut<'static, LogoutState>>,
mut sink: crate::ui_action::MessageSink,
) {
let signals = std::mem::take(&mut vm.own().signals);
if signals.is_empty() {
return;
}
vm.run(|script| {
let Some(script) = script else {
return;
};
for signal in signals {
match signal {
LogoutSignal::Camping => script.fire_event("PLAYER_CAMPING", Vec::new()),
LogoutSignal::Quiting => script.fire_event("PLAYER_QUITING", Vec::new()),
LogoutSignal::Cancelled => script.fire_event("LOGOUT_CANCEL", Vec::new()),
LogoutSignal::Refused => {
let line = crate::ui_action::keyed_line(script, LOGOUT_FAILED_KEY);
crate::ui_action::show_messages(script, &mut sink, "ui_logout", line);
}
}
}
})
}
/// What a session verb posts past its call, which nothing the script reads waits on: the process's
/// exit, as `ForceQuit` posts the context's close (`0x48ab60` → `0x401560`), which
/// [`exit_on_logout_complete`] takes, and the cinematic's stop, which schedules the end's fade
@@ -313,10 +303,7 @@ impl Plugin for UiLogoutPlugin {
.init_resource::<SessionPosts>()
.add_systems(
Update,
(
feed_logout.in_set(UiFeed),
exit_on_logout_complete.in_set(crate::ui_script::UiDrain),
),
exit_on_logout_complete.in_set(crate::ui_script::UiDrain),
)
.add_systems(
PreUpdate,
@@ -385,8 +372,14 @@ mod net {
.net_handler(K::CharacterLoginFailed, on_narration);
}
fn on_narration(In(ev): In<SessionEvent>, mut logout: ResMut<LogoutState>) {
match ev {
/// Each reply's signal goes on the notice lane at its packet's place, as the reference's
/// handlers signal in place (`0x5aaf17`, `0x5aaf26`, `0x5aaf72`, `0x5aae96`).
fn on_narration(
In(ev): In<SessionEvent>,
mut logout: ResMut<LogoutState>,
mut lane: ResMut<crate::field_watch::NoticeLane>,
) {
let signal = match ev {
SessionEvent::LogoutResponse { reason, instant } => {
logout.apply_response(reason, instant)
}
@@ -400,7 +393,10 @@ mod net {
}
| SessionEvent::LoggedOut
| SessionEvent::CharacterLoginFailed { .. } => logout.apply_left_world(),
_ => {}
_ => None,
};
if let Some(signal) = signal {
lane.write(signal.notice());
}
}
}
@@ -416,31 +412,32 @@ mod tests {
#[test]
fn the_response_decides_which_dialog_if_any() {
let mut s = LogoutState::default();
s.apply_response(0, true);
assert!(s.signals.is_empty(), "an instant logout shows no dialog");
s.apply_response(0, false);
assert_eq!(s.signals, vec![LogoutSignal::Camping]);
assert_eq!(
s.apply_response(0, true),
None,
"an instant logout shows no dialog"
);
assert_eq!(s.apply_response(0, false), Some(LogoutSignal::Camping));
let mut s = LogoutState {
quitting: true,
pending: true,
signals: Vec::new(),
..LogoutState::default()
};
s.apply_response(0, false);
assert_eq!(s.signals, vec![LogoutSignal::Quiting], "a quit says so");
assert_eq!(
s.apply_response(0, false),
Some(LogoutSignal::Quiting),
"a quit says so"
);
// In combat: the error line (`0x5aaf21`) and the pending byte cleared (`0x5aaf2e`); the
// quit byte stays, as only a request writes it (`0x5ab053`).
let mut s = LogoutState {
quitting: true,
pending: true,
signals: Vec::new(),
..LogoutState::default()
};
s.apply_response(1, false);
assert_eq!(s.signals, vec![LogoutSignal::Refused]);
assert_eq!(s.apply_response(1, false), Some(LogoutSignal::Refused));
assert!(s.quitting, "the refusal leaves the quit byte");
assert!(
!s.pending,
@@ -462,6 +459,14 @@ mod tests {
(app, rx)
}
/// What the logout replies' handlers put on the notice lane, taken.
fn notices(app: &mut App) -> Vec<crate::field_watch::FieldNotice> {
app.world_mut()
.resource_mut::<crate::field_watch::NoticeLane>()
.drain()
.collect()
}
/// Run `chunk` with the host lent; what it sent of the logout's and the roll's packets.
fn sent_by(
app: &mut App,
@@ -541,16 +546,12 @@ mod tests {
let mut s = LogoutState {
quitting: true,
pending: true,
signals: Vec::new(),
..LogoutState::default()
};
s.apply_cancelled();
assert_eq!(s.signals, vec![LogoutSignal::Cancelled]);
assert_eq!(s.apply_cancelled(), Some(LogoutSignal::Cancelled));
assert!(!s.pending);
assert!(s.quitting, "the ack leaves the quit byte");
s.signals.clear();
s.apply_cancelled();
assert!(s.signals.is_empty(), "nothing pending, nothing fired");
assert_eq!(s.apply_cancelled(), None, "nothing pending, nothing fired");
}
/// The ack of the player's own cancel fires nothing: `CancelLogout` (`0x5aaf80`) clears the
@@ -566,7 +567,7 @@ mod tests {
app.world_mut(),
vec![SessionEvent::LogoutCancelled, SessionEvent::LogoutCancelled],
);
assert!(app.world().resource::<LogoutState>().signals.is_empty());
assert!(notices(&mut app).is_empty());
}
/// A world load leaves the world first (`0x401bd4` → `0x5aae70(0)`), which fires
@@ -595,7 +596,7 @@ mod tests {
crate::net::handlers::dispatch(app.world_mut(), vec![port()]);
let logout = app.world().resource::<LogoutState>();
assert!(logout.pending, "the packet only posts the load");
assert!(logout.signals.is_empty());
assert!(notices(&mut app).is_empty());
assert_eq!(cancelled(&app), 0);
app.world_mut()
.run_system_cached(leave_world)
@@ -623,14 +624,13 @@ mod tests {
let (mut app, rx) = client();
assert_eq!(sent_by(&mut app, &rx, "Logout()"), ["logout"]);
crate::net::handlers::dispatch(app.world_mut(), vec![SessionEvent::LoggedOut]);
let logout = app.world().resource::<LogoutState>();
assert!(!logout.pending);
assert_eq!(logout.signals, [LogoutSignal::Cancelled]);
assert!(!app.world().resource::<LogoutState>().pending);
assert_eq!(notices(&mut app), [LogoutSignal::Cancelled.notice()]);
let (mut app, rx) = client();
assert_eq!(sent_by(&mut app, &rx, "ForceLogout()"), ["force"]);
crate::net::handlers::dispatch(app.world_mut(), vec![SessionEvent::LoggedOut]);
assert!(app.world().resource::<LogoutState>().signals.is_empty());
assert!(notices(&mut app).is_empty());
}
/// `SMSG_CHARACTER_LOGIN_FAILED` (`0x5b45f0` → `0x5aad70`) leaves the world first
@@ -643,9 +643,8 @@ mod tests {
app.world_mut(),
vec![SessionEvent::CharacterLoginFailed { result: 1 }],
);
let logout = app.world().resource::<LogoutState>();
assert!(!logout.pending);
assert_eq!(logout.signals, [LogoutSignal::Cancelled]);
assert!(!app.world().resource::<LogoutState>().pending);
assert_eq!(notices(&mut app), [LogoutSignal::Cancelled.notice()]);
}
/// A world load zeroes the world handle (`0x401bd4` → `0x5aae70(0)`, stored at `0x5aae82`)
@@ -1,5 +1,5 @@
//! The stock death popups (`StaticPopup.lua`): release, self-resurrect, resurrect offers, the
//! spirit healer's confirm and the corpse run, driven as the app's death feed drives them.
//! spirit healer's confirm and the corpse run, driven over the VM's copy of the death state.
use benilla_ui::script::{DeathAction, DeathUiState, ScriptValue, UiScript};
@@ -495,7 +495,10 @@ fn the_death_timers_answer_whole_seconds() {
1.0
);
// No timer: `0x4962a0` answers -1000 ms, which the signed divide keeps as -1.
s.set_death(DeathUiState::default());
s.set_death(DeathUiState {
release_remaining: None,
..Default::default()
});
assert_eq!(
s.eval::<f64>("return GetReleaseTimeRemaining()").unwrap(),
-1.0
+4 -66
View File
@@ -9,9 +9,10 @@ use bevy::prelude::*;
#[cfg(test)]
use benilla_ui::script::UiScript;
#[cfg(test)]
use crate::net::{ObjectStore, SelfPlayer};
use crate::player::UNIT_FLAG_TAXI_FLIGHT;
use crate::ui_script::{SweepApp, SweepLeg, UiFeed};
use crate::ui_script::{SweepApp, SweepLeg};
use crate::ui_session::{LatchApp, LatchedWindow, NpcWindow};
mod calls;
@@ -210,32 +211,6 @@ pub(crate) struct FlightMasterStatus {
pub(crate) known: bool,
}
/// Push `UnitOnTaxi("player")`: the reference's verb (`0x517a40`) answers bit 20 of
/// `UNIT_FIELD_FLAGS` (`0x517a86`), which vmangos sets only for a flight
/// (`FlightPathMovementGenerator`). Any other server spline, such as a fear, is not a taxi: stock
/// `UIParent.lua:474-478` closes the windows on `PLAYER_CONTROL_LOST` unless on a taxi. No self
/// store reads as not on a taxi.
fn feed_on_taxi(
mut hosted_vm: crate::script_calls::HostedVm,
self_q: Query<&ObjectStore, With<SelfPlayer>>,
mut last: Local<crate::ui_script::VmMemo<Option<bool>>>,
) {
hosted_vm.run(|script| {
let Some(script) = script else {
return;
};
let last = last.get(script);
let on_taxi = self_q
.iter()
.next()
.is_some_and(|s| s.0.unit_flags() & UNIT_FLAG_TAXI_FLIGHT != 0);
if *last != Some(on_taxi) {
script.set_on_taxi(on_taxi);
*last = Some(on_taxi);
}
})
}
mod net;
pub(crate) struct UiTaxiPlugin;
@@ -248,7 +223,7 @@ impl Plugin for UiTaxiPlugin {
.init_resource::<TaxiRouteCache>()
.add_latched_window::<TaxiState>()
.add_sweep_leg(SweepLeg::Taxi, leave_world)
.add_systems(Update, (load_taxi_catalogs, feed_on_taxi.in_set(UiFeed)));
.add_systems(Update, load_taxi_catalogs);
}
}
@@ -265,43 +240,6 @@ mod tests {
use benilla_protocol::field::FIELD_UNIT_FLAGS;
use benilla_protocol::ObjectFields;
/// The feed pushes the ride with the bit and clears it without; it reads nothing about server
/// splines.
#[test]
fn the_feed_pushes_the_taxi_flight_flag() {
let mut app = App::new();
app.add_systems(Update, feed_on_taxi);
app.insert_non_send_resource(UiScript::new().unwrap());
let me = app
.world_mut()
.spawn((
SelfPlayer,
ObjectStore(ObjectFields::from_pairs(&[(FIELD_UNIT_FLAGS, 0x1000)])),
))
.id();
let on_taxi = |app: &mut App| -> bool {
app.update();
app.world().non_send_resource::<UiScript>().on_taxi()
};
assert!(!on_taxi(&mut app), "no TAXI_FLIGHT bit: nil");
app.world_mut()
.entity_mut(me)
.insert(ObjectStore(ObjectFields::from_pairs(&[(
FIELD_UNIT_FLAGS,
0x1000 | UNIT_FLAG_TAXI_FLIGHT,
)])));
assert!(on_taxi(&mut app), "the bit set: 1");
app.world_mut()
.entity_mut(me)
.insert(ObjectStore(ObjectFields::from_pairs(&[(
FIELD_UNIT_FLAGS,
0,
)])));
assert!(!on_taxi(&mut app), "landed: nil again");
}
/// The map's fares take the flight master's discount and the express leg sends the raw route
/// sum (`0x4dc3d0` against `0x4dc96f`). Honored, a PvP-flagged flight master and honor rank
/// byte 6 make 0.15: Sentinel Hill's direct 110 shows 94, and Thelsamar's route through
+3
View File
@@ -995,6 +995,9 @@ impl benilla_ui::script::SelfRead for StoreObject<'_> {
fn action_bar_toggles(&self) -> u8 {
self.0 .0.player_action_bar_toggles().unwrap_or(0)
}
fn on_taxi(&self) -> bool {
self.0 .0.unit_flags() & crate::player::UNIT_FLAG_TAXI_FLIGHT != 0
}
}
/// `PLAYER_FLAGS` bit 7, free-for-all PvP (vmangos `Player.h:322`).
@@ -623,6 +623,15 @@ pub(crate) fn fire(
vec![ScriptValue::Int(i64::from(free_repop))],
),
FieldNotice::MinimapPing(ping) => ping.fire(script),
FieldNotice::Revived => {
script.unlock_all_items();
script.fire_event("PLAYER_ALIVE", vec![]);
}
FieldNotice::Line { key } => {
if let Some(line) = crate::ui_action::keyed_line(script, key) {
crate::ui_action::show_now(script, sink, "ui_unit", line);
}
}
FieldNotice::PvpPreference { on } => {
let (toast, verbose) = super::pvp_announcement(on);
// The verbose sentence is no catalog row, so it goes `unkeyed` to chat:
@@ -780,6 +789,9 @@ fn global_event(id: u16) -> Option<&'static str> {
id::PET_BAR_UPDATE => "PET_BAR_UPDATE",
id::AREA_SPIRIT_HEALER_IN_RANGE => "AREA_SPIRIT_HEALER_IN_RANGE",
id::AREA_SPIRIT_HEALER_OUT_OF_RANGE => "AREA_SPIRIT_HEALER_OUT_OF_RANGE",
id::PLAYER_CAMPING => "PLAYER_CAMPING",
id::PLAYER_QUITING => "PLAYER_QUITING",
id::LOGOUT_CANCEL => "LOGOUT_CANCEL",
id::INSPECT_HONOR_UPDATE => "INSPECT_HONOR_UPDATE",
id::PLAYERBANKBAGSLOTS_CHANGED => "PLAYERBANKBAGSLOTS_CHANGED",
id::PLAYER_FARSIGHT_FOCUS_CHANGED => "PLAYER_FARSIGHT_FOCUS_CHANGED",
+2 -2
View File
@@ -541,7 +541,7 @@ fn use_cleared(
if let (UseArm::Item(UseFork::Equip), Some(item)) = (arm, equip) {
// Without control the equip arm returns before it locks or sends, unless on a taxi
// (`0x4fa3ce`-`0x4fa3ec`).
return cursor::equip::has_cursor_control(model).then_some(item);
return cursor::equip::has_cursor_control(lua, model).then_some(item);
}
// The use dispatcher's gates (`0x5d8d00`), each showing its line and ending the call before
// the arm's lock (`0x5edcd9`): the requirement check ahead of the read, letter, open and
@@ -627,7 +627,7 @@ fn pickup_container_item(
) -> ContainerClick {
// Without control and off a taxi the click ends before anything is read
// (`0x4f9b87`-`0x4f9ba3`).
if !cursor::equip::has_cursor_control(model) {
if !cursor::equip::has_cursor_control(lua, model) {
return ContainerClick::Done;
}
// The slot as the click finds it now, by its own place.
+4 -4
View File
@@ -548,9 +548,9 @@ impl Setter {
}
/// Whether the setter runs, by the player-control flag `[0xb4b3e4]`.
fn admits(self, model: &Model) -> bool {
fn admits(self, lua: &Lua, model: &Model) -> bool {
match self {
Setter::Item => equip::has_cursor_control(model),
Setter::Item => equip::has_cursor_control(lua, model),
Setter::Controlled => model.player_control,
Setter::Free => true,
}
@@ -571,7 +571,7 @@ pub(crate) fn set_cursor(
payload: impl FnOnce(&Model) -> Option<CursorPayload>,
) -> bool {
let admitted = verb(lua, |model| {
if !setter.admits(model) {
if !setter.admits(lua, model) {
return false;
}
clear(
@@ -801,7 +801,7 @@ pub(crate) fn split_container_item(
let item = {
let model = lua.app_data_ref::<Model>().expect("model app_data");
// Without control and off a taxi the split ends first (`0x4f9fdb`-`0x4f9ff7`).
if !equip::has_cursor_control(&model) {
if !equip::has_cursor_control(lua, &model) {
return Ok(false);
}
// The slot resolver (`0x4fa00a`), through the bag lookup `0x4f93e0`.
+1 -1
View File
@@ -77,7 +77,7 @@ pub(super) fn doll_click(
) -> DollClick {
// Without control and off a taxi the click ends before the cursor is read
// (`0x4c7345`-`0x4c7360`).
if !super::equip::has_cursor_control(model) {
if !super::equip::has_cursor_control(lua, model) {
return DollClick::Done(false);
}
// Lua 0, the 0-based slot -1, is the ammo leg (`0x4c73a6`).
+11 -4
View File
@@ -235,11 +235,18 @@ pub(crate) fn auto_equip_cursor_item(lua: &Lua, model: &mut Model) -> bool {
/// `SetCursorItem`'s control gate (`0x494b8d`): without control of the character
/// (`[0xb4b3e4]`, `SMSG_CLIENT_CONTROL_UPDATE`) the set returns before its clear, unless the
/// player is on a taxi (`UNIT_FLAG_TAXI_FLIGHT`). The UseContainerItem equip arm
/// (`0x4fa3ce`-`0x4fa3ec`), `PickupContainerItem` (`0x4f9b87`-`0x4f9ba3`) and
/// player is on a taxi (`UNIT_FLAG_TAXI_FLIGHT`), read off the active player's object at the call
/// (`0x494b97`-`0x494ba6`) through the lent host, else off `model`'s copy. The UseContainerItem
/// equip arm (`0x4fa3ce`-`0x4fa3ec`), `PickupContainerItem` (`0x4f9b87`-`0x4f9ba3`) and
/// `PickupInventoryItem` (`0x4c7345`-`0x4c7360`) test the same pair first.
pub(crate) fn has_cursor_control(model: &Model) -> bool {
model.player_control || model.taxi_riding
pub(crate) fn has_cursor_control(lua: &Lua, model: &Model) -> bool {
use crate::script::SelfRead;
if model.player_control {
return true;
}
let mut live = None;
crate::script::host::read_host(lua, |h| h.read_self(&mut |own| live = Some(own.on_taxi())));
live.unwrap_or_else(|| model.on_taxi())
}
/// `0x5e1840`: `SetCursorItem(1, …)` puts the item on the cursor, its inner clear dropping and
+96 -33
View File
@@ -1,15 +1,70 @@
//! The release, reclaim, resurrect and self-res verbs and the getters the `DEATH`,
//! `RECOVER_CORPSE`, `RESURRECT` and `XP_LOSS` dialogs call, over a snapshot the app pushes.
//! The three predicates answer `1` or nil, as the reference does (`ResurrectHasSickness`
//! `0x48aa00`, `ResurrectHasTimer` `0x48aa30`, `CheckSpiritHealerDist` `0x48d120`).
//! `RECOVER_CORPSE`, `RESURRECT` and `XP_LOSS` dialogs call, each reading the death state through
//! the lent host as it runs ([`DeathQuery`]), as the reference's read their globals at the call
//! (`GetCorpseRecoveryDelay` `0x48b5d0`). The three predicates answer `1` or nil, as the reference
//! does (`ResurrectHasSickness` `0x48aa00`, `ResurrectHasTimer` `0x48aa30`,
//! `CheckSpiritHealerDist` `0x48d120`).
use mlua::{Lua, Value};
use super::binding_abi::flag;
use super::live::{ask, LiveQuery};
use super::Model;
/// The death snapshot the app pushes each frame.
#[derive(Clone, Debug, Default, PartialEq)]
/// The death state the getters read through the host as they run; the VM's copy of it
/// ([`super::UiScript::set_death`]) answers only with no host to ask.
pub struct DeathQuery;
impl LiveQuery for DeathQuery {
type Answer = DeathUiState;
}
/// The active player's level, which `GetResSicknessDuration` words the sickness by; `None` with
/// no active player held.
pub struct ResSicknessLevelQuery;
impl LiveQuery for ResSicknessLevelQuery {
type Answer = u32;
}
/// The death state as the getters read it now: the host's, else the VM's copy, which only a test
/// sets (every production entry that runs Lua lends the host).
fn state(lua: &Lua) -> DeathUiState {
ask(lua, &DeathQuery).unwrap_or_else(|| {
lua.app_data_ref::<Model>()
.expect("model app_data")
.death
.clone()
})
}
/// The sickness a spirit-healer res applies at `level`, per vmangos `Player::ResurrectPlayer`:
/// none below 11, `level - 10` minutes through 19, 10 minutes from 20. Worded with `GENERIC_MIN`,
/// the minute arm of the reference's formatter (`0x51a3a0` into `0x52fa50`).
///
/// Deviation: the minutes come from the server's table, not from spell 15007's `Spell.dbc`
/// duration, because the aura the server applies is what the dialog must warn about.
pub(crate) fn sickness_duration(
level: u32,
strings: crate::strings::Strings<'_>,
) -> Option<String> {
let minutes = match level {
0..=10 => return None,
11..=19 => level - 10,
_ => 10,
};
// `GetText(token, nil, ordinal)`, the VM's own.
let template = crate::strings::plural("GENERIC_MIN", Some(minutes), strings)?;
Some(crate::strings::fill(
&template,
&[crate::strings::Arg::D(i64::from(minutes))],
))
}
/// The death state the getters read: the VM's copy when no host is lent to answer
/// [`DeathQuery`]. A fresh copy is the state `UI_Init` leaves: the release timer zeroed
/// (`0x490131`), which reads 0, and nothing offered.
#[derive(Clone, Debug, PartialEq)]
pub struct DeathUiState {
/// Seconds until the server force-releases, counted from death against the 6-minute
/// `CORPSE_REPOP_TIME` the wire never carries. `None` (`PLAYER_FIELD_BYTES` bit `0x08` clear,
@@ -24,8 +79,9 @@ pub struct DeathUiState {
pub resurrect_has_timer: bool,
/// The confirming spirit healer is in dialog range (`CheckSpiritHealerDist`).
pub spirit_healer_in_range: bool,
/// The sickness duration a spirit-healer res would apply ("N minutes"); `None` below the
/// sickness level picks `XP_LOSS_NO_SICKNESS` (`UIParent.lua:399-408`).
/// The VM's copy of the sickness duration a spirit-healer res would apply ("N minutes");
/// `None` below the sickness level picks `XP_LOSS_NO_SICKNESS` (`UIParent.lua:399-408`). The
/// host answers the level instead ([`ResSicknessLevelQuery`]), which the getter words.
pub sickness_duration: Option<String>,
/// `HasSoulstone()`'s label (`0x48ac80`), stamped on the DEATH dialog's second button:
/// `PLAYER_SELF_RES_SPELL`'s `Spell.dbc` name (3026 and 20758-20761 "Use Soulstone", 21169
@@ -33,6 +89,20 @@ pub struct DeathUiState {
pub self_res_label: Option<String>,
}
impl Default for DeathUiState {
fn default() -> Self {
Self {
release_remaining: Some(0.0),
recovery_delay: 0.0,
resurrect_sickness: false,
resurrect_has_timer: false,
spirit_healer_in_range: false,
sickness_duration: None,
self_res_label: None,
}
}
}
/// The death verbs the host applies inside their calls ([`super::ScriptCall::Death`]).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DeathAction {
@@ -63,7 +133,7 @@ pub enum DeathAction {
}
impl super::UiScript {
/// Push this frame's death snapshot, before the event dispatch.
/// Set the VM's copy of the death state, which the getters read with no host to ask.
pub fn set_death(&mut self, state: DeathUiState) {
self.model_mut().death = state;
}
@@ -109,9 +179,7 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
g.set(
"GetReleaseTimeRemaining",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
Ok(model
.death
Ok(state(lua)
.release_remaining
.map_or(-1.0, |s| f64::from(s.max(0.0).trunc())))
})?,
@@ -121,40 +189,36 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
// (`0x48b5f0`-`0x48b5f7`).
g.set(
"GetCorpseRecoveryDelay",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
Ok(f64::from(model.death.recovery_delay.max(0.0).floor()))
})?,
lua.create_function(|lua, ()| Ok(f64::from(state(lua).recovery_delay.max(0.0).floor())))?,
)?;
g.set(
"ResurrectHasSickness",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
Ok(flag(model.death.resurrect_sickness))
})?,
lua.create_function(|lua, ()| Ok(flag(state(lua).resurrect_sickness)))?,
)?;
g.set(
"ResurrectHasTimer",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
Ok(flag(model.death.resurrect_has_timer))
})?,
lua.create_function(|lua, ()| Ok(flag(state(lua).resurrect_has_timer)))?,
)?;
g.set(
"CheckSpiritHealerDist",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
Ok(flag(model.death.spirit_healer_in_range))
})?,
lua.create_function(|lua, ()| Ok(flag(state(lua).spirit_healer_in_range)))?,
)?;
g.set(
"GetResSicknessDuration",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
Ok(match &model.death.sickness_duration {
Some(s) => Value::String(lua.create_string(s)?),
let duration = match ask(lua, &ResSicknessLevelQuery) {
Some(level) => sickness_duration(level, crate::strings::Strings::Vm(lua)),
None => lua
.app_data_ref::<Model>()
.expect("model app_data")
.death
.sickness_duration
.clone(),
};
Ok(match duration {
Some(s) => Value::String(lua.create_string(&s)?),
None => Value::Nil,
})
})?,
@@ -165,9 +229,8 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
g.set(
"HasSoulstone",
lua.create_function(|lua, ()| {
let model = lua.app_data_ref::<Model>().expect("model app_data");
Ok(match &model.death.self_res_label {
Some(s) => Value::String(lua.create_string(s)?),
Ok(match state(lua).self_res_label {
Some(s) => Value::String(lua.create_string(&s)?),
None => Value::Nil,
})
})?,
+1 -1
View File
@@ -319,7 +319,7 @@ pub use cvars::{
CVAR_WORLD_DETAIL, IN_WORLD_READ_ONLY_CVARS, LUA_CVAR_LIMIT, VIDEO_DEFAULT_CVARS,
WORLD_DETAIL_STOPS,
};
pub use death::{DeathAction, DeathUiState};
pub use death::{DeathAction, DeathQuery, DeathUiState, ResSicknessLevelQuery};
pub use dialog_live::{
meeting_stone_text, AreaSpiritHealerSecsQuery, BinderPendingQuery, CanResetInstancesQuery,
InstanceBootSecsQuery, InstanceTypeQuery, MeetingStoneQuery, MeetingStoneStatus,
@@ -227,6 +227,9 @@ pub trait SelfRead {
fn combo_target(&self) -> u64;
/// `PLAYER_FIELD_BYTES` byte 2 (`+0x102a`), `GetActionBarToggles`' (`0x4e768c`).
fn action_bar_toggles(&self) -> u8;
/// `UNIT_FIELD_FLAGS` bit 20 (`+0xa0`, `UNIT_FLAG_TAXI_FLIGHT`), which the cursor setter's
/// control gate reads off the object at the call (`0x494b97`-`0x494ba6`).
fn on_taxi(&self) -> bool;
/// Whether an active player is held (`0x468550` → `0x468460`), `CanReadUnitInventory`'s
/// first test (`0x4944c9`); only [`NoPlayer`] holds none.
fn held(&self) -> bool {
@@ -283,6 +286,9 @@ impl SelfRead for NoPlayer {
fn action_bar_toggles(&self) -> u8 {
0
}
fn on_taxi(&self) -> bool {
false
}
fn held(&self) -> bool {
false
}
@@ -332,6 +338,9 @@ impl SelfRead for Model {
fn action_bar_toggles(&self) -> u8 {
self.action_bar_toggles.unwrap_or(0)
}
fn on_taxi(&self) -> bool {
self.taxi_riding
}
}
/// `f` over the unit object held under `guid` and its combat stats through the lent host, as of
+4 -7
View File
@@ -112,17 +112,14 @@ impl super::UiScript {
self.model_mut().taxi = state;
}
/// Whether the player is riding a taxi (`UNIT_FLAG_TAXI_FLIGHT`), for the equip control gate
/// (`0x494ba6`); `UnitOnTaxi` reads the flag off the unit itself.
/// Seat the VM's copy of the active player's taxi flag (`UNIT_FLAG_TAXI_FLIGHT`), which the
/// cursor control gate reads with no host to ask (`0x494ba6`): the app seats it off our
/// object before a call's apply reaches the gate, and with the host lent the gate reads the
/// object itself.
pub fn set_on_taxi(&mut self, riding: bool) {
self.model_mut().taxi_riding = riding;
}
/// What [`Self::set_on_taxi`] last pushed.
pub fn on_taxi(&self) -> bool {
self.model_ref().taxi_riding
}
/// The taxi calls a harness's VM kept ([`Self::keep_calls`]), in call order.
pub fn take_taxi_calls(&mut self) -> Vec<TaxiCall> {
self.take_calls_where(|call| match call {
+6 -5
View File
@@ -36,7 +36,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
- [benilla-lua](#benilla-lua): 11
- [benilla-protocol](#benilla-protocol): 29
- [benilla-srp](#benilla-srp): 2
- [benilla-ui](#benilla-ui): 134
- [benilla-ui](#benilla-ui): 135
- [benilla-world](#benilla-world): 49
### benilla-app
@@ -129,7 +129,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### death
- The minutes come from the server's table, not from spell 15007's `Spell.dbc` duration, because the aura the server applies is what the dialog must warn about. ([`src/death/mod.rs:601`](../crates/benilla-app/src/death/mod.rs#L601))
- `0x492130` compares the positions whatever map we stand on, so a ghost on another map at the corpse's coordinates reads in range for a reclaim the server refuses; here only the corpse's display map counts. ([`src/death/mod.rs:332`](../crates/benilla-app/src/death/mod.rs#L332))
#### entities
@@ -286,8 +286,8 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### target
- The reference's arm reads the last object's stop (`0x611336` before `0x610383` stores this one's), so its first walk has no stop. ([`src/target/click.rs:742`](../crates/benilla-app/src/target/click.rs#L742))
- It runs on the first frame with none, so an arrival that sends no stop (mid-air, rooted, under a held turn key) acts at once or on landing or release, where the reference waits for the next ground stop and can act long after, wherever the player then is. ([`src/target/click.rs:1689`](../crates/benilla-app/src/target/click.rs#L1689))
- The reference's arm reads the last object's stop (`0x611336` before `0x610383` stores this one's), so its first walk has no stop. ([`src/target/click.rs:741`](../crates/benilla-app/src/target/click.rs#L741))
- It runs on the first frame with none, so an arrival that sends no stop (mid-air, rooted, under a held turn key) acts at once or on landing or release, where the reference waits for the next ground stop and can act long after, wherever the player then is. ([`src/target/click.rs:1693`](../crates/benilla-app/src/target/click.rs#L1693))
- The rank is held to 7, the top of the ring scale's eight entries (`0..=7`), where the reference keeps any value; a server rank past 7 would index outside our palette. ([`src/target/relations.rs:487`](../crates/benilla-app/src/target/relations.rs#L487))
- TAB uses Classic Era's screen-space priority, not 1.12's ±30° facing cone and snapshot cursor (`0x493f60`), because the cone skips a close mob in front of the camera, which sits behind the character. ([`src/target/scan.rs:3`](../crates/benilla-app/src/target/scan.rs#L3))
- Our own body is never a candidate. The reference's friendly scan picks the player at some facings (`CanAssist(P, P)` is true, `0x6061e0`; the cone test `0x47f220`), but our scoring always puts the player dead centre at distance 0, so CTRL-TAB would pick us on every press. ([`src/target/scan.rs:194`](../crates/benilla-app/src/target/scan.rs#L194))
@@ -771,6 +771,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
- Always empty, because a refresh rate is only selectable through an exclusive mode-set and benilla has none. ([`src/script/cvars.rs:1010`](../crates/benilla-ui/src/script/cvars.rs#L1010))
- 1.12 has no such CVar; it exists because our Graphics page needs somewhere to keep the stop, and takes the API's name. ([`src/script/cvars.rs:1118`](../crates/benilla-ui/src/script/cvars.rs#L1118))
- The getter reads `CVAR_WORLD_DETAIL`, where the reference's reads only `smallCull` (`0x488d77`), because benilla's stop follows the knob that draws: a console `frillDensity` write moves the ground clutter and `WorldDetail` with it, and no renderer reads `smallCull` (its callback's `[0x868620]` has no reader). ([`src/script/cvars.rs:1146`](../crates/benilla-ui/src/script/cvars.rs#L1146))
- The minutes come from the server's table, not from spell 15007's `Spell.dbc` duration, because the aura the server applies is what the dialog must warn about. ([`src/script/death.rs:45`](../crates/benilla-ui/src/script/death.rs#L45))
- The promotion's IME legs (`0x77d417`–`0x77d431`) and the IME writer's `or 6` (`0x77acde`, in `0x77ac60`) are not modelled: benilla has no IME composition. ([`src/script/editbox/flush.rs:28`](../crates/benilla-ui/src/script/editbox/flush.rs#L28))
- The nameplate glow is shown but never drawn, because its additive rim reads as hard edge lines in our linear-blending pipeline; the lit plate brightens its bar instead. ([`src/script/extract.rs:223`](../crates/benilla-ui/src/script/extract.rs#L223))
- A host of 0x80 bytes or more is refused. The reference copies the host into a 0x80-byte buffer (`0x5abc7c`-`0x5abc9c`) and writes its terminator one byte past the end, and the cut host could end in a whitelisted suffix the real one does not; this takes the safe side. ([`src/script/glue_core.rs:424`](../crates/benilla-ui/src/script/glue_core.rs#L424))
@@ -820,7 +821,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
- A format that ends in `%` reads past its terminator in the client (`0x4135c3`), into whatever memory follows the string; here the output ends there. ([`src/script/stdlib.rs:637`](../crates/benilla-ui/src/script/stdlib.rs#L637))
- With `#` and one byte of room, `_store_number` writes no digit and its reversal swaps before it tests (`0x413ab3`), trading the last byte written for the stale byte after it in the caller's buffer, which then ends the client's answer; here the output is kept. ([`src/script/stdlib.rs:688`](../crates/benilla-ui/src/script/stdlib.rs#L688))
- The reference reads uninitialised fields before the seed; we answer the first legal design because that value is undefined. ([`src/script/tabard.rs:122`](../crates/benilla-ui/src/script/tabard.rs#L122))
- Returns nothing. The handler ends `mov eax,1` with nothing pushed (`0x4dcd7c`), so Lua 5.0 hands back the stack top, the node argument: an accident of the handler, not an API, and copying a stack-top leak would copy a bug. ([`src/script/taxi.rs:238`](../crates/benilla-ui/src/script/taxi.rs#L238))
- Returns nothing. The handler ends `mov eax,1` with nothing pushed (`0x4dcd7c`), so Lua 5.0 hands back the stack top, the node argument: an accident of the handler, not an API, and copying a stack-top leak would copy a bug. ([`src/script/taxi.rs:235`](../crates/benilla-ui/src/script/taxi.rs#L235))
- `0x530a52` lays it out at once; getters resolve first, so only OnSizeChanged fires later. ([`src/script/tooltip/size.rs:180`](../crates/benilla-ui/src/script/tooltip/size.rs#L180))
- The reference anchors a Font object through its +0x24 with no type test (`0x5313c9`), undefined; benilla raises the owner line. ([`src/script/tooltip/verbs.rs:51`](../crates/benilla-ui/src/script/tooltip/verbs.rs#L51))
- No time line follows, where the reference's rides the record's `+0xc` (`0x532bdf`), a byte an empty record keeps from its history. 0 after `ClearBuffRecord 0x4e4490` prints a lone "0 seconds remaining" (`0x4e447e`); else it is whatever the last occupant left, as `ResetBuffCache 0x4e40c0` and the compaction's tail reset (`0x4e4237`) call `0x4e44b0` with slot -1, which writes `+0x0` and `+0x4` alone (`0x4e44bc`-`0x4e44c0`). ([`src/script/tooltip_aura.rs:238`](../crates/benilla-ui/src/script/tooltip_aura.rs#L238))