diff --git a/common/src/terrain/mod.rs b/common/src/terrain/mod.rs index 8ea9ebe53f..ca8e0a67a0 100644 --- a/common/src/terrain/mod.rs +++ b/common/src/terrain/mod.rs @@ -131,7 +131,7 @@ impl TerrainChunkMeta { } } - pub fn name(&self) -> &str { self.name.as_deref().unwrap_or("") } + pub fn name(&self) -> Option<&str> { self.name.as_deref() } pub fn biome(&self) -> BiomeKind { self.biome } diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 8b51741b74..c1fc992035 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -886,20 +886,22 @@ impl<'a> Widget for MiniMap<'a> { match self.client.current_chunk() { Some(chunk) => { // Count characters in the name to avoid clipping with the name display - let name_len = chunk.meta().name().chars().count(); - Text::new(chunk.meta().name()) - .mid_top_with_margin_on(state.ids.mmap_frame, match name_len { - 15..=30 => 4.0, - _ => 2.0, - }) - .font_size(self.fonts.cyri.scale(match name_len { - 0..=15 => 18, - 16..=30 => 14, - _ => 14, - })) - .font_id(self.fonts.cyri.conrod_id) - .color(TEXT_COLOR) - .set(state.ids.mmap_location, ui) + if let Some(name) = chunk.meta().name() { + let name_len = name.chars().count(); + Text::new(name) + .mid_top_with_margin_on(state.ids.mmap_frame, match name_len { + 15..=30 => 4.0, + _ => 2.0, + }) + .font_size(self.fonts.cyri.scale(match name_len { + 0..=15 => 18, + 16..=30 => 14, + _ => 14, + })) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.mmap_location, ui) + } }, None => Text::new(" ") .mid_top_with_margin_on(state.ids.mmap_frame, 0.0) diff --git a/voxygen/src/hud/popup.rs b/voxygen/src/hud/popup.rs index afb10a7de9..9daca35dec 100644 --- a/voxygen/src/hud/popup.rs +++ b/voxygen/src/hud/popup.rs @@ -98,23 +98,24 @@ impl<'a> Widget for Popup<'a> { // Push chunk name to message queue if let Some(chunk) = self.client.current_chunk() { - let current = chunk.meta().name(); - // Check if no other popup is displayed and a new one is needed - if state.messages.is_empty() - && state - .last_region_name - .as_ref() - .map(|l| l != current) - .unwrap_or(true) - { - // Update last_region - state.update(|s| { - if s.messages.is_empty() { - s.last_message_update = Instant::now(); - } - s.last_region_name = Some(current.to_owned()); - s.messages.push_back(current.to_owned()); - }); + if let Some(current) = chunk.meta().name() { + // Check if no other popup is displayed and a new one is needed + if state.messages.is_empty() + && state + .last_region_name + .as_ref() + .map(|l| l != current) + .unwrap_or(true) + { + // Update last_region + state.update(|s| { + if s.messages.is_empty() { + s.last_message_update = Instant::now(); + } + s.last_region_name = Some(current.to_owned()); + s.messages.push_back(current.to_owned()); + }); + } } }