From 5a09b743c9170f6844894b4becafc7afa2fd6334 Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Sat, 20 Apr 2024 17:09:44 +0200 Subject: [PATCH] return AlreadyJoined when a player attempts to join a room they are already in --- crates/lavina-core/src/player.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/lavina-core/src/player.rs b/crates/lavina-core/src/player.rs index 0486808..8693752 100644 --- a/crates/lavina-core/src/player.rs +++ b/crates/lavina-core/src/player.rs @@ -177,6 +177,7 @@ pub enum ClientCommand { pub enum JoinResult { Success(RoomInfo), + AlreadyJoined, Banned, } @@ -388,6 +389,9 @@ impl Player { if self.banned_from.contains(&room_id) { return JoinResult::Banned; } + if self.my_rooms.contains_key(&room_id) { + return JoinResult::AlreadyJoined; + } let room = match self.rooms.get_or_create_room(room_id.clone()).await { Ok(room) => room,