how did this ever work?

This commit is contained in:
jake 2020-11-25 22:02:16 -07:00
parent 78ed2101e5
commit f96ae557fd

View File

@ -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(())
}