return AlreadyJoined when a player attempts to join a room they are already in

This commit is contained in:
Nikita Vilunov 2024-04-20 17:09:44 +02:00
parent cebe354179
commit 5a09b743c9
1 changed files with 4 additions and 0 deletions

View File

@ -177,6 +177,7 @@ pub enum ClientCommand {
pub enum JoinResult { pub enum JoinResult {
Success(RoomInfo), Success(RoomInfo),
AlreadyJoined,
Banned, Banned,
} }
@ -388,6 +389,9 @@ impl Player {
if self.banned_from.contains(&room_id) { if self.banned_from.contains(&room_id) {
return JoinResult::Banned; 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 { let room = match self.rooms.get_or_create_room(room_id.clone()).await {
Ok(room) => room, Ok(room) => room,