|
|
|
@ -132,11 +132,12 @@ pub fn despawn_disconnected_clients(
|
|
|
|
|
mut message_queue: ResMut<MessageQueue>,
|
|
|
|
|
mut disconnected_clients: RemovedComponents<Client>,
|
|
|
|
|
) {
|
|
|
|
|
let default_username = "[Unknown username]".to_string();
|
|
|
|
|
let username_cache = USERNAME_CACHE.lock().unwrap();
|
|
|
|
|
let mut username_cache = USERNAME_CACHE.lock().unwrap();
|
|
|
|
|
for entity in disconnected_clients.iter() {
|
|
|
|
|
if let Some(mut entity_commands) = commands.get_entity(entity) {
|
|
|
|
|
let username = username_cache.get(&entity).unwrap_or(&default_username);
|
|
|
|
|
let username = username_cache
|
|
|
|
|
.remove(&entity)
|
|
|
|
|
.unwrap_or("[Unknown username]".to_string());
|
|
|
|
|
message_queue.0.push(
|
|
|
|
|
format!("{username} left the game")
|
|
|
|
|
.italic()
|
|
|
|
|