From f96ae557fd8f4da5eb9cdbfb2fd5a6fb111cbe8f Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 25 Nov 2020 22:02:16 -0700 Subject: [PATCH] how did this ever work? --- src/ship/location.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ship/location.rs b/src/ship/location.rs index 8b36055..c06a89e 100644 --- a/src/ship/location.rs +++ b/src/ship/location.rs @@ -146,6 +146,12 @@ impl Default for ClientLocation { impl ClientLocation { pub fn add_client_to_lobby(&mut self, id: ClientId, lobby: LobbyId) -> Result<(), JoinLobbyError> { + let l = self.lobbies.get_mut(lobby.0).ok_or(JoinLobbyError::LobbyDoesNotExist)?; + if l.0.iter().filter(|c| c.is_none()).count() == 0 { + return Err(JoinLobbyError::LobbyFull); + } + self.remove_client_from_area(id); + let l = self.lobbies.get_mut(lobby.0).ok_or(JoinLobbyError::LobbyDoesNotExist)?; let (index, empty_slot) = l.0.iter_mut() .enumerate() @@ -157,7 +163,6 @@ impl ClientLocation { local_client: LocalClientId(index), time_join: SystemTime::now(), }); - self.remove_client_from_area(id); self.client_location.insert(id, RoomLobby::Lobby(lobby)); Ok(()) }