231 Destination::ToSelf => vec![client_id], |
231 Destination::ToSelf => vec![client_id], |
232 Destination::ToId(id) => vec![id], |
232 Destination::ToId(id) => vec![id], |
233 Destination::ToIds(ids) => ids, |
233 Destination::ToIds(ids) => ids, |
234 Destination::ToAll { group, skip_self } => { |
234 Destination::ToAll { group, skip_self } => { |
235 let mut ids: Vec<_> = match group { |
235 let mut ids: Vec<_> = match group { |
236 DestinationGroup::All => server.all_clients().collect(), |
236 DestinationGroup::All => server.iter_client_ids().collect(), |
237 DestinationGroup::Lobby => server.lobby_clients().collect(), |
237 DestinationGroup::Lobby => server.lobby_client_ids().collect(), |
238 DestinationGroup::Protocol(proto) => server.protocol_clients(proto).collect(), |
238 DestinationGroup::Protocol(proto) => server.protocol_client_ids(proto).collect(), |
239 DestinationGroup::Room(id) => server.room_clients(id).collect(), |
239 DestinationGroup::Room(id) => server.room_client_ids(id).collect(), |
240 }; |
240 }; |
241 |
241 |
242 if skip_self { |
242 if skip_self { |
243 if let Some(index) = ids.iter().position(|id| *id == client_id) { |
243 if let Some(index) = ids.iter().position(|id| *id == client_id) { |
244 ids.remove(index); |
244 ids.remove(index); |
458 } |
458 } |
459 IoResult::SaveRoom(_, false) => { |
459 IoResult::SaveRoom(_, false) => { |
460 response.warn(ROOM_CONFIG_SAVE_FAILED); |
460 response.warn(ROOM_CONFIG_SAVE_FAILED); |
461 } |
461 } |
462 IoResult::LoadRoom(room_id, Some(contents)) => { |
462 IoResult::LoadRoom(room_id, Some(contents)) => { |
463 if let Some(ref mut room) = state.server.get_room_mut(room_id) { |
463 match state.server.set_room_saves(room_id, &contents) { |
464 match room.set_saves(&contents) { |
464 Ok(_) => response.add(server_chat(ROOM_CONFIG_LOADED.to_string()).send_self()), |
465 Ok(_) => response.add(server_chat(ROOM_CONFIG_LOADED.to_string()).send_self()), |
465 Err(e) => { |
466 Err(e) => { |
466 warn!("Error while deserializing the room configs: {}", e); |
467 warn!("Error while deserializing the room configs: {}", e); |
467 response.warn(ROOM_CONFIG_DESERIALIZE_FAILED); |
468 response.warn(ROOM_CONFIG_DESERIALIZE_FAILED); |
|
469 } |
|
470 } |
468 } |
471 } |
469 } |
472 } |
470 } |
473 IoResult::LoadRoom(_, None) => { |
471 IoResult::LoadRoom(_, None) => { |
474 response.warn(ROOM_CONFIG_LOAD_FAILED); |
472 response.warn(ROOM_CONFIG_LOAD_FAILED); |