From fb74b6038f026f5b09ddf1a85b2c64fe636648f9 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 26 Oct 2026 11:38:17 +0100 Subject: [PATCH] Chat: system and player lines share the window's chat code Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/chat_tests.rs | 3 ++- crates/horizon-client/src/game/chat.rs | 31 ++++++++----------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/crates/horizon-client/src/chat_tests.rs b/crates/horizon-client/src/chat_tests.rs index fa065766c..071cd8839 100644 --- a/crates/horizon-client/src/chat_tests.rs +++ b/crates/horizon-client/src/chat_tests.rs @@ -439,7 +439,8 @@ fn the_chat_option_filters_the_lines_both_ways() { /// The in-frame LAN host's chat: a guest's line is a player message, so the /// Chat option's player-message permission hides it at Commands Only and -/// Hidden; command feedback (`/say`, `/me`) is a system message and stays. +/// Hidden; command feedback (`/list`, `/tp`) is a system message and stays +/// at Commands Only. #[test] fn a_guests_line_follows_the_player_message_permission() { let font = font(); diff --git a/crates/horizon-client/src/game/chat.rs b/crates/horizon-client/src/game/chat.rs index be2a318a0..de5bbf116 100644 --- a/crates/horizon-client/src/game/chat.rs +++ b/crates/horizon-client/src/game/chat.rs @@ -464,22 +464,7 @@ impl Game<'_> { return; } // The Chat option's Hidden level takes the server's messages too. - if !self.ui.chat.shows(ChatSource::Server) { - return; - } - let focused = self.screen == Screen::Chat; - let heard = self.mods.running().then(|| text.plain()); - self.ui.chat.add( - &self.gui.atlas, - text, - Some(SYSTEM_INDICATOR), - ChatSource::Server, - self.ticks, - focused, - ); - if let Some(line) = heard { - self.mods_chat(&line); - } + self.local_chat_line(text, Some(SYSTEM_INDICATOR), ChatSource::Server); } /// A player's chat line on the window's own chat: a LAN guest's message /// while the host runs in-frame (`HostEvent::Chat`). `ChatListener` @@ -493,10 +478,14 @@ impl Game<'_> { } // A server's client receives the line as a packet (PlayerChat or // DisguisedChat) and filters it there. - if self.remote.is_some() { - return; + if self.remote.is_none() { + self.local_chat_line(text, None, ChatSource::Player); } - if !self.ui.chat.shows(ChatSource::Player) { + } + /// A line on the window's own chat when the Chat option lets `source` + /// through; running mods hear it. + fn local_chat_line(&mut self, text: Text, indicator: Option, source: ChatSource) { + if !self.ui.chat.shows(source) { return; } let focused = self.screen == Screen::Chat; @@ -504,8 +493,8 @@ impl Game<'_> { self.ui.chat.add( &self.gui.atlas, text, - None, - ChatSource::Player, + indicator, + source, self.ticks, focused, );