405 } else { |
413 } else { |
406 Err(ChangeMasterError::NoAccess) |
414 Err(ChangeMasterError::NoAccess) |
407 } |
415 } |
408 } |
416 } |
409 |
417 |
|
418 pub fn start_game(&mut self, room_id: RoomId) -> Result<Vec<String>, StartGameError> { |
|
419 let (room_clients, room_nicks): (Vec<_>, Vec<_>) = self |
|
420 .clients |
|
421 .iter() |
|
422 .map(|(id, c)| (id, c.nick.clone())) |
|
423 .unzip(); |
|
424 |
|
425 let room = &mut self.rooms[room_id]; |
|
426 |
|
427 if !room.has_multiple_clans() { |
|
428 Err(StartGameError::NotEnoughClans) |
|
429 } else if room.protocol_number <= 43 && room.players_number != room.ready_players_number { |
|
430 Err(StartGameError::NotReady) |
|
431 } else if room.game_info.is_some() { |
|
432 Err(StartGameError::AlreadyInGame) |
|
433 } else { |
|
434 room.start_round(); |
|
435 for id in room_clients { |
|
436 let c = &mut self.clients[id]; |
|
437 c.set_is_in_game(true); |
|
438 c.team_indices = room.client_team_indices(c.id); |
|
439 } |
|
440 Ok(room_nicks) |
|
441 } |
|
442 } |
|
443 |
410 #[inline] |
444 #[inline] |
411 pub fn set_var(&mut self, client_id: ClientId, var: ServerVar) -> Result<(), AccessError> { |
445 pub fn set_var(&mut self, client_id: ClientId, var: ServerVar) -> Result<(), AccessError> { |
412 if self.clients[client_id].is_admin() { |
446 if self.clients[client_id].is_admin() { |
413 match var { |
447 match var { |
414 ServerVar::MOTDNew(msg) => self.greetings.for_latest_protocol = msg, |
448 ServerVar::MOTDNew(msg) => self.greetings.for_latest_protocol = msg, |