rust/hedgewars-server/src/core/server.rs
changeset 15522 4a0b06b03199
parent 15520 fd3a20e9d095
child 15523 f4f6060b536c
equal deleted inserted replaced
15521:1fcce8feace4 15522:4a0b06b03199
   126     }
   126     }
   127 }
   127 }
   128 
   128 
   129 pub struct HwServer {
   129 pub struct HwServer {
   130     clients: IndexSlab<HwClient>,
   130     clients: IndexSlab<HwClient>,
   131     pub rooms: Slab<HwRoom>,
   131     rooms: Slab<HwRoom>,
   132     pub latest_protocol: u16,
   132     pub latest_protocol: u16,
   133     pub flags: ServerFlags,
   133     pub flags: ServerFlags,
   134     pub greetings: ServerGreetings,
   134     pub greetings: ServerGreetings,
   135 }
   135 }
   136 
   136 
   176     pub fn room_mut(&mut self, room_id: RoomId) -> &mut HwRoom {
   176     pub fn room_mut(&mut self, room_id: RoomId) -> &mut HwRoom {
   177         &mut self.rooms[room_id]
   177         &mut self.rooms[room_id]
   178     }
   178     }
   179 
   179 
   180     #[inline]
   180     #[inline]
       
   181     pub fn get_room(&self, room_id: RoomId) -> Option<&HwRoom> {
       
   182         self.rooms.get(room_id)
       
   183     }
       
   184 
       
   185     #[inline]
       
   186     pub fn get_room_mut(&mut self, room_id: RoomId) -> Option<&mut HwRoom> {
       
   187         self.rooms.get_mut(room_id)
       
   188     }
       
   189 
       
   190     #[inline]
       
   191     pub fn iter_rooms(&self) -> impl Iterator<Item = &HwRoom> {
       
   192         self.rooms.iter().map(|(_, r)| r)
       
   193     }
       
   194 
       
   195     #[inline]
   181     pub fn client_and_room(&self, client_id: ClientId, room_id: RoomId) -> (&HwClient, &HwRoom) {
   196     pub fn client_and_room(&self, client_id: ClientId, room_id: RoomId) -> (&HwClient, &HwRoom) {
   182         (&self.clients[client_id], &self.rooms[room_id])
   197         (&self.clients[client_id], &self.rooms[room_id])
   183     }
   198     }
   184 
   199 
   185     #[inline]
   200     #[inline]
   186     pub fn client_and_room_mut(
   201     pub fn client_and_room_mut(
   187         &mut self,
   202         &mut self,
   188         client_id: ClientId,
   203         client_id: ClientId,
   189         room_id: RoomId,
   204         room_id: RoomId,
   190     ) -> (&HwClient, &mut HwRoom) {
   205     ) -> (&HwClient, &HwRoom) {
   191         (&self.clients[client_id], &mut self.rooms[room_id])
   206         (&self.clients[client_id], &mut self.rooms[room_id])
   192     }
   207     }
   193 
   208 
   194     #[inline]
   209     #[inline]
   195     pub fn is_admin(&self, client_id: ClientId) -> bool {
   210     pub fn is_admin(&self, client_id: ClientId) -> bool {