master
Drake 1 year ago
parent 830213b37d
commit 406b52374c

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

Loading…
Cancel
Save