rust/hedgewars-server/src/server/core.rs
changeset 14671 455865ccd36c
parent 14504 6cc0fce249f9
child 14672 6e6632068a33
equal deleted inserted replaced
14670:56831f466d1d 14671:455865ccd36c
    71 
    71 
    72     pub fn add_room(&mut self) -> &mut HWRoom {
    72     pub fn add_room(&mut self) -> &mut HWRoom {
    73         allocate_room(&mut self.rooms)
    73         allocate_room(&mut self.rooms)
    74     }
    74     }
    75 
    75 
    76     pub fn handle_msg(&mut self, client_id: ClientId, msg: HWProtocolMessage) {
       
    77         debug!("Handling message {:?} for client {}", msg, client_id);
       
    78         if self.clients.contains(client_id) {
       
    79             handlers::handle(self, client_id, msg);
       
    80         }
       
    81     }
       
    82 
       
    83     #[inline]
    76     #[inline]
    84     pub fn create_room(
    77     pub fn create_room(
    85         &mut self,
    78         &mut self,
    86         creator_id: ClientId,
    79         creator_id: ClientId,
    87         name: String,
    80         name: String,
    91             &mut self.clients[creator_id],
    84             &mut self.clients[creator_id],
    92             &mut self.rooms,
    85             &mut self.rooms,
    93             name,
    86             name,
    94             password,
    87             password,
    95         )
    88         )
       
    89     }
       
    90 
       
    91     #[inline]
       
    92     pub fn move_to_room(&mut self, client_id: ClientId, room_id: RoomId) {
       
    93         move_to_room(&mut self.clients[client_id], &mut self.rooms[room_id])
    96     }
    94     }
    97 
    95 
    98     fn get_recipients(&self, client_id: ClientId, destination: &Destination) -> Vec<ClientId> {
    96     fn get_recipients(&self, client_id: ClientId, destination: &Destination) -> Vec<ClientId> {
    99         let mut ids = match *destination {
    97         let mut ids = match *destination {
   100             Destination::ToSelf => vec![client_id],
    98             Destination::ToSelf => vec![client_id],
   127     ) {
   125     ) {
   128         let ids = self.get_recipients(client_id, &destination);
   126         let ids = self.get_recipients(client_id, &destination);
   129         self.output.push((ids, message));
   127         self.output.push((ids, message));
   130     }
   128     }
   131 
   129 
       
   130     pub fn send_msg(&mut self, client_id: ClientId, message: PendingMessage) {
       
   131         self.send(client_id, &message.destination, message.message)
       
   132     }
       
   133 
   132     pub fn react(&mut self, client_id: ClientId, actions: Vec<actions::Action>) {
   134     pub fn react(&mut self, client_id: ClientId, actions: Vec<actions::Action>) {
   133         for action in actions {
   135         for action in actions {
   134             actions::run_action(self, client_id, action);
   136             actions::run_action(self, client_id, action);
   135         }
   137         }
   136     }
   138     }