Chat: system and player lines share the window's chat code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-26 11:38:17 +01:00
parent 276f8d49c1
commit fb74b6038f
2 changed files with 12 additions and 22 deletions
+2 -1
View File
@@ -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();
+10 -21
View File
@@ -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<u32>, 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,
);