srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/tui/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/tui/src')
-rw-r--r--crates/tui/src/main.rs1
-rw-r--r--crates/tui/src/multiplayer_net.rs9
2 files changed, 10 insertions, 0 deletions
diff --git a/crates/tui/src/main.rs b/crates/tui/src/main.rs
index f5c4a68..27ea983 100644
--- a/crates/tui/src/main.rs
+++ b/crates/tui/src/main.rs
@@ -104,6 +104,7 @@ fn merge_player_list(existing: &[MpPlayer], incoming: Vec<typerpunk_core::multip
fn apply_mp_event(app: &mut App, event: MpNetEvent) {
match event {
+ MpNetEvent::Ignored => {}
MpNetEvent::RoomCreated { code } => app.set_mp_room_created(code),
MpNetEvent::Joined { player_id } => app.set_mp_joined(player_id),
MpNetEvent::PlayerList(players) => {
diff --git a/crates/tui/src/multiplayer_net.rs b/crates/tui/src/multiplayer_net.rs
index 8c6c6b0..5d1b772 100644
--- a/crates/tui/src/multiplayer_net.rs
+++ b/crates/tui/src/multiplayer_net.rs
@@ -11,6 +11,10 @@ use typerpunk_core::multiplayer::{ClientMessage, PlayerInfo, ServerMessage};
#[derive(Debug, Clone)]
pub enum NetEvent {
+ /// A protocol message this client has no use for. Delivered rather than
+ /// dropped so the match on ServerMessage stays exhaustive and adding a
+ /// variant is a compile-time prompt rather than a silent parse failure.
+ Ignored,
RoomCreated { code: String },
Joined { player_id: String },
PlayerList(Vec<PlayerInfo>),
@@ -81,6 +85,11 @@ fn to_event(msg: ServerMessage) -> NetEvent {
match msg {
ServerMessage::Joined { player_id } => NetEvent::Joined { player_id },
ServerMessage::PlayerList { players } => NetEvent::PlayerList(players),
+ // The passage ahead of the countdown, so a client can show it while
+ // players wait. This one does not yet, and Start still carries the
+ // text, so it is accepted and ignored rather than dropped as an
+ // unparseable message.
+ ServerMessage::RaceText { .. } => NetEvent::Ignored,
ServerMessage::Countdown { seconds } => NetEvent::Countdown(seconds),
ServerMessage::Start { text } => NetEvent::Start(text),
ServerMessage::PlayerProgress { player_id, percent, wpm } => NetEvent::PlayerProgress { player_id, percent, wpm },