diff -r 1fcce8feace4 -r 4a0b06b03199 rust/hedgewars-server/src/core/server.rs --- a/rust/hedgewars-server/src/core/server.rs Mon Dec 23 18:11:15 2019 +0300 +++ b/rust/hedgewars-server/src/core/server.rs Mon Dec 23 18:55:25 2019 +0300 @@ -128,7 +128,7 @@ pub struct HwServer { clients: IndexSlab, - pub rooms: Slab, + rooms: Slab, pub latest_protocol: u16, pub flags: ServerFlags, pub greetings: ServerGreetings, @@ -178,6 +178,21 @@ } #[inline] + pub fn get_room(&self, room_id: RoomId) -> Option<&HwRoom> { + self.rooms.get(room_id) + } + + #[inline] + pub fn get_room_mut(&mut self, room_id: RoomId) -> Option<&mut HwRoom> { + self.rooms.get_mut(room_id) + } + + #[inline] + pub fn iter_rooms(&self) -> impl Iterator { + self.rooms.iter().map(|(_, r)| r) + } + + #[inline] pub fn client_and_room(&self, client_id: ClientId, room_id: RoomId) -> (&HwClient, &HwRoom) { (&self.clients[client_id], &self.rooms[room_id]) } @@ -187,7 +202,7 @@ &mut self, client_id: ClientId, room_id: RoomId, - ) -> (&HwClient, &mut HwRoom) { + ) -> (&HwClient, &HwRoom) { (&self.clients[client_id], &mut self.rooms[room_id]) }