enforce only one client at a position (#102)

This commit is contained in:
Ferdinand Schober
2024-04-10 14:16:19 +02:00
committed by GitHub
parent cc7984c066
commit 9ca7e2378c
2 changed files with 128 additions and 92 deletions

View File

@@ -178,6 +178,19 @@ impl ClientManager {
.map(|p| p as ClientHandle)
}
pub fn find_client(&self, pos: Position) -> Option<ClientHandle> {
self.clients
.iter()
.position(|c| {
if let Some(c) = c {
c.active && c.client.pos == pos
} else {
false
}
})
.map(|p| p as ClientHandle)
}
/// remove a client from the list
pub fn remove_client(&mut self, client: ClientHandle) -> Option<ClientState> {
// remove id from occupied ids