Remove all warnings

This commit is contained in:
Imbris 2019-09-04 19:03:49 -04:00
parent e1eccb18fd
commit 52d84248ec
19 changed files with 71 additions and 80 deletions

View File

@ -1,5 +1,5 @@
stages: stages:
- build - check
- test - test
- post-build - post-build
- executable - executable
@ -39,19 +39,19 @@ before_script:
fi; fi;
############# #############
# Build # CHECK
############# #############
build-voxygen: check-voxygen:
stage: build stage: check
image: registry.gitlab.com/veloren/veloren-docker-ci image: registry.gitlab.com/veloren/veloren-docker-ci
tags: tags:
- veloren-docker - veloren-docker
script: script:
- (cd voxygen && RUSTFLAGS="-D warnings" cargo check) - (cd voxygen && RUSTFLAGS="-D warnings" cargo check)
build-server-cli: check-server-cli:
stage: build stage: check
image: registry.gitlab.com/veloren/veloren-docker-ci image: registry.gitlab.com/veloren/veloren-docker-ci
tags: tags:
- veloren-docker - veloren-docker

View File

@ -64,7 +64,7 @@ impl Client {
let mut postbox = PostBox::to(addr)?; let mut postbox = PostBox::to(addr)?;
// Wait for initial sync // Wait for initial sync
let (mut state, entity, server_info) = match postbox.next_message() { let (state, entity, server_info) = match postbox.next_message() {
Some(ServerMsg::InitialSync { Some(ServerMsg::InitialSync {
ecs_state, ecs_state,
entity_uid, entity_uid,

View File

@ -9,10 +9,9 @@ use log::error;
use serde_json::Value; use serde_json::Value;
use std::{ use std::{
any::Any, any::Any,
env, fs::{self, File, ReadDir},
fs::{self, read_link, File, ReadDir},
io::{BufReader, Read}, io::{BufReader, Read},
path::{Path, PathBuf}, path::PathBuf,
sync::{Arc, RwLock}, sync::{Arc, RwLock},
}; };
@ -243,7 +242,7 @@ fn unpack_specifier(specifier: &str) -> PathBuf {
/// Loads a file based on the specifier and possible extensions /// Loads a file based on the specifier and possible extensions
pub fn load_file(specifier: &str, endings: &[&str]) -> Result<BufReader<File>, Error> { pub fn load_file(specifier: &str, endings: &[&str]) -> Result<BufReader<File>, Error> {
let mut path = unpack_specifier(specifier); let path = unpack_specifier(specifier);
for ending in endings { for ending in endings {
let mut path = path.clone(); let mut path = path.clone();
path.set_extension(ending); path.set_extension(ending);

View File

@ -1,5 +1,5 @@
use specs::{Component, FlaggedStorage, HashMapStorage}; use specs::{Component, FlaggedStorage, HashMapStorage};
use specs_idvs::IDVStorage; //use specs_idvs::IDVStorage;
use std::time::Duration; use std::time::Duration;
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]

View File

@ -5,7 +5,7 @@ pub mod item;
pub use self::item::{Debug, Item, Tool}; pub use self::item::{Debug, Item, Tool};
use specs::{Component, HashMapStorage, NullStorage}; use specs::{Component, HashMapStorage, NullStorage};
use specs_idvs::IDVStorage; //use specs_idvs::IDVStorage;
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Inventory { pub struct Inventory {

View File

@ -1,5 +1,5 @@
use specs::{Component, VecStorage}; use specs::{Component, VecStorage};
use std::{fmt::Debug, marker::Send, ops::Deref}; use std::marker::Send;
#[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, Hash, Serialize, Deserialize)]
pub struct Last<C: Component + PartialEq>(pub C); pub struct Last<C: Component + PartialEq>(pub C);

View File

@ -1,13 +1,12 @@
use crate::comp::Controller; use crate::comp::Controller;
use specs::{Entities, Join, System, WriteStorage}; use specs::{Join, System, WriteStorage};
use vek::*;
/// This system will allow NPCs to modify their controller /// This system will allow NPCs to modify their controller
pub struct Sys; pub struct Sys;
impl<'a> System<'a> for Sys { impl<'a> System<'a> for Sys {
type SystemData = (Entities<'a>, WriteStorage<'a, Controller>); type SystemData = WriteStorage<'a, Controller>;
fn run(&mut self, (entities, mut controllers): Self::SystemData) { fn run(&mut self, mut controllers: Self::SystemData) {
for controller in (&mut controllers).join() { for controller in (&mut controllers).join() {
*controller = Controller::default(); *controller = Controller::default();
} }

View File

@ -77,9 +77,7 @@ impl<'a> System<'a> for Sys {
}; };
if deal_damage { if deal_damage {
if let Some(Attack { time_left, applied }) = if let Some(Attack { .. }) = &character_states.get(entity).map(|c| c.action) {
&character_states.get(entity).map(|c| c.action)
{
// Go through all other entities // Go through all other entities
for (b, pos_b, ori_b, character_b, mut vel_b, stat_b) in ( for (b, pos_b, ori_b, character_b, mut vel_b, stat_b) in (
&entities, &entities,

View File

@ -5,9 +5,8 @@ use crate::{
}, },
state::DeltaTime, state::DeltaTime,
terrain::TerrainMap, terrain::TerrainMap,
vol::{ReadVol, Vox},
}; };
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage}; use specs::{Join, Read, ReadExpect, ReadStorage, System, WriteStorage};
use std::time::Duration; use std::time::Duration;
use vek::*; use vek::*;
@ -31,7 +30,6 @@ pub const MOVEMENT_THRESHOLD_VEL: f32 = 3.0;
pub struct Sys; pub struct Sys;
impl<'a> System<'a> for Sys { impl<'a> System<'a> for Sys {
type SystemData = ( type SystemData = (
Entities<'a>,
ReadExpect<'a, TerrainMap>, ReadExpect<'a, TerrainMap>,
Read<'a, DeltaTime>, Read<'a, DeltaTime>,
ReadStorage<'a, Stats>, ReadStorage<'a, Stats>,
@ -46,8 +44,7 @@ impl<'a> System<'a> for Sys {
fn run( fn run(
&mut self, &mut self,
( (
entities, _terrain,
terrain,
dt, dt,
stats, stats,
controllers, controllers,
@ -59,8 +56,7 @@ impl<'a> System<'a> for Sys {
): Self::SystemData, ): Self::SystemData,
) { ) {
// Apply movement inputs // Apply movement inputs
for (entity, stats, controller, physics, mut character, mut pos, mut vel, mut ori) in ( for (stats, controller, physics, mut character, mut _pos, mut vel, mut ori) in (
&entities,
&stats, &stats,
&controllers, &controllers,
&physics_states, &physics_states,
@ -86,8 +82,8 @@ impl<'a> System<'a> for Sys {
if character.action.is_block() || character.action.is_attack() { if character.action.is_block() || character.action.is_attack() {
vel.0 += Vec2::broadcast(dt.0) vel.0 += Vec2::broadcast(dt.0)
* controller.move_dir * controller.move_dir
* match (physics.on_ground) { * match physics.on_ground {
(true) if vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL, true if vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL,
_ => 0.0, _ => 0.0,
} }
} else { } else {

View File

@ -1,10 +1,10 @@
use { use {
crate::{ crate::{
comp::{Body, MovementState::*, Ori, PhysicsState, Pos, Scale, Stats, Vel}, comp::{Body, Ori, PhysicsState, Pos, Scale, Vel},
event::{EventBus, LocalEvent}, event::{EventBus, LocalEvent},
state::DeltaTime, state::DeltaTime,
terrain::TerrainMap, terrain::TerrainMap,
vol::{ReadVol, Vox}, vol::ReadVol,
}, },
specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage}, specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage},
vek::*, vek::*,
@ -61,7 +61,7 @@ impl<'a> System<'a> for Sys {
let mut event_emitter = event_bus.emitter(); let mut event_emitter = event_bus.emitter();
// Apply movement inputs // Apply movement inputs
for (entity, scale, b, mut pos, mut vel, mut ori) in ( for (entity, scale, _, mut pos, mut vel, mut _ori) in (
&entities, &entities,
scales.maybe(), scales.maybe(),
&bodies, &bodies,

View File

@ -1,4 +1,4 @@
use super::{Block, BlockKind}; use super::BlockKind;
use crate::{ use crate::{
assets::{self, Asset}, assets::{self, Asset},
vol::{BaseVol, ReadVol, SizedVol, Vox, WriteVol}, vol::{BaseVol, ReadVol, SizedVol, Vox, WriteVol},
@ -6,7 +6,7 @@ use crate::{
}; };
use dot_vox::DotVoxData; use dot_vox::DotVoxData;
use std::fs::File; use std::fs::File;
use std::io::{BufReader, Read}; use std::io::BufReader;
use vek::*; use vek::*;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

View File

@ -1,7 +1,7 @@
mod natural; mod natural;
use crate::{ use crate::{
column::{ColumnGen, ColumnSample, StructureData}, column::{ColumnGen, ColumnSample},
generator::{Generator, TownGen}, generator::{Generator, TownGen},
util::{HashCache, RandomField, Sampler, SamplerMut}, util::{HashCache, RandomField, Sampler, SamplerMut},
World, CONFIG, World, CONFIG,
@ -11,7 +11,6 @@ use common::{
util::saturate_srgb, util::saturate_srgb,
vol::{ReadVol, Vox}, vol::{ReadVol, Vox},
}; };
use noise::NoiseFn;
use std::ops::{Add, Div, Mul, Neg}; use std::ops::{Add, Div, Mul, Neg};
use vek::*; use vek::*;
@ -79,7 +78,7 @@ impl<'a> BlockGen<'a> {
pub fn get_z_cache(&mut self, wpos: Vec2<i32>) -> Option<ZCache<'a>> { pub fn get_z_cache(&mut self, wpos: Vec2<i32>) -> Option<ZCache<'a>> {
let BlockGen { let BlockGen {
world, world: _,
column_cache, column_cache,
column_gen, column_gen,
} = self; } = self;
@ -141,7 +140,7 @@ impl<'a> BlockGen<'a> {
let &ColumnSample { let &ColumnSample {
alt, alt,
chaos, chaos,
water_level, water_level: _,
//river, //river,
surface_color, surface_color,
sub_surface_color, sub_surface_color,
@ -166,7 +165,7 @@ impl<'a> BlockGen<'a> {
let wposf = wpos.map(|e| e as f64); let wposf = wpos.map(|e| e as f64);
let (definitely_underground, height, water_height) = let (_definitely_underground, height, water_height) =
if (wposf.z as f32) < alt - 64.0 * chaos { if (wposf.z as f32) < alt - 64.0 * chaos {
// Shortcut warping // Shortcut warping
(true, alt, CONFIG.sea_level /*water_level*/) (true, alt, CONFIG.sea_level /*water_level*/)
@ -214,7 +213,7 @@ impl<'a> BlockGen<'a> {
// let dirt_col = Rgb::new(79, 67, 60); // let dirt_col = Rgb::new(79, 67, 60);
let air = Block::empty(); let _air = Block::empty();
// let stone = Block::new(2, stone_col); // let stone = Block::new(2, stone_col);
// let surface_stone = Block::new(1, Rgb::new(200, 220, 255)); // let surface_stone = Block::new(1, Rgb::new(200, 220, 255));
// let dirt = Block::new(1, dirt_col); // let dirt = Block::new(1, dirt_col);
@ -399,7 +398,7 @@ impl<'a> ZCache<'a> {
.structures .structures
.iter() .iter()
.filter_map(|st| st.as_ref()) .filter_map(|st| st.as_ref())
.fold((0.0f32, 0.0f32), |(min, max), (st_info, st_sample)| { .fold((0.0f32, 0.0f32), |(min, max), (st_info, _st_sample)| {
let bounds = st_info.get_bounds(); let bounds = st_info.get_bounds();
let st_area = Aabr { let st_area = Aabr {
min: Vec2::from(bounds.min), min: Vec2::from(bounds.min),

View File

@ -1,4 +1,4 @@
use super::{BlockGen, StructureInfo, StructureMeta, ZCache}; use super::{BlockGen, StructureInfo, StructureMeta};
use crate::{ use crate::{
all::ForestKind, all::ForestKind,
column::{ColumnGen, ColumnSample}, column::{ColumnGen, ColumnSample},

View File

@ -4,7 +4,7 @@ use crate::{
generator::{Generator, SpawnRules, TownGen}, generator::{Generator, SpawnRules, TownGen},
sim::{LocationInfo, SimChunk, WorldSim}, sim::{LocationInfo, SimChunk, WorldSim},
util::{RandomPerm, Sampler, UnitChooser}, util::{RandomPerm, Sampler, UnitChooser},
World, CONFIG, CONFIG,
}; };
use common::{ use common::{
assets, assets,
@ -148,7 +148,8 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
let sim_chunk = sim.get(chunk_pos)?; let sim_chunk = sim.get(chunk_pos)?;
const RIVER_PROPORTION: f32 = 0.025; // Never used
//const RIVER_PROPORTION: f32 = 0.025;
/* /*
let river = dryness let river = dryness

View File

@ -5,8 +5,7 @@ use super::{Generator, SpawnRules};
use crate::{ use crate::{
block::block_from_structure, block::block_from_structure,
column::{ColumnGen, ColumnSample}, column::{ColumnGen, ColumnSample},
sim::WorldSim, util::Sampler,
util::{seed_expan, Grid, Sampler, UnitChooser},
}; };
use common::{ use common::{
assets, assets,
@ -16,7 +15,6 @@ use common::{
use hashbrown::HashSet; use hashbrown::HashSet;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use rand::prelude::*; use rand::prelude::*;
use rand_chacha::ChaChaRng;
use std::{ops::Add, sync::Arc}; use std::{ops::Add, sync::Arc};
use vek::*; use vek::*;
@ -96,14 +94,14 @@ impl<'a> Sampler<'a> for TownGen {
impl<'a> Generator<'a, TownState> for TownGen { impl<'a> Generator<'a, TownState> for TownGen {
fn get_z_limits( fn get_z_limits(
&self, &self,
town: &'a TownState, _town: &'a TownState,
wpos: Vec2<i32>, _wpos: Vec2<i32>,
sample: &ColumnSample, sample: &ColumnSample,
) -> (f32, f32) { ) -> (f32, f32) {
(sample.alt - 32.0, sample.alt + 75.0) (sample.alt - 32.0, sample.alt + 75.0)
} }
fn spawn_rules(&self, town: &'a TownState, wpos: Vec2<i32>) -> SpawnRules { fn spawn_rules(&self, _town: &'a TownState, _wpos: Vec2<i32>) -> SpawnRules {
SpawnRules { trees: false } SpawnRules { trees: false }
} }
} }
@ -234,7 +232,7 @@ impl TownVol {
let mut junctions = HashSet::new(); let mut junctions = HashSet::new();
junctions.insert(self.choose_column(rng, |_, col| col.is_road()).unwrap()); junctions.insert(self.choose_column(rng, |_, col| col.is_road()).unwrap());
for road in 0..n { for _road in 0..n {
for _ in 0..ATTEMPTS { for _ in 0..ATTEMPTS {
let start = *junctions.iter().choose(rng).unwrap(); let start = *junctions.iter().choose(rng).unwrap();
//let start = self.choose_column(rng, |pos, col| pos.map(|e| e % 2 == 0).reduce_and() && col.is_road()).unwrap(); //let start = self.choose_column(rng, |pos, col| pos.map(|e| e % 2 == 0).reduce_and() && col.is_road()).unwrap();
@ -291,10 +289,9 @@ impl TownVol {
}) })
.unwrap(); .unwrap();
let mut park = let park = self.floodfill(Some(16), [start].iter().copied().collect(), |_, col| {
self.floodfill(Some(16), [start].iter().copied().collect(), |_, col| { col.is_empty()
col.is_empty() });
});
if park.len() < 4 { if park.len() < 4 {
continue; continue;
@ -305,7 +302,8 @@ impl TownVol {
let col = self.col(cell).unwrap(); let col = self.col(cell).unwrap();
let ground = col.ground; let ground = col.ground;
for z in 0..2 { for z in 0..2 {
self.set(Vec3::new(cell.x, cell.y, ground + z), CellKind::Park.into()); let _ =
self.set(Vec3::new(cell.x, cell.y, ground + z), CellKind::Park.into());
} }
} }
@ -314,7 +312,7 @@ impl TownVol {
} }
} }
fn gen_walls(&mut self, rng: &mut impl Rng) { fn gen_walls(&mut self, _rng: &mut impl Rng) {
let mut outer = HashSet::new(); let mut outer = HashSet::new();
for i in 0..self.size().x { for i in 0..self.size().x {
outer.insert(Vec2::new(i, 0)); outer.insert(Vec2::new(i, 0));
@ -325,10 +323,10 @@ impl TownVol {
outer.insert(Vec2::new(self.size().x - 1, j)); outer.insert(Vec2::new(self.size().x - 1, j));
} }
let mut outer = self.floodfill(None, outer, |_, col| col.is_empty()); let outer = self.floodfill(None, outer, |_, col| col.is_empty());
let mut walls = HashSet::new(); let mut walls = HashSet::new();
let inner = self.floodfill( let _inner = self.floodfill(
None, None,
[self.size() / 2].iter().copied().collect(), [self.size() / 2].iter().copied().collect(),
|pos, _| { |pos, _| {
@ -371,7 +369,7 @@ impl TownVol {
let col = self.col(*wall).unwrap(); let col = self.col(*wall).unwrap();
let ground = col.ground; let ground = col.ground;
for z in -1..3 { for z in -1..3 {
self.set(Vec3::new(wall.x, wall.y, ground + z), CellKind::Wall.into()); let _ = self.set(Vec3::new(wall.x, wall.y, ground + z), CellKind::Wall.into());
} }
} }
} }
@ -385,13 +383,12 @@ impl TownVol {
match col.kind { match col.kind {
None => {} None => {}
Some(ColumnKind::Internal) => {} Some(ColumnKind::Internal) => {}
Some(ColumnKind::External) => {} //Some(ColumnKind::External) => {}
Some(ColumnKind::Road) => { Some(ColumnKind::Road) => {
for z in -1..2 { for z in -1..2 {
self.set(Vec3::new(i, j, ground + z), CellKind::Road.into()); let _ = self.set(Vec3::new(i, j, ground + z), CellKind::Road.into());
} }
} }
_ => unimplemented!(),
} }
} }
} }
@ -482,7 +479,7 @@ impl TownVol {
} }
for cell in cells { for cell in cells {
self.set(cell, CellKind::House(houses.len()).into()); let _ = self.set(cell, CellKind::House(houses.len()).into());
self.set_col_kind(Vec2::from(cell), Some(ColumnKind::Internal)); self.set_col_kind(Vec2::from(cell), Some(ColumnKind::Internal));
} }
@ -508,7 +505,7 @@ impl TownVol {
.map(TownCell::is_space) .map(TownCell::is_space)
.unwrap_or(true) .unwrap_or(true)
{ {
self.set(pos, TownCell::empty()); let _ = self.set(pos, TownCell::empty());
} }
} }
} }
@ -574,7 +571,7 @@ impl TownVol {
if let Some(module) = module { if let Some(module) = module {
let kind = this_cell.kind.clone(); let kind = this_cell.kind.clone();
self.set( let _ = self.set(
pos, pos,
TownCell { TownCell {
kind, kind,

View File

@ -16,9 +16,10 @@ pub fn unit(i: usize) -> (Vec2<i32>, Vec2<i32>) {
(UNITS[i % 4], UNITS[(i + 1) % 4]) (UNITS[i % 4], UNITS[(i + 1) % 4])
} }
pub fn gen_unit(rng: &mut impl Rng) -> (Vec2<i32>, Vec2<i32>) { // unused
unit(rng.gen_range(0, 4)) //pub fn gen_unit(rng: &mut impl Rng) -> (Vec2<i32>, Vec2<i32>) {
} // unit(rng.gen_range(0, 4))
//}
pub fn gen_dir(rng: &mut impl Rng) -> Vec2<i32> { pub fn gen_dir(rng: &mut impl Rng) -> Vec2<i32> {
UNITS[rng.gen_range(0, 4)] UNITS[rng.gen_range(0, 4)]
@ -37,6 +38,7 @@ pub fn dir_3d(i: usize) -> Vec3<i32> {
UNITS_3D[i % 6] UNITS_3D[i % 6]
} }
pub fn gen_dir_3d(rng: &mut impl Rng) -> Vec3<i32> { // unused
UNITS_3D[rng.gen_range(0, 6)] //pub fn gen_dir_3d(rng: &mut impl Rng) -> Vec3<i32> {
} // UNITS_3D[rng.gen_range(0, 6)]
//}

View File

@ -7,9 +7,9 @@ use vek::*;
#[derive(Clone)] #[derive(Clone)]
pub enum ColumnKind { pub enum ColumnKind {
Road, Road,
Wall, //Wall,
Internal, Internal,
External, // Outside the boundary wall //External, // Outside the boundary wall
} }
#[derive(Clone, Default)] #[derive(Clone, Default)]

View File

@ -21,7 +21,7 @@ pub use crate::config::CONFIG;
use crate::{ use crate::{
block::BlockGen, block::BlockGen,
column::{ColumnGen, ColumnSample}, column::{ColumnGen, ColumnSample},
util::{Sampler, SamplerMut}, util::Sampler,
}; };
use common::{ use common::{
terrain::{Block, BlockKind, TerrainChunk, TerrainChunkMeta, TerrainChunkSize}, terrain::{Block, BlockKind, TerrainChunk, TerrainChunkMeta, TerrainChunkSize},

View File

@ -104,7 +104,7 @@ pub struct WorldSim {
impl WorldSim { impl WorldSim {
pub fn generate(mut seed: u32) -> Self { pub fn generate(mut seed: u32) -> Self {
let mut seed = &mut seed; let seed = &mut seed;
let mut gen_seed = || { let mut gen_seed = || {
*seed = seed_expan::diffuse(*seed); *seed = seed_expan::diffuse(*seed);
*seed *seed
@ -162,7 +162,7 @@ impl WorldSim {
// chaos produces a value in [0.1, 1.24]. It is a meta-level factor intended to reflect how // chaos produces a value in [0.1, 1.24]. It is a meta-level factor intended to reflect how
// "chaotic" the region is--how much weird stuff is going on on this terrain. // "chaotic" the region is--how much weird stuff is going on on this terrain.
let chaos = uniform_noise(|posi, wposf| { let chaos = uniform_noise(|_posi, wposf| {
// From 0 to 1.6, but the distribution before the max is from -1 and 1, so there is a // From 0 to 1.6, but the distribution before the max is from -1 and 1, so there is a
// 50% chance that hill will end up at 0. // 50% chance that hill will end up at 0.
let hill = (0.0 let hill = (0.0
@ -252,7 +252,7 @@ impl WorldSim {
}; };
// A version of alt that is uniform over *non-seawater* (or land-adjacent seawater) chunks. // A version of alt that is uniform over *non-seawater* (or land-adjacent seawater) chunks.
let alt_no_seawater = uniform_noise(|posi, wposf| { let alt_no_seawater = uniform_noise(|posi, _wposf| {
if pure_water(posi) { if pure_water(posi) {
None None
} else { } else {
@ -436,7 +436,7 @@ impl WorldSim {
let near_towns = self.gen_ctx.town_gen.get(wpos); let near_towns = self.gen_ctx.town_gen.get(wpos);
let town = near_towns let town = near_towns
.iter() .iter()
.min_by_key(|(pos, seed)| wpos.distance_squared(*pos)); .min_by_key(|(pos, _seed)| wpos.distance_squared(*pos));
if let Some((pos, _)) = town { if let Some((pos, _)) = town {
let maybe_town = maybe_towns let maybe_town = maybe_towns