mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
stricten some rules and fix some clippy warnings
This commit is contained in:
parent
f3f08936d8
commit
201a5ac2c7
@ -14,7 +14,7 @@ too-many-arguments-threshold = 15
|
|||||||
|
|
||||||
# `many_single_char_names` often triggers for geometry or physics code with an
|
# `many_single_char_names` often triggers for geometry or physics code with an
|
||||||
# associated diagram, where the short names are points in the diagram.
|
# associated diagram, where the short names are points in the diagram.
|
||||||
single-char-binding-names-threshold = 4294967295
|
single-char-binding-names-threshold = 8
|
||||||
|
|
||||||
# `type_complexity` often triggers for the RHS of an associated type: it's
|
# `type_complexity` often triggers for the RHS of an associated type: it's
|
||||||
# telling you that a type is complicated enough to need a name, at the point
|
# telling you that a type is complicated enough to need a name, at the point
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
#![allow(clippy::new_without_default)]
|
|
||||||
#![feature(generic_const_exprs, const_fn_floating_point_arithmetic)]
|
#![feature(generic_const_exprs, const_fn_floating_point_arithmetic)]
|
||||||
pub mod msg;
|
pub mod msg;
|
||||||
pub mod sync;
|
pub mod sync;
|
||||||
|
@ -137,6 +137,7 @@ pub struct CompSyncPackage<P: CompPacket> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<P: CompPacket> CompSyncPackage<P> {
|
impl<P: CompPacket> CompSyncPackage<P> {
|
||||||
|
#[allow(clippy::new_without_default)]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
comp_updates: Vec::new(),
|
comp_updates: Vec::new(),
|
||||||
|
@ -113,6 +113,7 @@ impl Segment {
|
|||||||
pub struct DynaUnionizer<V: Vox>(Vec<(Dyna<V, ()>, Vec3<i32>)>);
|
pub struct DynaUnionizer<V: Vox>(Vec<(Dyna<V, ()>, Vec3<i32>)>);
|
||||||
|
|
||||||
impl<V: Vox + Copy> DynaUnionizer<V> {
|
impl<V: Vox + Copy> DynaUnionizer<V> {
|
||||||
|
#[allow(clippy::new_without_default)]
|
||||||
pub fn new() -> Self { DynaUnionizer(Vec::new()) }
|
pub fn new() -> Self { DynaUnionizer(Vec::new()) }
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
#![type_length_limit = "1664759"]
|
#![type_length_limit = "1664759"]
|
||||||
#![allow(
|
#![allow(clippy::option_map_unit_fn)]
|
||||||
clippy::erasing_op,
|
|
||||||
clippy::identity_op,
|
|
||||||
clippy::new_without_default,
|
|
||||||
clippy::option_map_unit_fn
|
|
||||||
)]
|
|
||||||
#![deny(clippy::clone_on_ref_ptr)]
|
#![deny(clippy::clone_on_ref_ptr)]
|
||||||
#![feature(
|
#![feature(
|
||||||
associated_type_defaults,
|
associated_type_defaults,
|
||||||
|
@ -13,6 +13,7 @@ pub enum Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Region consisting of a bitset of entities within it
|
/// Region consisting of a bitset of entities within it
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Region {
|
pub struct Region {
|
||||||
// Use specs bitset for simplicity (and joinability)
|
// Use specs bitset for simplicity (and joinability)
|
||||||
bitset: BitSet,
|
bitset: BitSet,
|
||||||
@ -23,14 +24,6 @@ pub struct Region {
|
|||||||
events: Vec<Event>,
|
events: Vec<Event>,
|
||||||
}
|
}
|
||||||
impl Region {
|
impl Region {
|
||||||
fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
bitset: BitSet::new(),
|
|
||||||
neighbors: [None; 8],
|
|
||||||
events: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks if the region contains no entities and no events
|
/// Checks if the region contains no entities and no events
|
||||||
fn removable(&self) -> bool { self.bitset.is_empty() && self.events.is_empty() }
|
fn removable(&self) -> bool { self.bitset.is_empty() && self.events.is_empty() }
|
||||||
|
|
||||||
@ -70,6 +63,7 @@ const NEIGHBOR_OFFSETS: [Vec2<i32>; 8] = [
|
|||||||
Vec2::new(1, 1),
|
Vec2::new(1, 1),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
// TODO generic region size (16x16 for now)
|
// TODO generic region size (16x16 for now)
|
||||||
// TODO compare to sweep and prune approach
|
// TODO compare to sweep and prune approach
|
||||||
/// A region system that tracks where entities are
|
/// A region system that tracks where entities are
|
||||||
@ -87,19 +81,11 @@ pub struct RegionMap {
|
|||||||
// (region, entity)
|
// (region, entity)
|
||||||
entities_to_remove: Vec<(usize, u32)>,
|
entities_to_remove: Vec<(usize, u32)>,
|
||||||
// Track the current tick, used to enable not checking everything every tick
|
// Track the current tick, used to enable not checking everything every tick
|
||||||
|
// rate is dependent on the rate the caller calls region_manager.tick()
|
||||||
tick: u64,
|
tick: u64,
|
||||||
}
|
}
|
||||||
impl RegionMap {
|
impl RegionMap {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self { Self::default() }
|
||||||
Self {
|
|
||||||
regions: IndexMap::default(),
|
|
||||||
tracked_entities: BitSet::new(),
|
|
||||||
entities_to_move: Vec::new(),
|
|
||||||
entities_to_remove: Vec::new(),
|
|
||||||
// rate is dependent on the rate the caller calls region_manager.tick()
|
|
||||||
tick: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO maintain within a system?
|
// TODO maintain within a system?
|
||||||
// TODO special case large entities
|
// TODO special case large entities
|
||||||
@ -268,7 +254,7 @@ impl RegionMap {
|
|||||||
/// Adds a new region
|
/// Adds a new region
|
||||||
/// Returns the index of the region in the index map
|
/// Returns the index of the region in the index map
|
||||||
fn insert(&mut self, key: Vec2<i32>) -> usize {
|
fn insert(&mut self, key: Vec2<i32>) -> usize {
|
||||||
let (index, old_region) = self.regions.insert_full(key, Region::new());
|
let (index, old_region) = self.regions.insert_full(key, Region::default());
|
||||||
if old_region.is_some() {
|
if old_region.is_some() {
|
||||||
panic!("Inserted a region that already exists!!!(this should never need to occur");
|
panic!("Inserted a region that already exists!!!(this should never need to occur");
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,22 @@ pub struct Spiral2d {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Spiral2d {
|
impl Spiral2d {
|
||||||
|
#[allow(clippy::new_without_default)]
|
||||||
/// Creates a new spiral starting at the origin
|
/// Creates a new spiral starting at the origin
|
||||||
pub fn new() -> Self { Self { layer: 0, i: 0 } }
|
pub fn new() -> Self { Self { layer: 0, i: 0 } }
|
||||||
|
|
||||||
/// Creates an iterator over points in a spiral starting at the origin and
|
/// Creates an iterator over points in a spiral starting at the origin and
|
||||||
/// going out to some radius
|
/// going out to some radius
|
||||||
pub fn radius(self, radius: i32) -> impl Iterator<Item = Vec2<i32>> {
|
pub fn with_radius(radius: i32) -> impl Iterator<Item = Vec2<i32>> {
|
||||||
self.take((radius * 2 + 1).pow(2) as usize)
|
Self::new()
|
||||||
|
.take((radius * 2 + 1).pow(2) as usize)
|
||||||
.filter(move |pos| pos.magnitude_squared() < (radius + 1).pow(2))
|
.filter(move |pos| pos.magnitude_squared() < (radius + 1).pow(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an iterator over points in the edge of a circle of some radius
|
/// Creates an iterator over points in the edge of a circle of some radius
|
||||||
pub fn edge_radius(self, radius: i32) -> impl Iterator<Item = Vec2<i32>> {
|
pub fn with_edge_radius(radius: i32) -> impl Iterator<Item = Vec2<i32>> {
|
||||||
self.take((radius * 2 + 1).pow(2) as usize)
|
Self::new()
|
||||||
|
.take((radius * 2 + 1).pow(2) as usize)
|
||||||
.filter(move |pos| pos.magnitude_squared() < (radius + 1).pow(2))
|
.filter(move |pos| pos.magnitude_squared() < (radius + 1).pow(2))
|
||||||
.filter(move |pos| pos.magnitude_squared() >= radius.pow(2))
|
.filter(move |pos| pos.magnitude_squared() >= radius.pow(2))
|
||||||
}
|
}
|
||||||
@ -30,6 +33,7 @@ impl Spiral2d {
|
|||||||
impl Iterator for Spiral2d {
|
impl Iterator for Spiral2d {
|
||||||
type Item = Vec2<i32>;
|
type Item = Vec2<i32>;
|
||||||
|
|
||||||
|
#[allow(clippy::erasing_op, clippy::identity_op)]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
let layer_size = (self.layer * 8 + 4 * self.layer.min(1) - 4).max(1);
|
let layer_size = (self.layer * 8 + 4 * self.layer.min(1) - 4).max(1);
|
||||||
if self.i >= layer_size {
|
if self.i >= layer_size {
|
||||||
|
@ -85,7 +85,7 @@ impl CharacterBehavior for Data {
|
|||||||
// 1 added to make range correct, too lazy to add 1 to both variables above
|
// 1 added to make range correct, too lazy to add 1 to both variables above
|
||||||
let radius = radius + 1;
|
let radius = radius + 1;
|
||||||
// Creates a spiral iterator for the newly achieved radius
|
// Creates a spiral iterator for the newly achieved radius
|
||||||
let spiral = Spiral2d::new().edge_radius(radius);
|
let spiral = Spiral2d::with_edge_radius(radius);
|
||||||
for point in spiral {
|
for point in spiral {
|
||||||
// If square is not sparse, generate sprite
|
// If square is not sparse, generate sprite
|
||||||
if !thread_rng().gen_bool(self.static_data.sparseness) {
|
if !thread_rng().gen_bool(self.static_data.sparseness) {
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
#![allow(
|
#![allow(clippy::identity_op, clippy::option_map_unit_fn)]
|
||||||
clippy::identity_op,
|
|
||||||
clippy::new_without_default,
|
|
||||||
clippy::option_map_unit_fn
|
|
||||||
)]
|
|
||||||
#![deny(clippy::clone_on_ref_ptr)]
|
#![deny(clippy::clone_on_ref_ptr)]
|
||||||
#![feature(
|
#![feature(
|
||||||
array_methods,
|
array_methods,
|
||||||
|
@ -15,6 +15,7 @@ impl<V: Vertex> Clone for Mesh<V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<V: Vertex> Mesh<V> {
|
impl<V: Vertex> Mesh<V> {
|
||||||
|
#[allow(clippy::new_without_default)]
|
||||||
/// Create a new `Mesh`.
|
/// Create a new `Mesh`.
|
||||||
pub fn new() -> Self { Self { verts: Vec::new() } }
|
pub fn new() -> Self { Self { verts: Vec::new() } }
|
||||||
|
|
||||||
|
@ -294,6 +294,7 @@ impl<Skel: Skeleton> FigureModelCache<Skel>
|
|||||||
where
|
where
|
||||||
Skel::Body: BodySpec + Eq + Hash,
|
Skel::Body: BodySpec + Eq + Hash,
|
||||||
{
|
{
|
||||||
|
#[allow(clippy::new_without_default)]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
// NOTE: It might be better to bubble this error up rather than panicking.
|
// NOTE: It might be better to bubble this error up rather than panicking.
|
||||||
let manifests = <Skel::Body as BodySpec>::load_spec().unwrap();
|
let manifests = <Skel::Body as BodySpec>::load_spec().unwrap();
|
||||||
|
@ -747,8 +747,7 @@ fn main() {
|
|||||||
let mut total_timings: BTreeMap<&str, f32> = BTreeMap::new();
|
let mut total_timings: BTreeMap<&str, f32> = BTreeMap::new();
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
let mut volgrid = VolGrid2d::new().unwrap();
|
let mut volgrid = VolGrid2d::new().unwrap();
|
||||||
for (i, spiralpos) in Spiral2d::new()
|
for (i, spiralpos) in Spiral2d::with_radius(RADIUS)
|
||||||
.radius(RADIUS)
|
|
||||||
.map(|v| v + sitepos.as_())
|
.map(|v| v + sitepos.as_())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user