diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index ebb47a9b73..74993288b0 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -48,7 +48,6 @@ pub fn handle_lantern(server: &mut Server, entity: EcsEntity) { } } -#[allow(clippy::useless_conversion)] // TODO: Pending review in #587 pub fn handle_mount(server: &mut Server, mounter: EcsEntity, mountee: EcsEntity) { let state = server.state_mut(); @@ -58,24 +57,18 @@ pub fn handle_mount(server: &mut Server, mounter: EcsEntity, mountee: EcsEntity) .get(mounter) .is_none() { - let not_mounting_yet = if let Some(comp::MountState::Unmounted) = state - .ecs() - .read_storage::() - .get(mountee) - .cloned() - { - true - } else { - false - }; + let not_mounting_yet = matches!( + state.ecs().read_storage::().get(mountee), + Some(comp::MountState::Unmounted) + ); if not_mounting_yet { if let (Some(mounter_uid), Some(mountee_uid)) = ( state.ecs().uid_from_entity(mounter), state.ecs().uid_from_entity(mountee), ) { - state.write_component(mountee, comp::MountState::MountedBy(mounter_uid.into())); - state.write_component(mounter, comp::Mounting(mountee_uid.into())); + state.write_component(mountee, comp::MountState::MountedBy(mounter_uid)); + state.write_component(mounter, comp::Mounting(mountee_uid)); } } } diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 2898937ae7..468abcdb4f 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -911,7 +911,8 @@ impl Hud { // Increase font size based on fraction of maximum health // "flashes" by having a larger size in the first 100ms let font_size_xp = 30 - + (exp_change.abs() as f32 / stats.exp.maximum() as f32 * 50.0) as u32 + + ((exp_change.abs() as f32 / stats.exp.maximum() as f32).min(1.0) + * 50.0) as u32 + if timer < 0.1 { (FLASH_MAX * (1.0 - timer / 0.1)) as u32 } else { @@ -953,7 +954,8 @@ impl Hud { // Increase font size based on fraction of maximum health // "flashes" by having a larger size in the first 100ms let font_size_xp = 30 - + (floater.exp_change.abs() as f32 / stats.exp.maximum() as f32 + + ((floater.exp_change.abs() as f32 / stats.exp.maximum() as f32) + .min(1.0) * 50.0) as u32 + if floater.timer < 0.1 { (FLASH_MAX * (1.0 - floater.timer / 0.1)) as u32 diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index b1a7f941ec..d6eb8ae472 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -90,11 +90,10 @@ pub struct Font(text::Font); impl assets::Asset for Font { const ENDINGS: &'static [&'static str] = &["ttf"]; - #[allow(clippy::redundant_clone)] // TODO: Pending review in #587 fn parse(mut buf_reader: BufReader) -> Result { let mut buf = Vec::new(); buf_reader.read_to_end(&mut buf)?; - Ok(Font(text::Font::from_bytes(buf.clone()).unwrap())) + Ok(Font(text::Font::from_bytes(buf).unwrap())) } } @@ -588,23 +587,25 @@ impl Ui { glyph_cache.queue_glyph(font_id.index(), glyph.clone()); } - glyph_cache - .cache_queued(|rect, data| { - let offset = [rect.min.x as u16, rect.min.y as u16]; - let size = [rect.width() as u16, rect.height() as u16]; + if let Err(err) = glyph_cache.cache_queued(|rect, data| { + let offset = [rect.min.x as u16, rect.min.y as u16]; + let size = [rect.width() as u16, rect.height() as u16]; - let new_data = data - .iter() - .map(|x| [255, 255, 255, *x]) - .collect::>(); + let new_data = data + .iter() + .map(|x| [255, 255, 255, *x]) + .collect::>(); - if let Err(err) = - renderer.update_texture(cache_tex, offset, size, &new_data) - { - warn!("Failed to update texture: {:?}", err); - } - }) - .unwrap(); + if let Err(err) = + renderer.update_texture(cache_tex, offset, size, &new_data) + { + warn!("Failed to update texture: {:?}", err); + } + }) { + warn!("Failed to cache queued glyphs: {:?}", err); + // Clear uncachable glyphs from the queue + glyph_cache.clear_queue(); + } let color = srgba_to_linear(color.to_fsa().into());