From 911acdd9db169ebc1c7503a1301a288dd89b81e6 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 6 Mar 2021 17:23:03 +0000 Subject: [PATCH] Fixed clippy warnings and fmt --- common/src/store.rs | 2 + voxygen/src/hud/map.rs | 10 ++--- voxygen/src/hud/minimap.rs | 2 - voxygen/src/scene/terrain.rs | 9 ++--- world/benches/tree.rs | 10 +++-- world/examples/site.rs | 1 - world/src/canvas.rs | 2 +- world/src/civ/mod.rs | 2 +- world/src/column/mod.rs | 8 ++-- world/src/layer/tree.rs | 13 +++--- world/src/lib.rs | 6 ++- world/src/sim/mod.rs | 9 ++--- world/src/site/mod.rs | 12 ++---- world/src/site/tree.rs | 38 +++++++++++++----- world/src/site2/gen.rs | 2 +- world/src/site2/mod.rs | 73 +++++++++++++++++++--------------- world/src/site2/plot.rs | 1 - world/src/site2/plot/castle.rs | 40 +++++++++---------- world/src/site2/plot/house.rs | 6 +-- world/src/site2/tile.rs | 22 +++++----- 20 files changed, 149 insertions(+), 119 deletions(-) diff --git a/common/src/store.rs b/common/src/store.rs index 2b819dd47d..75ce9dc427 100644 --- a/common/src/store.rs +++ b/common/src/store.rs @@ -73,6 +73,8 @@ impl Default for Store { } impl Store { + pub fn is_empty(&self) -> bool { self.len == 0 } + pub fn len(&self) -> usize { self.len } pub fn contains(&self, id: Id) -> bool { diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 72f9db6c9f..f7a6c57444 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -570,7 +570,6 @@ impl<'a> Widget for Map<'a> { SiteKind::Castle => self.imgs.mmap_site_castle, SiteKind::Cave => self.imgs.mmap_site_cave, SiteKind::Tree => self.imgs.mmap_site_tree, - _ => self.imgs.mmap_site_excl, }) .x_y_position_relative_to( state.ids.grid, @@ -584,7 +583,6 @@ impl<'a> Widget for Map<'a> { SiteKind::Castle => self.imgs.mmap_site_castle_hover, SiteKind::Cave => self.imgs.mmap_site_cave_hover, SiteKind::Tree => self.imgs.mmap_site_tree_hover, - _ => self.imgs.mmap_site_excl, }) .image_color(UI_HIGHLIGHT_0) .with_tooltip( @@ -605,7 +603,7 @@ impl<'a> Widget for Map<'a> { _ => TEXT_COLOR, }, SiteKind::Cave => TEXT_COLOR, - _ => TEXT_COLOR, + SiteKind::Tree => TEXT_COLOR, }, ); // Only display sites that are toggled on @@ -630,8 +628,10 @@ impl<'a> Widget for Map<'a> { site_btn.set(state.ids.mmap_site_icons[i], ui); } }, - _ => { - site_btn.set(state.ids.mmap_site_icons[i], ui); + SiteKind::Tree => { + if show_trees { + site_btn.set(state.ids.mmap_site_icons[i], ui); + } }, } diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index fd84aa0407..ab0d64c9eb 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -304,7 +304,6 @@ impl<'a> Widget for MiniMap<'a> { SiteKind::Castle => self.imgs.mmap_site_castle_bg, SiteKind::Cave => self.imgs.mmap_site_cave_bg, SiteKind::Tree => self.imgs.mmap_site_tree, - _ => self.imgs.mmap_site_excl, }) .x_y_position_relative_to( state.ids.grid, @@ -335,7 +334,6 @@ impl<'a> Widget for MiniMap<'a> { SiteKind::Castle => self.imgs.mmap_site_castle, SiteKind::Cave => self.imgs.mmap_site_cave, SiteKind::Tree => self.imgs.mmap_site_tree, - _ => self.imgs.mmap_site_excl, }) .middle_of(state.ids.mmap_site_icons_bgs[i]) .w_h(20.0, 20.0) diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index c69a98aa62..725141cb1a 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -515,7 +515,7 @@ impl Terrain { const AMBIANCE: f32 = 0.15; // 0-1, the proportion of light that should illuminate the rear of an object - let (bias, total, max) = Spiral2d::new() + let (bias, total) = Spiral2d::new() .take(9) .map(|rpos| { let chunk_pos = wpos_chunk + rpos; @@ -535,14 +535,13 @@ impl Terrain { }) .flatten() .fold( - (Vec3::broadcast(0.001), 0.0, 0.0f32), - |(bias, total, max), (lpos, level)| { + (Vec3::broadcast(0.001), 0.0), + |(bias, total), (lpos, level)| { let rpos = lpos.map(|e| e as f32 + 0.5) - wpos; let level = (*level as f32 - rpos.magnitude()).max(0.0) / SUNLIGHT as f32; ( bias + rpos.try_normalized().unwrap_or_else(Vec3::zero) * level, total + level, - max.max(level), ) }, ); @@ -643,7 +642,7 @@ impl Terrain { // be meshed span!(guard, "Add chunks with modified blocks to mesh todo list"); // TODO: would be useful if modified blocks were grouped by chunk - for (&pos, &block) in scene_data.state.terrain_changes().modified_blocks.iter() { + for (&pos, &_block) in scene_data.state.terrain_changes().modified_blocks.iter() { // TODO: Be cleverer about this to avoid remeshing all neighbours. There are a // few things that can create an 'effect at a distance'. These are // as follows: diff --git a/world/benches/tree.rs b/world/benches/tree.rs index ba91d76ae5..291c30e792 100644 --- a/world/benches/tree.rs +++ b/world/benches/tree.rs @@ -1,4 +1,5 @@ -use criterion::{black_box, criterion_group, criterion_main, BatchSize, Benchmark, Criterion}; +use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion}; +use rand::prelude::*; use veloren_world::layer::tree::{ProceduralTree, TreeConfig}; fn tree(c: &mut Criterion) { @@ -6,7 +7,10 @@ fn tree(c: &mut Criterion) { let mut i = 0; b.iter(|| { i += 1; - black_box(ProceduralTree::generate(TreeConfig::OAK, i)); + black_box(ProceduralTree::generate( + TreeConfig::oak(&mut thread_rng(), 1.0), + &mut thread_rng(), + )); }); }); @@ -15,7 +19,7 @@ fn tree(c: &mut Criterion) { b.iter_batched( || { i += 1; - ProceduralTree::generate(TreeConfig::OAK, i) + ProceduralTree::generate(TreeConfig::oak(&mut thread_rng(), 1.0), &mut thread_rng()) }, |tree| { let bounds = tree.get_bounds(); diff --git a/world/examples/site.rs b/world/examples/site.rs index b55e63026e..a731dcdc52 100644 --- a/world/examples/site.rs +++ b/world/examples/site.rs @@ -1,4 +1,3 @@ -use structopt::StructOpt; use svg_fmt::*; use veloren_world::site2::test_site; diff --git a/world/src/canvas.rs b/world/src/canvas.rs index 940ef051db..f7a8b22300 100644 --- a/world/src/canvas.rs +++ b/world/src/canvas.rs @@ -68,7 +68,7 @@ impl<'a> Canvas<'a> { .get(pos - self.wpos()) .ok() .copied() - .unwrap_or(Block::empty()) + .unwrap_or_else(Block::empty) } pub fn set(&mut self, pos: Vec3, block: Block) { diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index ef45d370c1..628d1536c9 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -108,7 +108,7 @@ impl Civs { attempt(5, || { let (kind, size) = match ctx.rng.gen_range(0..64) { 0..=4 => (SiteKind::Castle, 3), - 5..=28 => (SiteKind::Refactor, 6), + // 5..=28 => (SiteKind::Refactor, 6), 29..=31 => (SiteKind::Tree, 4), _ => (SiteKind::Dungeon, 0), }; diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 5719b6a5ca..4e13675ff7 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -69,10 +69,10 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { let sim = &self.sim; - let turb = Vec2::new( - sim.gen_ctx.turb_x_nz.get((wposf.div(48.0)).into_array()) as f32, - sim.gen_ctx.turb_y_nz.get((wposf.div(48.0)).into_array()) as f32, - ) * 12.0; + // let turb = Vec2::new( + // sim.gen_ctx.turb_x_nz.get((wposf.div(48.0)).into_array()) as f32, + // sim.gen_ctx.turb_y_nz.get((wposf.div(48.0)).into_array()) as f32, + // ) * 12.0; let wposf_turb = wposf; // + turb.map(|e| e as f64); let chaos = sim.get_interpolated(wpos, |chunk| chunk.chaos)?; diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 80b637c990..5082d1f61e 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -333,7 +333,7 @@ impl TreeConfig { } } - pub fn giant(rng: &mut impl Rng, scale: f32, inhabited: bool) -> Self { + pub fn giant(_rng: &mut impl Rng, scale: f32, inhabited: bool) -> Self { let log_scale = 1.0 + scale.log2().max(0.0); Self { @@ -380,7 +380,6 @@ impl ProceduralTree { 0, None, rng, - true, ); this.trunk_idx = trunk_idx; @@ -391,6 +390,7 @@ impl ProceduralTree { // returning the index and AABB of the branch. This AABB gets propagated // down to the parent and is used later during sampling to cull the branches to // be sampled. + #[allow(clippy::too_many_arguments)] fn add_branch( &mut self, config: &TreeConfig, @@ -401,7 +401,6 @@ impl ProceduralTree { depth: usize, sibling_idx: Option, rng: &mut impl Rng, - has_stairs: bool, ) -> (usize, Aabb) { let end = start + dir * branch_len; let line = LineSegment3 { start, end }; @@ -412,7 +411,10 @@ impl ProceduralTree { 0.0 }; - let has_stairs = /*has_stairs &&*/ config.inhabited && depth < config.max_depth && branch_radius > 6.5 && start.xy().distance(end.xy()) < (start.z - end.z).abs() * 1.5; + let has_stairs = config.inhabited + && depth < config.max_depth + && branch_radius > 6.5 + && start.xy().distance(end.xy()) < (start.z - end.z).abs() * 1.5; let bark_radius = if has_stairs { 5.0 } else { 0.0 } + wood_radius * 0.25; // The AABB that covers this branch, along with wood and leaves that eminate @@ -477,7 +479,6 @@ impl ProceduralTree { depth + 1, child_idx, rng, - has_stairs, ); child_idx = Some(branch_idx); // Parent branches AABBs include the AABBs of child branches to allow for @@ -523,7 +524,7 @@ impl ProceduralTree { // within its AABB if branch.aabb.contains_point(pos) { // Probe this branch - let (this, d2) = branch.is_branch_or_leaves_at(pos, parent); + let (this, _d2) = branch.is_branch_or_leaves_at(pos, parent); let siblings = branch_or_leaves | Vec4::from(this); diff --git a/world/src/lib.rs b/world/src/lib.rs index 043db27176..c3219fe5a5 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,6 +1,10 @@ #![deny(unsafe_code)] #![allow(incomplete_features)] -#![allow(clippy::option_map_unit_fn)] +#![allow( + clippy::option_map_unit_fn, + clippy::blocks_in_if_conditions, + clippy::too_many_arguments +)] #![deny(clippy::clone_on_ref_ptr)] #![feature( arbitrary_enum_discriminant, diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 2600672950..9458de6532 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -29,8 +29,8 @@ use crate::{ column::ColumnGen, site::Site, util::{ - seed_expan, DHashSet, FastNoise, FastNoise2d, RandomField, RandomPerm, Sampler, - StructureGen2d, CARDINALS, LOCALITY, NEIGHBORS, + seed_expan, DHashSet, FastNoise, FastNoise2d, RandomField, Sampler, StructureGen2d, + CARDINALS, LOCALITY, NEIGHBORS, }, IndexRef, CONFIG, }; @@ -1570,15 +1570,14 @@ impl WorldSim { // Vec2::new(rng.gen_range(-16..17), rng.gen_range(-16..17)); } for cliff in cliffs { - let alt = self.get(cliff).map_or(0.0, |c| c.alt); Spiral2d::new() .take((4usize * 2 + 1).pow(2)) .for_each(|rpos| { let dist = rpos.map(|e| e as f32).magnitude(); if let Some(c) = self.get_mut(cliff + rpos) { let warp = 1.0 / (1.0 + dist); - c.tree_density *= (1.0 - warp); - c.cliff_height = Lerp::lerp(44.0, 0.0, (-1.0 + dist / 3.5)); + c.tree_density *= 1.0 - warp; + c.cliff_height = Lerp::lerp(44.0, 0.0, -1.0 + dist / 3.5); } }); } diff --git a/world/src/site/mod.rs b/world/src/site/mod.rs index faf588af3f..2f7ed2a7e3 100644 --- a/world/src/site/mod.rs +++ b/world/src/site/mod.rs @@ -12,12 +12,8 @@ pub use self::{ settlement::Settlement, tree::Tree, }; -use crate::{column::ColumnSample, site2, Canvas, IndexRef}; -use common::{ - generation::ChunkSupplement, - terrain::Block, - vol::{BaseVol, ReadVol, RectSizedVol, WriteVol}, -}; +use crate::{column::ColumnSample, site2, Canvas}; +use common::generation::ChunkSupplement; use rand::Rng; use serde::Deserialize; use vek::*; @@ -121,8 +117,8 @@ impl Site { SiteKind::Settlement(s) => s.name(), SiteKind::Dungeon(d) => d.name(), SiteKind::Castle(c) => c.name(), - SiteKind::Refactor(s) => "Town", - SiteKind::Tree(t) => "Tree", + SiteKind::Refactor(_) => "Town", + SiteKind::Tree(_) => "Giant Tree", } } diff --git a/world/src/site/tree.rs b/world/src/site/tree.rs index 965e8e0670..a050dac93c 100644 --- a/world/src/site/tree.rs +++ b/world/src/site/tree.rs @@ -1,7 +1,7 @@ use crate::{ layer::tree::{ProceduralTree, TreeConfig}, - util::{FastNoise, Sampler}, site::SpawnRules, + util::{FastNoise, Sampler}, Canvas, Land, }; use common::terrain::{Block, BlockKind}; @@ -38,7 +38,7 @@ impl Tree { } } - pub fn render(&self, canvas: &mut Canvas, dynamic_rng: &mut impl Rng) { + pub fn render(&self, canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) { let nz = FastNoise::new(self.seed); canvas.foreach_col(|canvas, wpos2d, col| { @@ -50,18 +50,38 @@ impl Tree { return; } + let mut above = true; for z in (bounds.min.z..bounds.max.z + 1).rev() { let wpos = wpos2d.with_z(self.alt + z); let rposf = (wpos - self.origin.with_z(self.alt)).map(|e| e as f32 + 0.5); let (branch, leaves, _, _) = self.tree.is_branch_or_leaves_at(rposf); - if leaves { - let dark = Rgb::new(10, 70, 50).map(|e| e as f32); - let light = Rgb::new(80, 140, 10).map(|e| e as f32); - let leaf_col = Lerp::lerp(dark, light, nz.get(rposf.map(|e| e as f64) * 0.05) * 0.5 + 0.5); - canvas.set(wpos, Block::new(BlockKind::Leaves, leaf_col.map(|e| e as u8))); - } else if branch { - canvas.set(wpos, Block::new(BlockKind::Wood, Rgb::new(80, 32, 0))); + + if branch || leaves { + if above && col.snow_cover { + canvas.set( + wpos + Vec3::unit_z(), + Block::new(BlockKind::Snow, Rgb::new(255, 255, 255)), + ); + } + + if leaves { + let dark = Rgb::new(10, 70, 50).map(|e| e as f32); + let light = Rgb::new(80, 140, 10).map(|e| e as f32); + let leaf_col = Lerp::lerp( + dark, + light, + nz.get(rposf.map(|e| e as f64) * 0.05) * 0.5 + 0.5, + ); + canvas.set( + wpos, + Block::new(BlockKind::Leaves, leaf_col.map(|e| e as u8)), + ); + } else if branch { + canvas.set(wpos, Block::new(BlockKind::Wood, Rgb::new(80, 32, 0))); + } + + above = true; } } }); diff --git a/world/src/site2/gen.rs b/world/src/site2/gen.rs index f5522d113b..af81fbec7a 100644 --- a/world/src/site2/gen.rs +++ b/world/src/site2/gen.rs @@ -129,7 +129,7 @@ pub trait Structure { fn render_collect(&self, site: &Site) -> (Store, Vec<(Id, Fill)>) { let mut tree = Store::default(); let mut fills = Vec::new(); - let root = self.render(site, |p| tree.insert(p), |p, f| fills.push((p, f))); + self.render(site, |p| tree.insert(p), |p, f| fills.push((p, f))); (tree, fills) } } diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index 3c6c02f029..4587ad2e4f 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -5,18 +5,19 @@ mod tile; use self::{ gen::{Fill, Primitive, Structure}, plot::{Plot, PlotKind}, - tile::{HazardKind, Tile, TileGrid, TileKind, KeepKind, Ori, TILE_SIZE}, + tile::{HazardKind, Ori, Tile, TileGrid, TileKind, TILE_SIZE}, }; use crate::{ site::SpawnRules, - util::{attempt, DHashSet, Grid, CARDINALS, LOCALITY, SQUARE_4, SQUARE_9}, + util::{attempt, DHashSet, Grid, CARDINALS, SQUARE_4, SQUARE_9}, Canvas, Land, }; use common::{ astar::Astar, lottery::Lottery, spiral::Spiral2d, - store::{Id, Store}, terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize}, + store::{Id, Store}, + terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize}, vol::RectVolSize, }; use hashbrown::hash_map::DefaultHashBuilder; @@ -62,7 +63,6 @@ impl Site { self.wpos_tile(wpos + rpos * tile::TILE_SIZE as i32) .is_empty() }), - ..SpawnRules::default() } } @@ -193,12 +193,10 @@ impl Site { let search_pos = if rng.gen() { self.plot(*self.plazas.choose(rng)?).root_tile + (dir * 4.0).map(|e: f32| e.round() as i32) + } else if let PlotKind::Road(path) = &self.plot(*self.roads.choose(rng)?).kind { + *path.nodes().choose(rng)? + (dir * 1.0).map(|e: f32| e.round() as i32) } else { - if let PlotKind::Road(path) = &self.plot(*self.roads.choose(rng)?).kind { - *path.nodes().choose(rng)? + (dir * 1.0).map(|e: f32| e.round() as i32) - } else { - unreachable!() - } + unreachable!() }; self.find_aabr(search_pos, area_range, min_dims) @@ -360,14 +358,11 @@ impl Site { * rng.gen_range(16.0..48.0)) .map(|e| e as i32); - if site.plazas.iter().all(|&p| { - site.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2) - }) && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max() - { - Some(tile) - } else { - None - } + Some(tile).filter(|_| { + site.plazas.iter().all(|&p| { + site.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2) + }) && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max() + }) }) .unwrap_or_else(Vec2::zero); @@ -444,21 +439,33 @@ impl Site { plot: Some(plot), }, ); - site.tiles.set(Vec2::new(aabr.center().x + 2, aabr.center().y + 2), tower.clone()); - site.tiles.set(Vec2::new(aabr.center().x + 2, aabr.center().y - 3), tower.clone()); - site.tiles.set(Vec2::new(aabr.center().x - 3, aabr.center().y + 2), tower.clone()); - site.tiles.set(Vec2::new(aabr.center().x - 3, aabr.center().y - 3), tower.clone()); + site.tiles.set( + Vec2::new(aabr.center().x + 2, aabr.center().y + 2), + tower.clone(), + ); + site.tiles.set( + Vec2::new(aabr.center().x + 2, aabr.center().y - 3), + tower.clone(), + ); + site.tiles.set( + Vec2::new(aabr.center().x - 3, aabr.center().y + 2), + tower.clone(), + ); + site.tiles.set( + Vec2::new(aabr.center().x - 3, aabr.center().y - 3), + tower.clone(), + ); site.blit_aabr( - Aabr { - min: aabr.center() - 2, - max: aabr.center() + 2, - }, - Tile { - kind: TileKind::Keep(tile::KeepKind::Middle), - plot: Some(plot), - }, - ); + Aabr { + min: aabr.center() - 2, + max: aabr.center() + 2, + }, + Tile { + kind: TileKind::Keep(tile::KeepKind::Middle), + plot: Some(plot), + }, + ); castles += 1; } @@ -486,7 +493,7 @@ impl Site { self.origin + tile * tile::TILE_SIZE as i32 + tile::TILE_SIZE as i32 / 2 } - pub fn render_tile(&self, canvas: &mut Canvas, dynamic_rng: &mut impl Rng, tpos: Vec2) { + pub fn render_tile(&self, canvas: &mut Canvas, _dynamic_rng: &mut impl Rng, tpos: Vec2) { let tile = self.tiles.get(tpos); let twpos = self.tile_wpos(tpos); let border = TILE_SIZE as i32; @@ -497,6 +504,7 @@ impl Site { }) .flatten(); + #[allow(clippy::single_match)] match &tile.kind { TileKind::Plaza => { let near_roads = CARDINALS.iter().filter_map(|rpos| { @@ -510,7 +518,7 @@ impl Site { } }); - cols.for_each(|(wpos2d, offs)| { + cols.for_each(|(wpos2d, _offs)| { let wpos2df = wpos2d.map(|e| e as f32); let dist = near_roads .clone() @@ -584,6 +592,7 @@ impl Site { let tile = self.wpos_tile(wpos2d); let seed = tile.plot.map_or(0, |p| self.plot(p).seed); + #[allow(clippy::single_match)] match tile.kind { TileKind::Field /*| TileKind::Road*/ => (-4..5).for_each(|z| canvas.map( Vec3::new(wpos2d.x, wpos2d.y, col.alt as i32 + z), diff --git a/world/src/site2/plot.rs b/world/src/site2/plot.rs index 57b55084ca..3b0bcaa1f1 100644 --- a/world/src/site2/plot.rs +++ b/world/src/site2/plot.rs @@ -26,7 +26,6 @@ impl Plot { } pub enum PlotKind { - Field, House(House), Plaza, Castle(Castle), diff --git a/world/src/site2/plot/castle.rs b/world/src/site2/plot/castle.rs index 0d24e985cb..6a185428c5 100644 --- a/world/src/site2/plot/castle.rs +++ b/world/src/site2/plot/castle.rs @@ -1,28 +1,28 @@ use super::*; -use crate::{util::SQUARE_4, Land}; -use common::terrain::{Block, BlockKind, SpriteKind}; +use crate::Land; +use common::terrain::{Block, BlockKind}; use rand::prelude::*; use vek::*; pub struct Castle { - entrance_tile: Vec2, + _entrance_tile: Vec2, tile_aabr: Aabr, - bounds: Aabr, + _bounds: Aabr, alt: i32, } impl Castle { pub fn generate( land: &Land, - rng: &mut impl Rng, + _rng: &mut impl Rng, site: &Site, entrance_tile: Vec2, tile_aabr: Aabr, ) -> Self { Self { - entrance_tile, + _entrance_tile: entrance_tile, tile_aabr, - bounds: Aabr { + _bounds: Aabr { min: site.tile_wpos(tile_aabr.min), max: site.tile_wpos(tile_aabr.max), }, @@ -39,20 +39,20 @@ impl Structure for Castle { mut fill: G, ) { let wall_height = 24; - let thickness = 12; + let _thickness = 12; let parapet_height = 2; let parapet_width = 1; - let downwards = 40; + let _downwards = 40; let tower_height = 12; let keep_levels = 3; let keep_level_height = 8; - let keep_height = wall_height + keep_levels * keep_level_height + 1; + let _keep_height = wall_height + keep_levels * keep_level_height + 1; for x in 0..self.tile_aabr.size().w { for y in 0..self.tile_aabr.size().h { let tile_pos = self.tile_aabr.min + Vec2::new(x, y); - let wpos_center = site.tile_center_wpos(tile_pos); + let _wpos_center = site.tile_center_wpos(tile_pos); let wpos = site.tile_wpos(tile_pos); let ori = if x == 0 || x == self.tile_aabr.size().w - 1 { Vec2::new(1, 0) @@ -71,7 +71,7 @@ impl Structure for Castle { }; let ori_tower = ori_tower_x + ori_tower_y; match site.tiles.get(tile_pos).kind.clone() { - TileKind::Wall(orientation) => { + TileKind::Wall(_ori) => { let wall = prim(Primitive::Aabb(Aabb { min: wpos.with_z(self.alt), max: (wpos + 6).with_z(self.alt + wall_height + parapet_height), @@ -115,7 +115,7 @@ impl Structure for Castle { })); let tower_lower_inner_x = prim(Primitive::Aabb(Aabb { min: Vec3::new( - wpos.x + 1 * ori_tower.x, + wpos.x + ori_tower.x, wpos.y + parapet_width, self.alt + wall_height, ), @@ -128,7 +128,7 @@ impl Structure for Castle { let tower_lower_inner_y = prim(Primitive::Aabb(Aabb { min: Vec3::new( wpos.x + parapet_width, - wpos.y + 1 * ori_tower.y, + wpos.y + ori_tower.y, self.alt + wall_height, ), max: Vec3::new( @@ -147,19 +147,19 @@ impl Structure for Castle { min: Vec3::new( wpos.x - 1, wpos.y - 1, - self.alt + wall_height + tower_height - 3 as i32, + self.alt + wall_height + tower_height - 3i32, ), max: Vec3::new( wpos.x + 7, wpos.y + 7, - self.alt + wall_height + tower_height - 1 as i32, + self.alt + wall_height + tower_height - 1i32, ), })); let tower_upper2 = prim(Primitive::Aabb(Aabb { min: Vec3::new( wpos.x - 2, wpos.y - 2, - self.alt + wall_height + tower_height - 1 as i32, + self.alt + wall_height + tower_height - 1i32, ), max: Vec3::new( wpos.x + 8, @@ -209,11 +209,11 @@ impl Structure for Castle { } }, tile::KeepKind::Corner => {}, - tile::KeepKind::Wall(orientation) => { + tile::KeepKind::Wall(_ori) => { for i in 0..keep_levels + 1 { - let height = keep_level_height * i; + let _height = keep_level_height * i; // TODO clamp value in case of big heights - let window_height = keep_level_height - 3; + let _window_height = keep_level_height - 3; } }, } diff --git a/world/src/site2/plot/house.rs b/world/src/site2/plot/house.rs index b9a32ce2a7..7bc85fc8c0 100644 --- a/world/src/site2/plot/house.rs +++ b/world/src/site2/plot/house.rs @@ -1,11 +1,11 @@ use super::*; -use crate::{util::SQUARE_4, Land}; +use crate::Land; use common::terrain::{Block, BlockKind, SpriteKind}; use rand::prelude::*; use vek::*; pub struct House { - door_tile: Vec2, + _door_tile: Vec2, tile_aabr: Aabr, bounds: Aabr, alt: i32, @@ -22,7 +22,7 @@ impl House { tile_aabr: Aabr, ) -> Self { Self { - door_tile, + _door_tile: door_tile, tile_aabr, bounds: Aabr { min: site.tile_wpos(tile_aabr.min), diff --git a/world/src/site2/tile.rs b/world/src/site2/tile.rs index 3f82ad5245..ef757f9887 100644 --- a/world/src/site2/tile.rs +++ b/world/src/site2/tile.rs @@ -7,6 +7,7 @@ pub const TILE_SIZE: u32 = 6; pub const ZONE_SIZE: u32 = 16; pub const ZONE_RADIUS: u32 = 16; pub const TILE_RADIUS: u32 = ZONE_SIZE * ZONE_RADIUS; +#[allow(dead_code)] pub const MAX_BLOCK_RADIUS: u32 = TILE_SIZE * TILE_RADIUS; pub struct TileGrid { @@ -48,7 +49,7 @@ impl TileGrid { Grid::populate_from(Vec2::broadcast(ZONE_SIZE as i32), |_| None) }) .get_mut(tpos.map(|e| e.rem_euclid(ZONE_SIZE as i32))) - .map(|tile| tile.get_or_insert_with(|| Tile::empty())) + .map(|tile| tile.get_or_insert_with(Tile::empty)) }) } @@ -87,15 +88,14 @@ impl TileGrid { let mut last_growth = 0; for i in 0..32 { - if i - last_growth >= 4 { - break; - } else if aabr.size().product() - + if i % 2 == 0 { - aabr.size().h - } else { - aabr.size().w - } - > area_range.end as i32 + if i - last_growth >= 4 + || aabr.size().product() + + if i % 2 == 0 { + aabr.size().h + } else { + aabr.size().w + } + > area_range.end as i32 { break; } else { @@ -239,5 +239,5 @@ pub enum Ori { } impl Ori { - pub fn dir(self) -> Vec2 {CARDINALS[self as u8 as usize]} + pub fn dir(self) -> Vec2 { CARDINALS[self as u8 as usize] } }