From 225cbf472f166036d561ffe33162f6873fe3d53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=A4rtens?= Date: Mon, 28 Nov 2022 23:51:03 +0100 Subject: [PATCH] update tag and fix empty maps, other bugs introduced by auto fix --- .gitlab-ci.yml | 2 +- client/src/lib.rs | 4 +--- common/src/view_distances.rs | 5 ++--- server/src/presence.rs | 2 +- voxygen/src/hud/map.rs | 4 ++-- voxygen/src/hud/minimap.rs | 2 +- world/src/canvas.rs | 2 +- world/src/column/mod.rs | 12 ++++-------- world/src/layer/cave.rs | 2 +- world/src/layer/mod.rs | 2 +- 10 files changed, 15 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f924603ea..b76fc171a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,7 +13,7 @@ variables: # https://docs.gitlab.com/ee/ci/yaml/#shallow-cloning GIT_DEPTH: 3 GIT_CLEAN_FLAGS: -f - CACHE_IMAGE_TAG: 9a0cb110 + CACHE_IMAGE_TAG: 8e8fe241 TAG_REGEX: '/^v[0-9]+\.[0-9]+\.[0-9]+$/' default: diff --git a/client/src/lib.rs b/client/src/lib.rs index 6076e958c1..8f57187f2b 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -992,12 +992,10 @@ impl Client { &mut self, view_distances: common::ViewDistances, ) -> common::ViewDistances { - #[allow(clippy::manual_clamp)] let view_distances = common::ViewDistances { terrain: view_distances .terrain - .max(1) - .min(MAX_SELECTABLE_VIEW_DISTANCE), + .clamp(1, MAX_SELECTABLE_VIEW_DISTANCE), entity: view_distances.entity.max(1), }; self.view_distance = Some(view_distances.terrain); diff --git a/common/src/view_distances.rs b/common/src/view_distances.rs index 4ff1f7357f..655dbd7481 100644 --- a/common/src/view_distances.rs +++ b/common/src/view_distances.rs @@ -15,12 +15,11 @@ impl ViewDistances { /// entity view distance to the resulting terrain view distance. /// /// Also ensures both are at a minimum of 1 (unless the provided max is 0). - #[allow(clippy::manual_clamp)] pub fn clamp(self, max: Option) -> Self { - let terrain = self.terrain.max(1).min(max.unwrap_or(u32::MAX)); + let terrain = self.terrain.clamp(1,max.unwrap_or(u32::MAX)); Self { terrain, - entity: self.entity.max(1).min(terrain), + entity: self.entity.clamp(1,terrain), } } } diff --git a/server/src/presence.rs b/server/src/presence.rs index 8863ac7346..99c7c10c4c 100644 --- a/server/src/presence.rs +++ b/server/src/presence.rs @@ -80,7 +80,7 @@ impl ViewDistance { pub fn new(start_value: u32, now: Instant) -> Self { Self { direction: Direction::Up, - last_direction_change_time: now.checked_sub(Self::TIME_PER_DIR_CHANGE).unwrap(), + last_direction_change_time: now.checked_sub(Self::TIME_PER_DIR_CHANGE).unwrap_or(now), target: None, current: start_value, } diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 7dce34d69d..5f9d57792d 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -1204,7 +1204,7 @@ impl<'a> Widget for Map<'a> { let side_length = 20.0 * factor; let (rpos, fade) = match wpos_to_rpos_fade( - member_pos.0.xy().map(|e| e), + member_pos.0.xy(), Vec2::from(side_length / 2.0), side_length / 2.0, ) { @@ -1232,7 +1232,7 @@ impl<'a> Widget for Map<'a> { handle_widget_mouse_events( state.ids.member_indicators[i], - MarkerChange::Pos(member_pos.0.xy().map(|e| e)), + MarkerChange::Pos(member_pos.0.xy()), ui, &mut events, state.ids.map_layers[0], diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 5552b3a900..79a9993384 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -769,7 +769,7 @@ impl<'a> Widget for MiniMap<'a> { let member_pos = entity.and_then(|entity| member_pos.get(entity)); if let Some(member_pos) = member_pos { - let rpos = match wpos_to_rpos(member_pos.0.xy().map(|e| e), false) { + let rpos = match wpos_to_rpos(member_pos.0.xy(), false) { Some(rpos) => rpos, None => continue, }; diff --git a/world/src/canvas.rs b/world/src/canvas.rs index 67634f08a4..196206d2ee 100644 --- a/world/src/canvas.rs +++ b/world/src/canvas.rs @@ -168,7 +168,7 @@ impl<'a> Canvas<'a> { ) { let chunk_aabr = Aabr { min: self.wpos(), - max: self.wpos() + Vec2::from(self.area().size().map(|e| e)), + max: self.wpos() + Vec2::from(self.area().size()), }; for y in chunk_aabr.min.y.max(aabr.min.y)..chunk_aabr.max.y.min(aabr.max.y) { diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 4f7789a251..d78c4cbf84 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -262,10 +262,8 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { Some(RiverKind::Lake { .. } | RiverKind::Ocean) ) { let water_chunk = posj.map(|e| e as f64); - let lake_width_noise = sim - .gen_ctx - .small_nz - .get((wposf.map(|e| e).div(32.0)).into_array()); + let lake_width_noise = + sim.gen_ctx.small_nz.get((wposf.div(32.0)).into_array()); let water_aabr = Aabr { min: water_chunk * neighbor_coef + 4.0 - lake_width_noise * 8.0, max: (water_chunk + 1.0) * neighbor_coef - 4.0 @@ -313,10 +311,8 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { }, RiverKind::Ocean => { let water_chunk = posj.map(|e| e as f64); - let lake_width_noise = sim - .gen_ctx - .small_nz - .get((wposf.map(|e| e).div(32.0)).into_array()); + let lake_width_noise = + sim.gen_ctx.small_nz.get((wposf.div(32.0)).into_array()); let water_aabr = Aabr { min: water_chunk * neighbor_coef + 4.0 - lake_width_noise * 8.0, max: (water_chunk + 1.0) * neighbor_coef - 4.0 + lake_width_noise * 8.0, diff --git a/world/src/layer/cave.rs b/world/src/layer/cave.rs index e3ab049e4e..7aa63bc9a9 100644 --- a/world/src/layer/cave.rs +++ b/world/src/layer/cave.rs @@ -499,7 +499,7 @@ fn write_column( .mul(0.1) .clamped(0.0, 1.0); - let rpos = wposf_warped - mushroom.pos.map(|e| e as f32).map(|e| e); + let rpos = wposf_warped - mushroom.pos.map(|e| e as f32); let stalk_radius = 2.5f32; let head_radius = 12.0f32; diff --git a/world/src/layer/mod.rs b/world/src/layer/mod.rs index 194c15266f..c1aa677732 100644 --- a/world/src/layer/mod.rs +++ b/world/src/layer/mod.rs @@ -887,7 +887,7 @@ pub fn apply_caverns_to(canvas: &mut Canvas, dynamic_rng: &mut R) { .mul(0.1) .clamped(0.0, 1.0); - let rpos = wposf_warped - mushroom.pos.map(|e| e as f32).map(|e| e); + let rpos = wposf_warped - mushroom.pos.map(|e| e as f32); let stalk_radius = 2.5f32; let head_radius = 18.0f32;