diff --git a/content/docs/launch-options.md b/content/docs/launch-options.md index 56295fa80..196d5af54 100644 --- a/content/docs/launch-options.md +++ b/content/docs/launch-options.md @@ -298,6 +298,7 @@ To turn it off, quit the launcher and start it again without the variable. | `OPENAC_DUMP_APPEARANCE` | `openac` (every form) | off | `1` prints every appearance change (`0xF625`): a header with the object, base palette and counts, then one line per palette swap (`SP`), texture change (`TC`) and part change (`APC`); a body that does not parse prints `PARSE FAILED`. | | `OPENAC_MOTION_LOG` | `openac` (every form) | off | `1` traces the motions of the player and the selected object, three kinds of line, in order. `[motion] recv seq= ctl= auto= type=` and the state, for every motion message from the server (`auto=1` is the echo of the character's own movement, `type` other than 0 a move-to or turn-to). `[motion] applied serial= session-body\|server-only` and the state, for every server state taken up (the session's body, or the server's state for an object nothing here moves; an echo is not taken up), preceded by `[motion] interrupted serial=` and the state the body's movement under way was left in when the server state interrupted it (a move-to's turn stopped; the window follows it first, as `followed between`). `[motion] window took up\|followed serial=` and the state, then `playing=[...]` (the motions waiting on their animations, oldest first: a swing shows as its command, `0x1000005B` for SlashHigh) and `cycle=` (the looping motion under them), for every state the window takes up in order or follows from the latest view (only with a window open); `playing` is the motions' completion queue, not what is drawn. What is drawn is `[motion] window draws from frame F to L; left at frame F of L`, one line each time the drawn animation (its dat id) changes, so an action left before its last frame was cut short, and one without the `left` part when the object is first watched; `[motion] window hit the ground\|left the ground\|went hidden\|came back: link animations dropped` (an action under way is dropped with them, as the game does), and `built from its view` / `dropped` when the window's copy of the object is made again. Every line carries `t=.` (the wall clock, the same on the session's and the window's lines). A state reads `style= fwd=@ side= turn=` and `actions=[#@]` (`*` marks an autonomous action). A swing lost between server and screen shows as a `recv` without its `applied`, or an `applied` without its `window took up`. | | `[combat-mode]` lines in the client log | `openac` (every form) | always | Not an option: written only when a combat-mode change has waited on the character's body for 5 s or more (a change is held back until the body is ready for the mode it is leaving). `[combat-mode] t=. change to parked s: mode= style= fwd= waiting=[] blocked by: ` at 5 s and every 30 s after while it still waits, the reasons being the ready check's conditions that fail (`not in a missile stance`, `not standing at the ready`, `no combat table`, `motions still waiting`; `no body` when there is none); then one `change to went out after s`, or `given up after s` when another request replaced it. With the first such line of a wait come `[combat-mode-history]` lines: a header with the same `t=` and the session clock `s=`, then the last 32 combat-mode events, oldest first, each `s= `: a request sent, already in that mode, held back until the body is ready, or refused; a held-back request sent; a weapon swap made in combat asking for its mode again; the server's combat-mode update with its sequence, `taken` or `refused as older`; the client's mode now; the body's stance now (a full motion command). It lands in the session folder's `client.log`. A change that goes out within 5 s writes nothing. | +| `-- vital:`, `-- quality:`, `-- login complete` and `-- still dead` lines in the client log | `openac` (every form) | always | Not an option: what the session did with the character's own vitals and portal space, so a character left at 0 health after a death explains itself. A session that does not die writes none of the vital lines. `vital: (id ) seq : refused, ; now ` for every vital update of the character's own the client refused, why being `sequence vs held ` (older than the one last taken; ACE restores the vitals after a death with two updates each and the older arrives second, so one such refusal per vital there is normal), `not in items` (the character has no item record) or `no player guid` (no character yet); `now` is the value the client holds afterwards (`unknown` before the full record). The same line ending `: taken; ...` for every taken vital update while a death is watched: from the update that brings the health to 0 to the one that brings it back (both included), or until a `still dead` line was written for that death. `quality: own property seq : refused, ` for any other update of the character's own the client refused, at most once per property every 10 s (`( more refused since the last line)` when some were held back). `login complete sent: teleport arrived at 0x` when a teleport's arrival sends login complete, or `login complete: teleport arrived at 0x before the login's own went; ...` when it releases the one held for the login, then `login complete sent: the login's own, released by teleport at 0x` when that one goes. On the session clock, once per death and only while the health is still 0: `still dead 30 s after the death teleport to 0x (last health update: s=, , taken\|refused, )` 30 s after the first arrival since the death (a later arrival does not move that time; the line names the latest teleport), or `still dead 60 s after dying with no teleport arrival (last health update: ...)` 60 s after the death when no arrival came; `none` when no health update came. They go to the console and to the session folder's `client.log` with or without `--console`. | | `OPENAC_PROBE_EXTERNAL_CONTAINER` | `openac` (every form) | off | `1` prints one `[external-container] t=. (requested 0x..., open 0x...)` line when the outside container (a corpse, a chest) is asked for, opens, has its open refused by a use-done error, is closed by the server (`, not the open one` when it names another), stops being viewed, leaves the world while open, or is found open with no object in the world (`open 0x... left the world, closed`), and for each plugin close of a container with its answer and why (`plugin close 0x...: InvalidTarget, object not in the world`). Nothing is built while it is off. | | `OPENAC_POSITION_LOG` | `openac` (every form) | off | `1` traces where the objects near the character are (any object but the character itself and a projectile in flight, not only creatures), three kinds of line, each `[position] t=. s=`. `update "" seq=/// ground=yes\|no server= (x, y, z) body= (x, y, z) -> (x, y, z) gap= -> m player= m` for every server position of such an object within 30 m of the character: how it was handled (`glide`, the body catching up; `jump (more than 4 m\|first update\|body off the ground)`, put there at once; `placed (teleport\|far\|beyond 96 m)`; `ignored, no ground flag, cell written over \|cell unchanged`; `rejected (sequence\|bad position\|not authoritative\|no position yet)`, not applied; `no body (...)`), the server's place, the simulated body's place before and after (cell and landblock-local metres), and the body's distance from the server's place before and after. `apart "" gap= m server= body= since update= s since moved= s player= m` every 2 s for each such object within 30 m whose body stands more than 4 m from the server's last place for it. `order target= "" via=body\|stand-in\|order place ()\|order heading () steer= (x, y, z)` and the order's fields (`distance`, `min`, `fail`, `speed`, `walk_run`, `run_rate`; `speed`, `heading` for a turn) for every movement the server orders for the character; `via=body` adds `target gap=`, the target's body's distance from the server's place for it. | | `OPENAC_PROBE_OBJECTS` | `openac` (every form) | off | `1` prints one `[objects] t=. "" inst= at , player at m apart` line for each object standing in the world (not in a container, not held, not a projectile in flight, not the character) that is `created`, `created again` (a newer incarnation), `resent` (the incarnation held), given a `stale create ignored`, `described again`, `deleted by the server`, given a `delete for another incarnation ignored`, or `forgotten by the client` (25 s out of range); a delete for an object the client does not hold says `delete held for a create ... at nowhere`, whatever the object is (it may be an item in a pack), and `world emptied with objects` marks the session's world cleared. An object that leaves or enters the world without a create or delete (picked up, put down) has no line. The distance is along the ground across landblocks; `player at unknown` before the character is placed. To find which side lost an object: the client never told of it (no `created` after the player came back), or the client dropped it. Nothing is built while it is off. | diff --git a/crates/ac-core/src/items/quality_stamps.rs b/crates/ac-core/src/items/quality_stamps.rs index f462801cf..a8992083c 100644 --- a/crates/ac-core/src/items/quality_stamps.rs +++ b/crates/ac-core/src/items/quality_stamps.rs @@ -118,6 +118,13 @@ impl QualityStamps { pub fn rejected(&self) -> u64 { self.rejected } + + /// The sequence last taken for `property` of `kind`, if any was (a + /// refusal names it beside the sequence it refused). + #[must_use] + pub fn held(&self, kind: QualityKind, property: u32) -> Option { + self.held.get(&(property | kind.tag())).copied() + } } #[cfg(test)] @@ -173,4 +180,15 @@ mod tests { assert!(stamps.update(QualityKind::Bool, 1, 51)); assert!(!stamps.update(QualityKind::Bool, 1, 50)); } + + #[test] + fn the_held_sequence_is_the_last_one_taken_for_its_kind_and_property() { + let mut stamps = QualityStamps::new(); + assert_eq!(stamps.held(QualityKind::Vital, 2), None); + stamps.update(QualityKind::Vital, 2, 18); + stamps.update(QualityKind::Vital, 2, 17); + assert_eq!(stamps.held(QualityKind::Vital, 2), Some(18)); + // Another kind with the same id has its own. + assert_eq!(stamps.held(QualityKind::Int, 2), None); + } } diff --git a/crates/ac-runtime/src/session/mod.rs b/crates/ac-runtime/src/session/mod.rs index bbf7bc43f..e34443b34 100644 --- a/crates/ac-runtime/src/session/mod.rs +++ b/crates/ac-runtime/src/session/mod.rs @@ -37,6 +37,8 @@ mod runner; pub mod selection; #[cfg(feature = "host")] mod state; +#[cfg(feature = "host")] +mod vital_watch; pub mod world_tap; pub use chargen_table::project_chargen; diff --git a/crates/ac-runtime/src/session/runner.rs b/crates/ac-runtime/src/session/runner.rs index 80400415b..a5eec415a 100644 --- a/crates/ac-runtime/src/session/runner.rs +++ b/crates/ac-runtime/src/session/runner.rs @@ -239,6 +239,11 @@ pub enum HostEvent { /// through: the positions sent and received for the player just /// before. PlayerNotFound(Box), + /// A line for the client log about what the session did with the + /// player's own vitals and portal space (a vital update taken or + /// refused, login complete going out after a teleport, a character + /// still at 0 health after dying). Nothing a player sees. + Diagnostic(String), /// The session ended; nothing follows. Ended(SessionSummary), } @@ -1579,7 +1584,7 @@ impl Drive<'_> { !self.state.movement.has_content() || self.state.movement.controller().is_some(); if self.state.take_login_release() { if window || entered { - self.flow.send_held_login_complete(); + self.state.send_held_login_complete(&mut self.flow); } // Released to the no-window path before the character entered: // it goes when the entry is done (below, in a later pass). @@ -1600,7 +1605,7 @@ impl Drive<'_> { _ => false, }; if !held && (window || entered) { - self.flow.send_held_login_complete(); + self.state.send_held_login_complete(&mut self.flow); } } diff --git a/crates/ac-runtime/src/session/state.rs b/crates/ac-runtime/src/session/state.rs index 5a5d4906d..c5abd1bf2 100644 --- a/crates/ac-runtime/src/session/state.rs +++ b/crates/ac-runtime/src/session/state.rs @@ -183,6 +183,12 @@ pub struct SessionState { self_cast_watch: SelfCastWatch, /// When positions the server does not answer report the trail. answer_watch: AnswerWatch, + /// What the client log hears of the player's vital updates and death + /// teleports. + vital_watch: super::vital_watch::VitalWatch, + /// The teleport (its sequence and destination cell) whose arrival + /// released the login complete held for the login, until that one goes. + login_release_teleport: Option<(u16, u32)>, } impl SessionState { @@ -230,6 +236,8 @@ impl SessionState { position_trail: PositionTrail::default(), self_cast_watch: SelfCastWatch::default(), answer_watch: AnswerWatch::default(), + vital_watch: super::vital_watch::VitalWatch::default(), + login_release_teleport: None, } } @@ -280,6 +288,7 @@ impl SessionState { .then(|| self.player_stamps()) .flatten(); self.world.apply(message); + self.follow_quality_notes(); self.note_received_position(message, player_stamps); self.follow_transit(message); self.movement @@ -426,6 +435,32 @@ impl SessionState { } } + /// What the world did with the player's own vital updates (and refused + /// updates) of the message just applied goes to the client log. + fn follow_quality_notes(&mut self) { + for note in self.world.take_quality_notes() { + let vital_now = ac_core::player::vital_id_to_kind(note.property) + .filter(|_| note.kind == ac_core::items::QualityKind::Vital) + .and_then(|kind| self.own_vital(kind)); + let health_now = self.own_vital(ac_core::player::VitalKind::Health); + if let Some(line) = + self.vital_watch + .note(¬e, vital_now, health_now, self.session_now) + { + self.host_events.push(HostEvent::Diagnostic(line)); + } + } + } + + /// The current value of the player's own `kind` as the client holds + /// it (`None` before its full record). + fn own_vital(&self, kind: ac_core::player::VitalKind) -> Option { + self.world + .player() + .and_then(|player| player.numbers().get(kind)) + .map(|vital| vital.current) + } + /// The local player's counters as the world has them now. fn player_stamps(&self) -> Option { let player = self.world.player_guid()?; @@ -719,11 +754,28 @@ impl SessionState { if std::mem::take(&mut self.login_release_on_arrival) { // The login complete a window held at login goes out now. self.login_release = true; + self.login_release_teleport = Some((teleport_sequence, destination_cell)); + self.host_events.push(HostEvent::Diagnostic(format!( + "login complete: teleport {teleport_sequence} arrived at \ + 0x{destination_cell:08X} before the login's own went; that one is \ + released and ends the teleport" + ))); } else { // Login complete carries sequence 0 and does not use the // counter. outbox.send(build_login_complete(), Queue::Ui); + self.host_events.push(HostEvent::Diagnostic(format!( + "login complete sent: teleport {teleport_sequence} arrived at \ + 0x{destination_cell:08X}" + ))); } + let health = self.own_vital(ac_core::player::VitalKind::Health); + self.vital_watch.arrived( + self.session_now, + teleport_sequence, + destination_cell, + health, + ); self.portal_events.push(PortalSpaceEvent::Arrived { teleport_sequence, destination_cell, @@ -901,6 +953,23 @@ impl SessionState { pub fn login_complete_not_held(&mut self) { self.login_release = false; self.login_release_on_arrival = false; + self.login_release_teleport = None; + } + + /// The login complete `flow` holds goes out (nothing when it holds + /// none), and the client log hears it when a teleport's arrival + /// released it. + pub(crate) fn send_held_login_complete(&mut self, flow: &mut super::SessionFlow) { + if !flow.login_complete_held() { + return; + } + flow.send_held_login_complete(); + if let Some((teleport, cell)) = self.login_release_teleport.take() { + self.host_events.push(HostEvent::Diagnostic(format!( + "login complete sent: the login's own, released by teleport {teleport} \ + at 0x{cell:08X}" + ))); + } } /// The attached window showed the login destination (its presentation @@ -1066,6 +1135,8 @@ impl SessionState { self.login_entry = LoginEntry::Idle; self.login_release = false; self.login_release_on_arrival = false; + self.login_release_teleport = None; + self.vital_watch = super::vital_watch::VitalWatch::default(); self.portal_events.clear(); self.last_tick = None; self.forward(); @@ -1338,6 +1409,10 @@ impl SessionState { self.gameplay.follow_selected_object(selected, &mut ctx); self.gameplay.tick(&mut ctx); self.follow_combat(outbox, in_world, clocks); + let health = self.own_vital(ac_core::player::VitalKind::Health); + if let Some(line) = self.vital_watch.tick(clocks.session, health) { + self.host_events.push(HostEvent::Diagnostic(line)); + } self.forward(); } @@ -4073,6 +4148,213 @@ mod tests { assert!(!state.take_login_release()); } + /// The client log's lines (diagnostics) the session queued, oldest + /// first. + fn diagnostics(state: &mut SessionState) -> Vec { + state + .drain_host_events() + .into_iter() + .filter_map(|event| match event { + HostEvent::Diagnostic(line) => Some(line), + _ => None, + }) + .collect() + } + + /// The player's numbers, with `health` as the current health. + fn describe_health(state: &mut SessionState, health: u32) { + let mut description = crate::world::tests::empty_description(); + description.attributes.push(ac_proto::AttributeEntry { + id: 7, + ranks: 10, + start: 190, + xp: 0, + current: Some(health), + }); + state.world.apply_player_description(&description); + } + + fn health_current(sequence: u8, current: u32) -> Inbound<'static> { + Inbound::PrivateUpdateVitalCurrent(ac_proto::PrivateUpdateVitalCurrent { + sequence, + vital: 2, + current, + }) + } + + fn at_session(seconds: u64) -> Clocks { + Clocks { + session: Duration::from_secs(seconds), + ..CLOCKS + } + } + + #[test] + fn the_players_vital_updates_reach_the_client_log_while_dead_or_refused() { + let (mut state, mut outbox) = in_portal_space(false, 1); + describe_health(&mut state, 147); + state.drain_host_events(); + // Alive: a taken update is no line. + state.apply(&health_current(9, 120), &mut outbox, true, CLOCKS); + assert!(diagnostics(&mut state).is_empty()); + state.apply(&health_current(10, 0), &mut outbox, true, CLOCKS); + state.apply(&health_current(18, 147), &mut outbox, true, CLOCKS); + state.apply(&health_current(17, 140), &mut outbox, true, CLOCKS); + state.apply(&health_current(19, 150), &mut outbox, true, CLOCKS); + assert_eq!( + diagnostics(&mut state), + [ + "vital: health 0 (id 2) seq 10: taken; health now 0", + "vital: health 147 (id 2) seq 18: taken; health now 147", + "vital: health 140 (id 2) seq 17: refused, sequence 17 vs held 18; \ + health now 147", + ] + ); + } + + #[test] + fn a_death_with_no_arrival_warns_once_on_the_session_clock() { + let (mut state, mut outbox) = in_portal_space(false, 1); + describe_health(&mut state, 147); + state.apply(&health_current(10, 0), &mut outbox, true, at_session(20)); + state.drain_host_events(); + state.tick(&mut outbox, true, at_session(79)); + assert!(diagnostics(&mut state).is_empty(), "not yet 60 s"); + state.tick(&mut outbox, true, at_session(80)); + assert_eq!( + diagnostics(&mut state), + ["still dead 60 s after dying with no teleport arrival \ + (last health update: s=20.000, 0, taken)"] + ); + state.tick(&mut outbox, true, at_session(200)); + assert!(diagnostics(&mut state).is_empty(), "once"); + } + + #[test] + fn a_vital_update_for_a_player_without_an_item_record_is_logged_as_not_in_items() { + let (mut state, mut outbox) = state(); + state.world.set_player(TRAVELLER); + state.apply(&health_current(5, 147), &mut outbox, true, CLOCKS); + assert_eq!( + diagnostics(&mut state), + ["vital: health 147 (id 2) seq 5: refused, not in items; health now unknown"] + ); + } + + #[test] + fn a_death_teleport_left_at_zero_health_warns_once_on_the_session_clock() { + let (mut state, mut outbox) = in_portal_space(false, 1); + describe_health(&mut state, 147); + state.apply(&health_current(10, 0), &mut outbox, true, at_session(20)); + arrive_at(&mut state, &mut outbox, 1, DESTINATION); + assert!( + diagnostics(&mut state) + .contains(&"login complete sent: teleport 1 arrived at 0x7D640020".to_owned()) + ); + // The arrival came at 30 s on the session clock. + state.tick(&mut outbox, true, at_session(59)); + assert!(diagnostics(&mut state).is_empty(), "not yet 30 s"); + state.tick(&mut outbox, true, at_session(60)); + assert_eq!( + diagnostics(&mut state), + ["still dead 30 s after the death teleport 1 to 0x7D640020 \ + (last health update: s=20.000, 0, taken)"] + ); + state.tick(&mut outbox, true, at_session(120)); + assert!(diagnostics(&mut state).is_empty(), "once"); + } + + #[test] + fn a_death_teleport_whose_health_came_back_says_nothing() { + let (mut state, mut outbox) = in_portal_space(false, 1); + describe_health(&mut state, 147); + state.apply(&health_current(10, 0), &mut outbox, true, at_session(20)); + arrive_at(&mut state, &mut outbox, 1, DESTINATION); + state.apply(&health_current(11, 110), &mut outbox, true, at_session(33)); + state.drain_host_events(); + state.tick(&mut outbox, true, at_session(60)); + assert!(diagnostics(&mut state).is_empty()); + } + + #[test] + fn a_login_complete_a_teleport_released_is_logged_when_it_goes() { + let (mut state, mut outbox) = entering(false); + let at = crate::world::tests::position(LOGIN_CELL, 1.0); + state.apply( + &crate::world::tests::create(ENTERING, crate::world::tests::stamps(1, 1), Some(at)), + &mut outbox, + true, + CLOCKS, + ); + let start = Inbound::PlayerTeleport(ac_proto::PlayerTeleport { + teleport_sequence: 1, + }); + state.apply(&start, &mut outbox, true, CLOCKS); + state.apply( + &teleported(ENTERING, 1, DESTINATION), + &mut outbox, + true, + CLOCKS, + ); + assert_eq!( + diagnostics(&mut state), + [ + "login complete: teleport 1 arrived at 0x7D640020 before the login's own \ + went; that one is released and ends the teleport" + ] + ); + // The flow holds the login's login complete (no window: until the + // entry is done); the runner sends it through the state. + let mut flow = held_login_flow(); + state.send_held_login_complete(&mut flow); + let sent: Vec> = flow.drain_outgoing().map(|o| o.body).collect(); + assert_eq!(sent.first(), Some(&build_login_complete())); + assert_eq!( + diagnostics(&mut state), + ["login complete sent: the login's own, released by teleport 1 at 0x7D640020"] + ); + state.send_held_login_complete(&mut flow); + assert_eq!(flow.drain_outgoing().count(), 0, "sent once"); + assert!(diagnostics(&mut state).is_empty(), "logged once"); + } + + /// A flow in the world whose login complete waits for the character's + /// entry (no window, a world to simulate). + fn held_login_flow() -> super::super::SessionFlow { + let words = + |words: &[u32]| -> Vec { words.iter().flat_map(|w| w.to_le_bytes()).collect() }; + let mut list = ac_bits::Writer::new(); + list.u32(0xF658); + list.u32(0); + list.u32(1); + list.u32(ENTERING); + list.string16l("+Entering").unwrap(); + list.u32(0); + list.u32(0); + list.i32(11); + list.string16l("TestAccount").unwrap(); + list.u32(1); + list.u32(1); + let mut flow = super::super::SessionFlow::new(Duration::ZERO); + flow.handle_message(Duration::ZERO, &words(&[0xF7E5])); + flow.handle_message(Duration::ZERO, &list.into_vec()); + flow.handle_message(Duration::ZERO, &words(&[0xF7EA])); + flow.enter_world( + Duration::ZERO, + &super::super::CharacterSelector::FirstAvailable, + ) + .unwrap(); + flow.handle_message(Duration::ZERO, &words(&[0xF7DF])); + flow.set_login_awaits_entry(true); + flow.handle_message( + Duration::ZERO, + &words(&[0xF745, ENTERING, 0x11, 0, 0, 0, 0, 0, 0, 0]), + ); + flow.drain_outgoing().for_each(drop); + assert!(flow.login_complete_held()); + flow + } + /// A window that does not draw the world (no dats) does not hold the /// login: OpenAC sends login complete at the first entry when there is /// no world to show. diff --git a/crates/ac-runtime/src/session/vital_watch.rs b/crates/ac-runtime/src/session/vital_watch.rs new file mode 100644 index 000000000..3ded74add --- /dev/null +++ b/crates/ac-runtime/src/session/vital_watch.rs @@ -0,0 +1,540 @@ +//! What the client log needs to explain a character left at 0 health after +//! a death. +//! +//! On a death the server sets the character's health to 0, sends it to its +//! lifestone, and a few seconds into that teleport sends health, stamina +//! and mana back at 75% (ACE's `Player_Death.cs`). Login complete at the +//! arrival ends the server's portal space; until then it moves the +//! character nowhere (ACE's `Player_Location.cs`). A character still at 0 +//! health long after dying either had its restore refused here, never +//! arrived here (so never sent login complete), or never had its portal +//! space ended there. +//! +//! So, cheaply enough for a bot that farms for days: every refused vital +//! update of the player's own is logged, other refused updates of its own +//! at most once per property every [`REFUSAL_LOG_INTERVAL`], and taken +//! vital updates only while a death is being watched (from the health +//! seen at 0 until it comes back, or until a warning below was written). +//! An arrival after the death that leaves the health at 0 for +//! [`STILL_DEAD_AFTER_ARRIVAL`] says so once; a death with no arrival at +//! all for [`STILL_DEAD_WITHOUT_ARRIVAL`] says so once too. + +use std::collections::HashMap; +use std::time::Duration; + +use ac_core::items::QualityKind; +use ac_core::player::{VitalKind, vital_id_to_kind}; + +use crate::world::{QualityNote, QualityOutcome}; + +/// How long after an arrival that followed a death the health may stay 0 +/// before the log says so. +pub const STILL_DEAD_AFTER_ARRIVAL: Duration = Duration::from_secs(30); + +/// How long the health may stay 0 with no arrival since the death before +/// the log says so. +pub const STILL_DEAD_WITHOUT_ARRIVAL: Duration = Duration::from_secs(60); + +/// The shortest time between two lines about refused updates of the same +/// property other than a vital (a refused vital is always logged). +pub const REFUSAL_LOG_INTERVAL: Duration = Duration::from_secs(10); + +/// The last health update of the player's own, as a warning names it. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct HealthUpdate { + at: Duration, + value: Option, + sequence: u8, + outcome: QualityOutcome, +} + +/// One property's refusal lines. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct RefusalLog { + /// When its last line was written. + logged_at: Duration, + /// Refusals since that were not written. + held_back: u32, +} + +/// The arrival warning waiting for its time: the first arrival after the +/// death sets when, the latest names the teleport. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct PendingArrival { + due: Duration, + teleport_sequence: u16, + destination_cell: u32, +} + +/// A death being watched: from the health seen at 0 until it comes back. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct Death { + /// When the health was seen at 0. + since: Duration, + /// An arrival came since. + arrived: bool, + pending: Option, + /// The arrival warning was written. + arrival_warned: bool, + /// The no-arrival warning was written. + stray_warned: bool, +} + +impl Death { + fn new(since: Duration) -> Self { + Self { + since, + arrived: false, + pending: None, + arrival_warned: false, + stray_warned: false, + } + } +} + +/// The session's watch over the player's vital updates and its deaths. +#[derive(Debug, Default)] +pub(crate) struct VitalWatch { + last_health: Option, + refusals: HashMap<(QualityKind, u32), RefusalLog>, + death: Option, +} + +impl VitalWatch { + /// Whether taken vital updates are logged now: a death is watched and + /// no warning about it was written yet. + fn logs_taken(&self) -> bool { + self.death + .is_some_and(|death| !death.arrival_warned && !death.stray_warned) + } + + /// The world noted `note` at `at`; `vital_now` is the current value the + /// client holds now for the note's vital and `health_now` the health's + /// (`None` before the full record). The line to log, if any. + pub(crate) fn note( + &mut self, + note: &QualityNote, + vital_now: Option, + health_now: Option, + at: Duration, + ) -> Option { + // The update that opens the watch and the one that closes it are + // both logged. + let logged_before = self.logs_taken(); + let kind = (note.kind == QualityKind::Vital) + .then(|| vital_id_to_kind(note.property)) + .flatten(); + if kind == Some(VitalKind::Health) { + self.last_health = Some(HealthUpdate { + at, + value: note.value, + sequence: note.sequence, + outcome: note.outcome, + }); + } + match health_now { + Some(0) => { + self.death.get_or_insert(Death::new(at)); + } + // The health came back: the death and its warnings are over. + Some(_) => self.death = None, + None => {} + } + if note.kind != QualityKind::Vital { + return self.refusal_line(note, at); + } + let logged = note.outcome != QualityOutcome::Taken || logged_before || self.logs_taken(); + logged.then(|| vital_line(note, kind, vital_now)) + } + + /// A refusal of a property other than a vital, unless one of the same + /// property was logged less than [`REFUSAL_LOG_INTERVAL`] ago. + fn refusal_line(&mut self, note: &QualityNote, at: Duration) -> Option { + let why = refusal(note.outcome, note.sequence)?; + let key = (note.kind, note.property); + if let Some(log) = self.refusals.get_mut(&key) + && at.saturating_sub(log.logged_at) < REFUSAL_LOG_INTERVAL + { + log.held_back += 1; + return None; + } + let held_back = self + .refusals + .insert( + key, + RefusalLog { + logged_at: at, + held_back: 0, + }, + ) + .map_or(0, |log| log.held_back); + let more = if held_back == 0 { + String::new() + } else { + format!(" ({held_back} more refused since the last line)") + }; + Some(format!( + "quality: own {:?} property {} seq {}: refused, {why}{more}", + note.kind, note.property, note.sequence + )) + } + + /// A portal arrival completed at `at`. During a watched death (or with + /// the health 0 now) the first arrival starts the + /// [`STILL_DEAD_AFTER_ARRIVAL`] wait; a later one keeps that time and + /// only changes which teleport the warning names. + pub(crate) fn arrived( + &mut self, + at: Duration, + teleport_sequence: u16, + destination_cell: u32, + health_now: Option, + ) { + if health_now == Some(0) { + self.death.get_or_insert(Death::new(at)); + } + let Some(death) = self.death.as_mut() else { + return; + }; + death.arrived = true; + if death.arrival_warned { + return; + } + let due = death + .pending + .map_or(at + STILL_DEAD_AFTER_ARRIVAL, |pending| pending.due); + death.pending = Some(PendingArrival { + due, + teleport_sequence, + destination_cell, + }); + } + + /// Once a pass: a warning, once per death, when the health is still 0 + /// [`STILL_DEAD_AFTER_ARRIVAL`] after an arrival, or + /// [`STILL_DEAD_WITHOUT_ARRIVAL`] after dying with no arrival since. + pub(crate) fn tick(&mut self, at: Duration, health_now: Option) -> Option { + if health_now != Some(0) { + return None; + } + let death = self.death.as_mut()?; + if let Some(pending) = death.pending + && at >= pending.due + { + death.pending = None; + death.arrival_warned = true; + return Some(format!( + "still dead {} s after the death teleport {} to 0x{:08X} \ + (last health update: {})", + STILL_DEAD_AFTER_ARRIVAL.as_secs(), + pending.teleport_sequence, + pending.destination_cell, + self.last_health_text(), + )); + } + if !death.arrived && !death.stray_warned && at >= death.since + STILL_DEAD_WITHOUT_ARRIVAL { + death.stray_warned = true; + return Some(format!( + "still dead {} s after dying with no teleport arrival (last health update: {})", + STILL_DEAD_WITHOUT_ARRIVAL.as_secs(), + self.last_health_text(), + )); + } + None + } + + fn last_health_text(&self) -> String { + match self.last_health { + None => "none".to_owned(), + Some(update) => format!( + "s={:.3}, {}, {}", + update.at.as_secs_f64(), + value_text(update.value), + verdict(update.outcome, update.sequence) + ), + } + } +} + +/// Why an update with `sequence` was refused; `None` when it was taken. +fn refusal(outcome: QualityOutcome, sequence: u8) -> Option { + match outcome { + QualityOutcome::Taken => None, + QualityOutcome::NoPlayer => Some("no player guid".to_owned()), + QualityOutcome::NotInItems => Some("not in items".to_owned()), + QualityOutcome::Older { held } => Some(format!("sequence {sequence} vs held {held}")), + } +} + +/// `taken`, or `refused, ` and why. +fn verdict(outcome: QualityOutcome, sequence: u8) -> String { + refusal(outcome, sequence).map_or_else(|| "taken".to_owned(), |why| format!("refused, {why}")) +} + +fn value_text(value: Option) -> String { + value.map_or_else(|| "?".to_owned(), |value| value.to_string()) +} + +/// One vital update: the vital, its value, the sequence, what the world did +/// with it and the value the client holds now. +fn vital_line(note: &QualityNote, kind: Option, now: Option) -> String { + let name = match kind { + Some(VitalKind::Health) => "health", + Some(VitalKind::Stamina) => "stamina", + Some(VitalKind::Mana) => "mana", + None => "vital", + }; + let now = now.map_or_else(|| "unknown".to_owned(), |value| value.to_string()); + format!( + "vital: {name} {} (id {}) seq {}: {}; {name} now {now}", + value_text(note.value), + note.property, + note.sequence, + verdict(note.outcome, note.sequence) + ) +} + +#[cfg(test)] +mod tests { + //! The lines the watch writes, and when it stays quiet. + + use super::*; + + const HEALTH: u32 = 2; + + fn health(value: u32, sequence: u8, outcome: QualityOutcome) -> QualityNote { + QualityNote { + kind: QualityKind::Vital, + property: HEALTH, + sequence, + value: Some(value), + outcome, + } + } + + fn taken(value: u32, sequence: u8) -> QualityNote { + health(value, sequence, QualityOutcome::Taken) + } + + fn refused_int(property: u32, sequence: u8) -> QualityNote { + QualityNote { + kind: QualityKind::Int, + property, + sequence, + value: None, + outcome: QualityOutcome::Older { held: 40 }, + } + } + + fn secs(s: u64) -> Duration { + Duration::from_secs(s) + } + + /// The health is `value` after the note (the update was taken). + fn set(watch: &mut VitalWatch, value: u32, sequence: u8, at: u64) -> Option { + watch.note(&taken(value, sequence), Some(value), Some(value), secs(at)) + } + + #[test] + fn a_refused_vital_update_is_always_a_line_with_why() { + let mut watch = VitalWatch::default(); + let older = health(140, 17, QualityOutcome::Older { held: 18 }); + assert_eq!( + watch.note(&older, Some(147), Some(147), secs(1)).as_deref(), + Some( + "vital: health 140 (id 2) seq 17: refused, sequence 17 vs held 18; health now 147" + ) + ); + let missing = health(147, 3, QualityOutcome::NotInItems); + assert_eq!( + watch.note(&missing, None, None, secs(1)).as_deref(), + Some("vital: health 147 (id 2) seq 3: refused, not in items; health now unknown") + ); + let stamina = QualityNote { + property: 4, + ..health(90, 5, QualityOutcome::NoPlayer) + }; + assert_eq!( + watch.note(&stamina, None, None, secs(1)).as_deref(), + Some("vital: stamina 90 (id 4) seq 5: refused, no player guid; stamina now unknown") + ); + } + + #[test] + fn a_taken_vital_update_is_a_line_only_while_a_death_is_watched() { + let mut watch = VitalWatch::default(); + // Farming: regeneration and hits write nothing. + assert_eq!(set(&mut watch, 147, 18, 1), None); + assert_eq!(set(&mut watch, 120, 19, 2), None); + // The death opens the watch, with its own line. + assert_eq!( + set(&mut watch, 0, 20, 3).as_deref(), + Some("vital: health 0 (id 2) seq 20: taken; health now 0") + ); + let mana = QualityNote { + property: 6, + ..taken(0, 4) + }; + assert_eq!( + watch.note(&mana, Some(0), Some(0), secs(4)).as_deref(), + Some("vital: mana 0 (id 6) seq 4: taken; mana now 0") + ); + // The restore closes it, with its own line; after it, nothing. + assert_eq!( + set(&mut watch, 110, 21, 7).as_deref(), + Some("vital: health 110 (id 2) seq 21: taken; health now 110") + ); + assert_eq!(set(&mut watch, 115, 22, 8), None); + } + + #[test] + fn taken_vital_updates_stop_being_logged_once_a_warning_was_written() { + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + watch.arrived(secs(60), 3, 0x8164_0007, Some(0)); + assert!(watch.tick(secs(90), Some(0)).is_some()); + assert_eq!(set(&mut watch, 0, 11, 95), None); + // Refusals still are. + let older = health(0, 9, QualityOutcome::Older { held: 11 }); + assert!(watch.note(&older, Some(0), Some(0), secs(96)).is_some()); + } + + #[test] + fn a_refused_update_of_another_kind_is_logged_once_per_property_every_ten_seconds() { + let mut watch = VitalWatch::default(); + let first = watch.note(&refused_int(25, 9), None, None, secs(100)); + assert_eq!( + first.as_deref(), + Some("quality: own Int property 25 seq 9: refused, sequence 9 vs held 40") + ); + // The same property again within 10 s: held back; another + // property has its own limit. + assert_eq!(watch.note(&refused_int(25, 9), None, None, secs(105)), None); + assert_eq!(watch.note(&refused_int(25, 9), None, None, secs(109)), None); + assert!( + watch + .note(&refused_int(26, 9), None, None, secs(105)) + .is_some() + ); + assert_eq!( + watch + .note(&refused_int(25, 9), None, None, secs(110)) + .as_deref(), + Some( + "quality: own Int property 25 seq 9: refused, sequence 9 vs held 40 \ + (2 more refused since the last line)" + ) + ); + // A taken update of another kind is no line at all. + let taken = QualityNote { + outcome: QualityOutcome::Taken, + ..refused_int(25, 41) + }; + assert_eq!(watch.note(&taken, None, None, secs(130)), None); + } + + #[test] + fn an_arrival_after_a_death_still_at_zero_health_warns_once() { + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + watch.note( + &health(147, 11, QualityOutcome::Older { held: 12 }), + Some(0), + Some(0), + secs(53), + ); + watch.arrived(secs(60), 3, 0x8164_0007, Some(0)); + assert_eq!(watch.tick(secs(89), Some(0)), None, "not yet 30 s"); + assert_eq!( + watch.tick(secs(90), Some(0)).as_deref(), + Some( + "still dead 30 s after the death teleport 3 to 0x81640007 \ + (last health update: s=53.000, 147, refused, sequence 11 vs held 12)" + ) + ); + assert_eq!(watch.tick(secs(200), Some(0)), None, "once"); + watch.arrived(secs(210), 4, 0x8164_0007, Some(0)); + assert_eq!(watch.tick(secs(300), Some(0)), None, "once per death"); + } + + #[test] + fn later_arrivals_keep_the_first_arrivals_deadline() { + // A bot recalling every 15 s while dead still hears the warning, + // 30 s after its first arrival, naming the latest teleport. + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + watch.arrived(secs(60), 3, 0x8164_0007, Some(0)); + watch.arrived(secs(75), 4, 0x7D64_0020, Some(0)); + watch.arrived(secs(89), 5, 0x8164_0007, Some(0)); + assert_eq!( + watch.tick(secs(90), Some(0)).as_deref(), + Some( + "still dead 30 s after the death teleport 5 to 0x81640007 \ + (last health update: s=50.000, 0, taken)" + ) + ); + } + + #[test] + fn a_death_with_no_arrival_warns_once_after_sixty_seconds() { + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + assert_eq!(watch.tick(secs(109), Some(0)), None, "not yet 60 s"); + assert_eq!( + watch.tick(secs(110), Some(0)).as_deref(), + Some( + "still dead 60 s after dying with no teleport arrival \ + (last health update: s=50.000, 0, taken)" + ) + ); + assert_eq!(watch.tick(secs(200), Some(0)), None, "once"); + // An arrival has its own warning instead. + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + watch.arrived(secs(55), 3, 0x8164_0007, Some(0)); + assert!(watch.tick(secs(85), Some(0)).is_some(), "the arrival's"); + assert_eq!(watch.tick(secs(110), Some(0)), None, "not this one"); + } + + #[test] + fn no_warning_when_the_health_came_back_or_there_was_no_death() { + // Restored after the arrival. + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + watch.arrived(secs(60), 3, 0x8164_0007, Some(0)); + set(&mut watch, 147, 11, 63); + assert_eq!(watch.tick(secs(95), Some(147)), None); + // Restored before the arrival (in portal space, as the server + // sends it): the arrival waits for nothing. + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + set(&mut watch, 147, 11, 53); + watch.arrived(secs(60), 3, 0x8164_0007, Some(147)); + assert_eq!(watch.tick(secs(95), Some(147)), None); + assert_eq!(watch.tick(secs(200), Some(147)), None); + // An arrival with no death before it waits for nothing. + let mut watch = VitalWatch::default(); + watch.arrived(secs(60), 4, 0x7D64_0020, Some(147)); + assert_eq!(watch.tick(secs(95), Some(0)), None); + } + + #[test] + fn the_health_coming_back_ends_the_death_and_its_pending_warning() { + // Restored, then dead again: the first death's arrival warning is + // gone, and the new death waits its own 60 s from its own start. + let mut watch = VitalWatch::default(); + set(&mut watch, 0, 10, 50); + watch.arrived(secs(60), 3, 0x8164_0007, Some(0)); + set(&mut watch, 147, 11, 63); + set(&mut watch, 0, 12, 70); + assert_eq!(watch.tick(secs(90), Some(0)), None); + assert_eq!(watch.tick(secs(129), Some(0)), None); + assert_eq!( + watch.tick(secs(130), Some(0)).as_deref(), + Some( + "still dead 60 s after dying with no teleport arrival \ + (last health update: s=70.000, 0, taken)" + ) + ); + } +} diff --git a/crates/ac-runtime/src/world/mod.rs b/crates/ac-runtime/src/world/mod.rs index da289b991..e1435ff31 100644 --- a/crates/ac-runtime/src/world/mod.rs +++ b/crates/ac-runtime/src/world/mod.rs @@ -92,6 +92,43 @@ pub enum WorldChange { PlayerChanged, } +/// What the world did with a single-quality update of the player's own. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum QualityOutcome { + /// Taken: the value is the player's now. + Taken, + /// Refused: the world has no player yet to give it to. + NoPlayer, + /// Refused: the player has no item record. + NotInItems, + /// Refused: older than the sequence last taken for the property. + Older { + /// The sequence last taken. + held: u8, + }, +} + +/// A single-quality update of the player's own and what the world did with +/// it: every vital update, and every refusal of any other kind. The session +/// writes them to the client log (a character left at 0 health after a +/// death teleport shows whether the restore was refused). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct QualityNote { + /// The kind of quality. + pub kind: QualityKind, + /// The property (for a vital, its update id). + pub property: u32, + /// The update's sequence. + pub sequence: u8, + /// The value a vital update carried (its current value). + pub value: Option, + /// Taken, or why not. + pub outcome: QualityOutcome, +} + +/// How many quality notes are kept for a session that does not take them. +const QUALITY_NOTE_CAP: usize = 64; + /// The world as one session sees it. #[derive(Debug, Default)] pub struct World { @@ -133,6 +170,11 @@ pub struct World { /// not take (older than the one held, or for an object it has no record /// of). refused_update: bool, + /// The player's own single-quality update in the message being applied. + own_quality: Option, + /// The player's own vital updates and refused updates since the last + /// take, oldest first. + quality_notes: Vec, /// The object probe (`OPENAC_PROBE_OBJECTS=1`); off by default. object_probe: object_probe::ObjectProbe, /// The delete being applied is the client forgetting an object out of @@ -587,6 +629,30 @@ impl World { /// [`apply_appraisal`](Self::apply_appraisal). pub fn apply(&mut self, message: &Inbound<'_>) { self.refused_update = false; + self.own_quality = None; + self.apply_message(message); + if let Some(mut note) = self.own_quality.take() { + note.value = match message { + Inbound::PrivateUpdateVital(u) => Some(u.current), + Inbound::PrivateUpdateVitalCurrent(u) => Some(u.current), + _ => None, + }; + if note.kind == QualityKind::Vital || note.outcome != QualityOutcome::Taken { + if self.quality_notes.len() == QUALITY_NOTE_CAP { + self.quality_notes.remove(0); + } + self.quality_notes.push(note); + } + } + } + + /// The player's own vital updates and refused single-quality updates + /// since the last call, oldest first. + pub fn take_quality_notes(&mut self) -> Vec { + std::mem::take(&mut self.quality_notes) + } + + fn apply_message(&mut self, message: &Inbound<'_>) { // The private forms are about the player's own object. let player = self.player_guid.unwrap_or(0); match message { @@ -781,13 +847,37 @@ impl World { /// item record takes none; otherwise the first update of a property is /// taken, then only one not older than the last taken. fn take_quality(&mut self, guid: u32, kind: QualityKind, property: u32, sequence: u8) -> bool { - let taken = self.items.get(guid).is_some() - && self - .quality_stamps - .entry(guid) - .or_default() - .update(kind, property, sequence); + let outcome = if self.items.get(guid).is_none() { + QualityOutcome::NotInItems + } else { + let stamps = self.quality_stamps.entry(guid).or_default(); + let held = stamps.held(kind, property); + if stamps.update(kind, property, sequence) { + QualityOutcome::Taken + } else { + QualityOutcome::Older { + held: held.unwrap_or(sequence), + } + } + }; + let taken = outcome == QualityOutcome::Taken; self.refused_update = !taken; + // The player's own: its guid, or a private form (guid 0) before + // the world knows who the player is. + let outcome = match self.player_guid { + Some(player) if player == guid => Some(outcome), + None if guid == 0 => Some(QualityOutcome::NoPlayer), + _ => None, + }; + if let Some(outcome) = outcome { + self.own_quality = Some(QualityNote { + kind, + property, + sequence, + value: None, + outcome, + }); + } taken } diff --git a/crates/ac-runtime/src/world/tests.rs b/crates/ac-runtime/src/world/tests.rs index 0f75125b4..c70142a86 100644 --- a/crates/ac-runtime/src/world/tests.rs +++ b/crates/ac-runtime/src/world/tests.rs @@ -434,6 +434,79 @@ fn the_players_vitals_skip_a_late_update() { assert_eq!(current(&world), 60); } +#[test] +fn the_players_own_vital_updates_and_refusals_are_noted_with_why() { + // Every vital update of the player's own is noted, taken or not, with + // the value it carried; another kind only when refused; another + // object's never. What is taken does not change. + let vital_current = |sequence, current| { + Inbound::PrivateUpdateVitalCurrent(ac_proto::PrivateUpdateVitalCurrent { + sequence, + vital: 2, + current, + }) + }; + let own_int = |sequence| { + Inbound::PrivateUpdatePropertyInt(ac_proto::PrivateUpdatePropertyInt { + sequence, + property: 25, + value: 7, + }) + }; + let note = |sequence, value, outcome| QualityNote { + kind: QualityKind::Vital, + property: 2, + sequence, + value: Some(value), + outcome, + }; + let mut world = World::new(); + // No player yet: the private form names nobody. + world.apply(&vital_current(1, 10)); + assert!(world.refused_last_update()); + assert_eq!( + world.take_quality_notes(), + [note(1, 10, QualityOutcome::NoPlayer)] + ); + // The player is known but has no item record. + world.set_player(PLAYER); + world.apply(&vital_current(2, 20)); + assert_eq!( + world.take_quality_notes(), + [note(2, 20, QualityOutcome::NotInItems)] + ); + world.apply(&create( + PLAYER, + stamps(1, 1), + Some(position(0xA9B4_0031, 1.0)), + )); + world.apply(&vital_current(18, 147)); + world.apply(&vital_current(17, 140)); + assert!(world.refused_last_update()); + world.apply(&own_int(9)); + world.apply(&own_int(8)); + assert_eq!( + world.take_quality_notes(), + [ + note(18, 147, QualityOutcome::Taken), + note(17, 140, QualityOutcome::Older { held: 18 }), + QualityNote { + kind: QualityKind::Int, + property: 25, + sequence: 8, + value: None, + outcome: QualityOutcome::Older { held: 9 }, + }, + ] + ); + // Another object's refusal is not the player's. + world.apply(&named(DOOR, 1, "Door")); + world.apply(&int_update(5, 18, 1)); + world.apply(&int_update(4, 18, 1)); + assert!(world.refused_last_update()); + assert!(world.take_quality_notes().is_empty()); +} + #[test] fn a_new_incarnation_or_a_resent_description_starts_the_counters_afresh() { // The counters belong to the object's record: a newer incarnation, an diff --git a/crates/openac/src/console.rs b/crates/openac/src/console.rs index 07e3255d2..d18bdb802 100644 --- a/crates/openac/src/console.rs +++ b/crates/openac/src/console.rs @@ -1535,6 +1535,7 @@ pub fn event_lines(event: &HostEvent, session: Option<&str>) -> Vec { vec![notice(&crate::portal_failure::summary(failure), session)] } HostEvent::PlayerNotFound(lost) => player_not_found_lines(lost, session), + HostEvent::Diagnostic(text) => vec![notice(text, session)], _ => Vec::new(), } } diff --git a/crates/openac/src/multi.rs b/crates/openac/src/multi.rs index 102aa6956..eec9247c2 100644 --- a/crates/openac/src/multi.rs +++ b/crates/openac/src/multi.rs @@ -648,7 +648,8 @@ pub(crate) fn monitor( | HostEvent::Logout(_) | HostEvent::CharacterSelection(_) | HostEvent::CharacterCreation(_) - | HostEvent::PlayerNotFound(_)), + | HostEvent::PlayerNotFound(_) + | HostEvent::Diagnostic(_)), ) => { for line in console::event_lines(&event, tag) { printer.print_logged(kind, &line);