From 707275e5efe7d4207c4b744c78a04b02d9aa9492 Mon Sep 17 00:00:00 2001 From: yuni Date: Wed, 27 Nov 2024 23:00:22 +0100 Subject: [PATCH] atmosphere: change variable types from f32 to f64 --- src/actor.rs | 4 ++-- src/hud.rs | 4 ++-- src/nature.rs | 12 ++++++------ src/var.rs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 3713c05..f1a49d0 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -1159,8 +1159,8 @@ fn handle_atmosphere( let pressure = nature::jupiter_altitude_to_pressure(distance); if player.is_some() { - settings.atmo_pressure = Some(pressure as f32); - settings.atmo_altitude = Some(height as f32); + settings.atmo_pressure = Some(pressure); + settings.atmo_altitude = Some(height); reset_player_gauges = false; } diff --git a/src/hud.rs b/src/hud.rs index a29b7f2..c29e436 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -878,10 +878,10 @@ fn update_speedometer( // Atmospheric conditions let mut atmo = String::new(); if let Some(val) = settings.atmo_altitude { - atmo += format!("Altitude: {}m\n", nature::readable_si(val as f64)).as_str(); + atmo += format!("alt: {}m\n", nature::readable_si(val)).as_str(); } if let Some(val) = settings.atmo_pressure { - atmo += format!("Pressure: {}bar\n", nature::readable_si(val as f64)).as_str(); + atmo += format!("p: {}bar\n", nature::readable_si(val as f64)).as_str(); } speed_text.sections[0].value = atmo; diff --git a/src/nature.rs b/src/nature.rs index ad1e7f8..08a99bb 100644 --- a/src/nature.rs +++ b/src/nature.rs @@ -157,17 +157,17 @@ pub fn readable_speed(speed: f64) -> String { pub fn readable_si(value: f64) -> String { if value > 1e10 { - return format!("{:.3} G", value / 1e9); + return format!("{:.1} G", value / 1e9); } else if value > 1e7 { - return format!("{:.3} M", value / 1e6); + return format!("{:.1} M", value / 1e6); } else if value > 1e4 { - return format!("{:.3} k", value / 1e3); + return format!("{:.1} k", value / 1e3); } else if value < 1e-2 { - return format!("{:.3} m", value * 1e3); + return format!("{:.1} m", value * 1e3); } else if value < 1e-5 { - return format!("{:.3} µ", value * 1e3); + return format!("{:.1} µ", value * 1e3); } - return format!("{:.3} ", value); + return format!("{:.1} ", value); } pub fn lorentz_factor(speed: f64) -> f64 { diff --git a/src/var.rs b/src/var.rs index 6223cb2..d7703d0 100644 --- a/src/var.rs +++ b/src/var.rs @@ -52,8 +52,8 @@ pub struct Settings { pub fov_highspeed: f32, pub zoom_fov: f32, pub zoom_sensitivity_factor: f32, - pub atmo_pressure: Option, - pub atmo_altitude: Option, + pub atmo_pressure: Option, + pub atmo_altitude: Option, pub font_size_hud: f32, pub font_size_fps: f32, pub font_size_conversations: f32,