From e3cab272c3c003d4afe31be731d20d123b5960e2 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 12 Aug 2020 18:29:51 +0100 Subject: [PATCH] Fixed floating sprites in towns, clippy fixes --- common/src/lottery.rs | 9 +- server/src/cmd.rs | 2 +- voxygen/src/anim/src/character/beta.rs | 101 +++++++++--------- voxygen/src/anim/src/character/spin.rs | 96 ++++++++--------- voxygen/src/anim/src/lib.rs | 1 + .../audio/sfx/event_mapper/movement/tests.rs | 22 ++-- world/examples/view.rs | 2 +- world/examples/water.rs | 4 +- world/src/block/mod.rs | 21 ++-- world/src/civ/mod.rs | 4 +- world/src/column/mod.rs | 38 +++---- world/src/layer/mod.rs | 16 +-- world/src/site/dungeon/mod.rs | 2 +- .../site/settlement/building/archetype/mod.rs | 2 + world/src/site/settlement/mod.rs | 8 +- world/src/util/random.rs | 14 +-- 16 files changed, 164 insertions(+), 178 deletions(-) diff --git a/common/src/lottery.rs b/common/src/lottery.rs index 0a7a6698a1..6e4546f88e 100644 --- a/common/src/lottery.rs +++ b/common/src/lottery.rs @@ -47,14 +47,11 @@ impl Lottery { #[cfg(test)] mod tests { - use crate::{ - assets, - comp::inventory::item::{lottery::Lottery, Item}, - }; + use super::*; + use crate::{assets, comp::Item}; #[test] fn test_loot_table() { - let test = assets::load_expect::>("common.loot_table"); - let test = test; + let test = assets::load_expect::>("common.loot_table"); for (_, item) in test.iter() { assert!( diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 9abd4f49a4..61e8eed5ed 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -209,7 +209,7 @@ fn handle_make_block( } else { server.notify_client( client, - ChatType::CommandError.server_msg(String::from(action.help_string())), + ChatType::CommandError.server_msg(action.help_string()), ); } } diff --git a/voxygen/src/anim/src/character/beta.rs b/voxygen/src/anim/src/character/beta.rs index 3facc7a2e0..720ce56bf3 100644 --- a/voxygen/src/anim/src/character/beta.rs +++ b/voxygen/src/anim/src/character/beta.rs @@ -41,65 +41,60 @@ impl Animation for BetaAnimation { .sqrt()) * ((anim_time as f32 * lab as f32 * 14.0).sin()); - match active_tool_kind { - //TODO: Inventory - Some(ToolKind::Axe(_)) - | Some(ToolKind::Hammer(_)) - | Some(ToolKind::Sword(_)) - | Some(ToolKind::Dagger(_)) => { - //INTENTION: SWORD - next.head.offset = - Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); - next.head.ori = Quaternion::rotation_z(slow * -0.18) - * Quaternion::rotation_x(-0.1 + slow * -0.28) - * Quaternion::rotation_y(0.2 + slow * 0.18); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; + if let Some( + ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_), + ) = active_tool_kind + { + //INTENTION: SWORD + next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); + next.head.ori = Quaternion::rotation_z(slow * -0.18) + * Quaternion::rotation_x(-0.1 + slow * -0.28) + * Quaternion::rotation_y(0.2 + slow * 0.18); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0); - next.chest.ori = Quaternion::rotation_z(slow * 0.2) - * Quaternion::rotation_x(slow * 0.2) - * Quaternion::rotation_y(slow * -0.1); + next.chest.offset = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0); + next.chest.ori = Quaternion::rotation_z(slow * 0.2) + * Quaternion::rotation_x(slow * 0.2) + * Quaternion::rotation_y(slow * -0.1); - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = Quaternion::rotation_z(slow * 0.1) - * Quaternion::rotation_x(slow * 0.1) - * Quaternion::rotation_y(slow * -0.04); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = Quaternion::rotation_z(slow * 0.1) + * Quaternion::rotation_x(slow * 0.1) + * Quaternion::rotation_y(slow * -0.04); - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.shorts.ori = Quaternion::rotation_z(slow * 0.1) - * Quaternion::rotation_x(slow * 0.1) - * Quaternion::rotation_y(slow * -0.05); + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.shorts.ori = Quaternion::rotation_z(slow * 0.1) + * Quaternion::rotation_x(slow * 0.1) + * Quaternion::rotation_y(slow * -0.05); - next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); - next.main.ori = Quaternion::rotation_x(-0.3); + next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3); - next.control.offset = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0); - next.control.ori = Quaternion::rotation_x(-1.4) - * Quaternion::rotation_y(slow * 2.0 + 0.7) - * Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6); - next.control.scale = Vec3::one(); - next.l_foot.offset = Vec3::new( - -skeleton_attr.foot.0, - footquick * -9.5, - skeleton_attr.foot.2, - ); - next.l_foot.ori = Quaternion::rotation_x(footquick * 0.3) - * Quaternion::rotation_y(footquick * -0.6); + next.control.offset = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0); + next.control.ori = Quaternion::rotation_x(-1.4) + * Quaternion::rotation_y(slow * 2.0 + 0.7) + * Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6); + next.control.scale = Vec3::one(); + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + footquick * -9.5, + skeleton_attr.foot.2, + ); + next.l_foot.ori = + Quaternion::rotation_x(footquick * 0.3) * Quaternion::rotation_y(footquick * -0.6); - next.r_foot.offset = - Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2); - next.r_foot.ori = Quaternion::rotation_x(footquick * -0.3) - * Quaternion::rotation_y(footquick * 0.2); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - _ => {}, + next.r_foot.offset = + Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2); + next.r_foot.ori = + Quaternion::rotation_x(footquick * -0.3) * Quaternion::rotation_y(footquick * 0.2); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; } next.l_shoulder.offset = Vec3::new( diff --git a/voxygen/src/anim/src/character/spin.rs b/voxygen/src/anim/src/character/spin.rs index 36aa169bab..52fa49eef5 100644 --- a/voxygen/src/anim/src/character/spin.rs +++ b/voxygen/src/anim/src/character/spin.rs @@ -38,60 +38,56 @@ impl Animation for SpinAnimation { let spin = (anim_time as f32 * 2.8 * lab as f32).sin(); let spinhalf = (anim_time as f32 * 1.4 * lab as f32).sin(); - match active_tool_kind { - //TODO: Inventory - Some(ToolKind::Axe(_)) - | Some(ToolKind::Hammer(_)) - | Some(ToolKind::Sword(_)) - | Some(ToolKind::Dagger(_)) => { - //INTENTION: SWORD - next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5); - next.l_hand.ori = Quaternion::rotation_x(1.27); - next.l_hand.scale = Vec3::one() * 1.04; - next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5); - next.r_hand.ori = Quaternion::rotation_x(1.27); - next.r_hand.scale = Vec3::one() * 1.05; - next.main.offset = Vec3::new(0.0, 6.0, -1.0); - next.main.ori = Quaternion::rotation_x(-0.3) - * Quaternion::rotation_y(0.0) - * Quaternion::rotation_z(0.0); - next.main.scale = Vec3::one(); + if let Some( + ToolKind::Axe(_) | ToolKind::Hammer(_) | ToolKind::Sword(_) | ToolKind::Dagger(_), + ) = active_tool_kind + { + //INTENTION: SWORD + next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5); + next.l_hand.ori = Quaternion::rotation_x(1.27); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5); + next.r_hand.ori = Quaternion::rotation_x(1.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 6.0, -1.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); - next.control.offset = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0); - next.control.ori = Quaternion::rotation_x(-1.7) - * Quaternion::rotation_y(0.2 + spin * -2.0) - * Quaternion::rotation_z(1.4 + spin * 0.1); - next.control.scale = Vec3::one(); - next.head.offset = Vec3::new( - 0.0, - -2.0 + skeleton_attr.head.0 + spin * -0.8, - skeleton_attr.head.1, - ); - next.head.ori = Quaternion::rotation_z(spin * -0.25) - * Quaternion::rotation_x(0.0 + spin * -0.1) - * Quaternion::rotation_y(spin * -0.2); - next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1); - next.chest.ori = Quaternion::rotation_z(spin * 0.1) - * Quaternion::rotation_x(0.0 + spin * 0.1) - * Quaternion::rotation_y(decel * -0.2); - next.chest.scale = Vec3::one(); + next.control.offset = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0); + next.control.ori = Quaternion::rotation_x(-1.7) + * Quaternion::rotation_y(0.2 + spin * -2.0) + * Quaternion::rotation_z(1.4 + spin * 0.1); + next.control.scale = Vec3::one(); + next.head.offset = Vec3::new( + 0.0, + -2.0 + skeleton_attr.head.0 + spin * -0.8, + skeleton_attr.head.1, + ); + next.head.ori = Quaternion::rotation_z(spin * -0.25) + * Quaternion::rotation_x(0.0 + spin * -0.1) + * Quaternion::rotation_y(spin * -0.2); + next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1); + next.chest.ori = Quaternion::rotation_z(spin * 0.1) + * Quaternion::rotation_x(0.0 + spin * 0.1) + * Quaternion::rotation_y(decel * -0.2); + next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, 0.0, -2.0); - next.belt.ori = next.chest.ori * -0.1; - next.belt.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, 0.0, -2.0); + next.belt.ori = next.chest.ori * -0.1; + next.belt.scale = Vec3::one(); - next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); - next.belt.ori = next.chest.ori * -0.08; - next.shorts.scale = Vec3::one(); - next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_z((spin * 7.0).max(0.3)) - * Quaternion::rotation_x(0.0) - * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - }, - - _ => {}, + next.shorts.offset = Vec3::new(0.0, 0.0, -5.0); + next.belt.ori = next.chest.ori * -0.08; + next.shorts.scale = Vec3::one(); + next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_z((spin * 7.0).max(0.3)) + * Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; } + next.l_foot.offset = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2); next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); next.l_foot.scale = Vec3::one(); diff --git a/voxygen/src/anim/src/lib.rs b/voxygen/src/anim/src/lib.rs index b697eb89f4..8fa5542505 100644 --- a/voxygen/src/anim/src/lib.rs +++ b/voxygen/src/anim/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(or_patterns)] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); diff --git a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs index f407231ab6..6a004489d3 100644 --- a/voxygen/src/audio/sfx/event_mapper/movement/tests.rs +++ b/voxygen/src/audio/sfx/event_mapper/movement/tests.rs @@ -85,7 +85,7 @@ fn maps_idle() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Idle, @@ -107,7 +107,7 @@ fn maps_run_with_sufficient_velocity() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Idle, @@ -129,7 +129,7 @@ fn does_not_map_run_with_insufficient_velocity() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Idle, @@ -151,7 +151,7 @@ fn does_not_map_run_with_sufficient_velocity_but_not_on_ground() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Idle, @@ -176,7 +176,7 @@ fn maps_roll() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Run, @@ -198,7 +198,7 @@ fn maps_land_on_ground_to_run() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Idle, @@ -220,7 +220,7 @@ fn maps_glider_open() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Jump, @@ -242,7 +242,7 @@ fn maps_glide() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Glide, @@ -264,7 +264,7 @@ fn maps_glider_close_when_closing_mid_flight() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Glide, @@ -287,7 +287,7 @@ fn maps_glider_close_when_landing() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, &PreviousEntityState { event: SfxEvent::Glide, @@ -308,7 +308,7 @@ fn maps_quadrupeds_running() { on_ceiling: false, on_wall: None, touch_entity: None, - in_fluid: false, + in_fluid: None, }, Vec3::new(0.5, 0.8, 0.0), ); diff --git a/world/examples/view.rs b/world/examples/view.rs index f80bbca0de..b137e8abbe 100644 --- a/world/examples/view.rs +++ b/world/examples/view.rs @@ -28,7 +28,7 @@ fn main() { let pos = focus + Vec2::new(i as i32, j as i32) * scale; let (alt, place) = sampler - .get(pos) + .get((pos, world.index())) .map(|sample| { ( sample.alt.sub(64.0).add(gain).mul(0.7).max(0.0).min(255.0) as u8, diff --git a/world/examples/water.rs b/world/examples/water.rs index 1b1c47354f..36303763c5 100644 --- a/world/examples/water.rs +++ b/world/examples/water.rs @@ -85,7 +85,7 @@ fn main() { lakes, oceans, quads, - } = config.generate(sampler, |pos, (r, g, b, a)| { + } = config.generate(sampler, world.index(), |pos, (r, g, b, a)| { let i = pos.x; let j = pos.y; buf[j * W + i] = u32::from_le_bytes([b, g, r, a]); @@ -104,7 +104,7 @@ fn main() { ..config }; let mut buf = vec![0u8; 4 * len]; - config.generate(sampler, |pos, (r, g, b, a)| { + config.generate(sampler, world.index(), |pos, (r, g, b, a)| { let i = pos.x; let j = pos.y; (&mut buf[(j * x + i) * 4..]).write(&[r, g, b, a]).unwrap(); diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 7f98b5acb5..77f7d3ae08 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -48,10 +48,7 @@ impl<'a> BlockGen<'a> { close_cliffs.iter().fold( 0.0f32, |max_height, (cliff_pos, seed)| match Self::sample_column( - column_gen, - cache, - *cliff_pos, - index, + column_gen, cache, *cliff_pos, index, ) { Some(cliff_sample) if cliff_sample.is_cliffs && cliff_sample.spawn_rate > 0.5 => { let cliff_pos3d = Vec3::from(*cliff_pos); @@ -314,10 +311,10 @@ impl<'a> BlockGen<'a> { // Some(Block::new( // if on_cliff && (height * 1271.0).fract() < 0.015 { - // treasures[(height * 731.3) as usize % treasures.len()] - // } else if (height * 1271.0).fract() < 0.1 { - // flowers[(height * 0.2) as usize % flowers.len()] - // } else { + // treasures[(height * 731.3) as usize % + // treasures.len()] } else if (height * + // 1271.0).fract() < 0.1 { flowers[(height * + // 0.2) as usize % flowers.len()] } else { // grasses[(height * 103.3) as usize % grasses.len()] // }, // Rgb::broadcast(0), @@ -343,10 +340,10 @@ impl<'a> BlockGen<'a> { // Some(Block::new( // if (height * 1271.0).fract() < 0.5 { - // large_cacti[(height * 0.2) as usize % large_cacti.len()] - // } else { - // small_cacti[(height * 0.3) as usize % small_cacti.len()] - // }, + // large_cacti[(height * 0.2) as usize % + // large_cacti.len()] } else { + // small_cacti[(height * 0.3) as usize % + // small_cacti.len()] }, // Rgb::broadcast(0), // )) } else { diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index fcb599832e..9d9058b925 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -715,9 +715,7 @@ fn find_site_loc( loc = ctx.sim.get(test_loc).and_then(|c| { Some( c.downhill? - .map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| { - e / (sz as i32) - }), + .map2(TerrainChunkSize::RECT_SIZE, |e, sz: u32| e / (sz as i32)), ) }); } diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 92746650b5..5f08f73f39 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -614,7 +614,7 @@ where .unwrap_or_else(|| { max_border_river .river_kind - .and_then(|river_kind| { + .map(|river_kind| { match river_kind { RiverKind::Ocean => { let ( @@ -648,7 +648,7 @@ where let river_dist = wposf.distance(river_pos); let _river_height_factor = river_dist / (river_width * 0.5); - return Some(( + return ( true, Some((river_dist - river_width * 0.5) as f32), alt_for_river @@ -656,10 +656,10 @@ where lake_water_alt - river_gouge, alt_for_river.max(lake_water_alt), 0.0, - )); + ); } - Some(( + ( river_scale_factor <= 1.0, Some( (wposf.distance(river_pos) - river_width * 0.5) @@ -669,7 +669,7 @@ where downhill_water_alt, alt_for_river, river_scale_factor as f32, - )) + ) }, RiverKind::Lake { .. } => { let lake_dist = (max_border_river_pos.map(|e| e as f64) @@ -691,7 +691,7 @@ where || in_bounds { let gouge_factor = 0.0; - return Some(( + return ( in_bounds || downhill_water_alt .max(river_chunk.water_alt) @@ -703,16 +703,16 @@ where alt_for_river, river_scale_factor as f32 * (1.0 - gouge_factor), - )); + ); } else { - return Some(( + return ( false, Some(lake_dist as f32), alt_for_river, downhill_water_alt, alt_for_river, river_scale_factor as f32, - )); + ); }; let lake_dist = dist.y; @@ -724,7 +724,7 @@ where river_t as f32, ); if dist == Vec2::zero() { - return Some(( + return ( true, Some(lake_dist as f32), alt_for_river @@ -732,7 +732,7 @@ where lake_water_alt - river_gouge, alt_for_river.max(lake_water_alt), 0.0, - )); + ); } if lake_dist <= TerrainChunkSize::RECT_SIZE.x as f64 * 1.0 || in_bounds @@ -745,7 +745,7 @@ where let in_bounds_ = lake_dist <= TerrainChunkSize::RECT_SIZE.x as f64 * 0.5; if gouge_factor == 1.0 { - return Some(( + return ( true, Some(lake_dist as f32), alt.min(lake_water_alt - 1.0 - river_gouge), @@ -753,9 +753,9 @@ where - river_gouge, alt.max(lake_water_alt), 0.0, - )); + ); } else { - return Some(( + return ( true, None, alt_for_river, @@ -767,17 +767,17 @@ where alt_for_river, river_scale_factor as f32 * (1.0 - gouge_factor), - )); + ); } } - Some(( + ( river_scale_factor <= 1.0, Some(lake_dist as f32), alt_for_river, downhill_water_alt, alt_for_river, river_scale_factor as f32, - )) + ) }, RiverKind::River { .. } => { let (_, _, river_width, (_, (river_pos, _), _)) = @@ -785,14 +785,14 @@ where let river_dist = wposf.distance(river_pos); // FIXME: Make water altitude accurate. - Some(( + ( river_scale_factor <= 1.0, Some((river_dist - river_width * 0.5) as f32), alt_for_river, downhill_water_alt, alt_for_river, river_scale_factor as f32, - )) + ) }, } }) diff --git a/world/src/layer/mod.rs b/world/src/layer/mod.rs index 23c057d93e..72986bb1ec 100644 --- a/world/src/layer/mod.rs +++ b/world/src/layer/mod.rs @@ -105,14 +105,14 @@ pub fn apply_scatter_to<'a>( .find_map(|(i, (bk, is_underwater, f))| { let (density, patch) = f(chunk); let is_patch = patch - .map(|(wavelen, threshold)| { - index.noise.scatter_nz.get( - wpos2d - .map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0) - .into_array(), - ) < threshold as f64 - }) - .unwrap_or(false); + .map(|(wavelen, threshold)| { + index.noise.scatter_nz.get( + wpos2d + .map(|e| e as f64 / wavelen as f64 + i as f64 * 43.0) + .into_array(), + ) < threshold as f64 + }) + .unwrap_or(false); if density <= 0.0 || is_patch || !RandomField::new(i as u32) diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index e2d8bdc102..b34619c487 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -404,7 +404,7 @@ impl Floor { if area.contains_point(stair_rcenter.xy()) { let offs = Vec2::new(rng.gen_range(-1.0, 1.0), rng.gen_range(-1.0, 1.0)) .try_normalized() - .unwrap_or(Vec2::unit_y()) + .unwrap_or_else(Vec2::unit_y) * FLOOR_SIZE.x as f32 / 2.0 - 8.0; diff --git a/world/src/site/settlement/building/archetype/mod.rs b/world/src/site/settlement/building/archetype/mod.rs index d6b858ff78..d20e943ef2 100644 --- a/world/src/site/settlement/building/archetype/mod.rs +++ b/world/src/site/settlement/building/archetype/mod.rs @@ -12,6 +12,8 @@ pub trait Archetype { fn generate(rng: &mut R) -> (Self, Skeleton) where Self: Sized; + + #[allow(clippy::too_many_arguments)] fn draw( &self, pos: Vec3, diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index ea20a5df76..7b9f418965 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -232,7 +232,7 @@ impl Settlement { for _ in 0..PATH_COUNT { dir = (Vec2::new(rng.gen::() - 0.5, rng.gen::() - 0.5) * 2.0 - dir) .try_normalized() - .unwrap_or(Vec2::zero()); + .unwrap_or_else(Vec2::zero); let origin = dir.map(|e| (e * 100.0) as i32); let origin = self .land @@ -662,7 +662,7 @@ impl Settlement { } } - Some(Rgb::new(100, 105, 75).map2(Rgb::iota(), |e: u8, i: i32| { + Some(Rgb::new(100, 95, 65).map2(Rgb::iota(), |e: u8, i: i32| { e.saturating_add( (self.noise.get(Vec3::new(wpos2d.x, wpos2d.y, i * 5)) % 1) as u8, @@ -746,9 +746,9 @@ impl Settlement { for z in -8 - diff..4 + diff { let pos = Vec3::new(offs.x, offs.y, surface_z + z); - let block = vol.get(pos).ok().copied().unwrap_or(Block::empty()); + let block = vol.get(pos).ok().copied().unwrap_or_else(Block::empty); - if block.is_empty() { + if block.kind() == BlockKind::Air { break; } diff --git a/world/src/util/random.rs b/world/src/util/random.rs index 390ab51e8e..15eb502188 100644 --- a/world/src/util/random.rs +++ b/world/src/util/random.rs @@ -24,17 +24,17 @@ impl Sampler<'static> for RandomField { let mut a = self.seed; a = (a ^ 61) ^ (a >> 16); a = a.wrapping_add(a << 3); - a = a ^ pos.x; - a = a ^ (a >> 4); + a ^= pos.x; + a ^= a >> 4; a = a.wrapping_mul(0x27d4eb2d); - a = a ^ (a >> 15); - a = a ^ pos.y; + a ^= a >> 15; + a ^= pos.y; a = (a ^ 61) ^ (a >> 16); a = a.wrapping_add(a << 3); - a = a ^ (a >> 4); - a = a ^ pos.z; + a ^= a >> 4; + a ^= pos.z; a = a.wrapping_mul(0x27d4eb2d); - a = a ^ (a >> 15); + a ^= a >> 15; a } }