Fix warnings

This commit is contained in:
Dr. Dystopia 2021-12-07 21:40:27 +01:00 committed by Marcel Märtens
parent 2644c51b39
commit bb48267827
9 changed files with 26 additions and 26 deletions

View File

@ -1,7 +1,7 @@
use crate::path::Path; use crate::path::Path;
use core::{ use core::{
cmp::Ordering::{self, Equal}, cmp::Ordering::{self, Equal},
f32, fmt, fmt,
hash::{BuildHasher, Hash}, hash::{BuildHasher, Hash},
}; };
use hashbrown::{HashMap, HashSet}; use hashbrown::{HashMap, HashSet};

View File

@ -79,7 +79,7 @@ impl Ori {
/// let ori1 = Ori::from(Dir::new(Vec3::unit_x())); /// let ori1 = Ori::from(Dir::new(Vec3::unit_x()));
/// let ori2 = Ori::default().rotated(roll_right).rotated(pitch_up); /// let ori2 = Ori::default().rotated(roll_right).rotated(pitch_up);
/// ///
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON); /// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= f32::EPSILON);
/// ``` /// ```
#[must_use] #[must_use]
pub fn rotated(self, q: Quaternion<f32>) -> Self { pub fn rotated(self, q: Quaternion<f32>) -> Self {
@ -100,7 +100,7 @@ impl Ori {
/// let ori1 = Ori::from(Dir::up()); /// let ori1 = Ori::from(Dir::up());
/// let ori2 = Ori::default().prerotated(roll_right).prerotated(pitch_up); /// let ori2 = Ori::default().prerotated(roll_right).prerotated(pitch_up);
/// ///
/// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= std::f32::EPSILON); /// assert!((ori1.look_dir().dot(*ori2.look_dir()) - 1.0).abs() <= f32::EPSILON);
/// ``` /// ```
#[must_use] #[must_use]
pub fn prerotated(self, q: Quaternion<f32>) -> Self { pub fn prerotated(self, q: Quaternion<f32>) -> Self {
@ -280,17 +280,17 @@ impl Ori {
/// let zenith = vek::Vec3::unit_z(); /// let zenith = vek::Vec3::unit_z();
/// ///
/// let rl = Ori::default().rolled_left(ang); /// let rl = Ori::default().rolled_left(ang);
/// assert!((rl.up().angle_between(zenith) - ang).abs() <= std::f32::EPSILON); /// assert!((rl.up().angle_between(zenith) - ang).abs() <= f32::EPSILON);
/// assert!(rl.uprighted().up().angle_between(zenith) <= std::f32::EPSILON); /// assert!(rl.uprighted().up().angle_between(zenith) <= f32::EPSILON);
/// ///
/// let pd_rr = Ori::default().pitched_down(ang).rolled_right(ang); /// let pd_rr = Ori::default().pitched_down(ang).rolled_right(ang);
/// let pd_upr = pd_rr.uprighted(); /// let pd_upr = pd_rr.uprighted();
/// ///
/// assert!((pd_upr.up().angle_between(zenith) - ang).abs() <= std::f32::EPSILON); /// assert!((pd_upr.up().angle_between(zenith) - ang).abs() <= f32::EPSILON);
/// ///
/// let ang1 = pd_upr.rolled_right(ang).up().angle_between(zenith); /// let ang1 = pd_upr.rolled_right(ang).up().angle_between(zenith);
/// let ang2 = pd_rr.up().angle_between(zenith); /// let ang2 = pd_rr.up().angle_between(zenith);
/// assert!((ang1 - ang2).abs() <= std::f32::EPSILON); /// assert!((ang1 - ang2).abs() <= f32::EPSILON);
/// ``` /// ```
#[must_use] #[must_use]
pub fn uprighted(self) -> Self { self.look_dir().into() } pub fn uprighted(self) -> Self { self.look_dir().into() }

View File

@ -112,9 +112,9 @@ impl Recipe {
/// ingredients needed, whose positions correspond to particular recipe /// ingredients needed, whose positions correspond to particular recipe
/// inputs. If items are missing, return the missing items, and how many /// inputs. If items are missing, return the missing items, and how many
/// are missing. /// are missing.
pub fn inventory_contains_ingredients<'a>( pub fn inventory_contains_ingredients(
&self, &self,
inv: &'a Inventory, inv: &Inventory,
) -> Result<Vec<(u32, InvSlotId)>, Vec<(&RecipeInput, u32)>> { ) -> Result<Vec<(u32, InvSlotId)>, Vec<(&RecipeInput, u32)>> {
// Hashmap tracking the quantity that needs to be removed from each slot (so // Hashmap tracking the quantity that needs to be removed from each slot (so
// that it doesn't think a slot can provide more items than it contains) // that it doesn't think a slot can provide more items than it contains)

View File

@ -78,15 +78,15 @@ impl CharacterBehavior for Data {
update update
} }
fn talk(&self, data: &JoinData, _: &mut OutputEvents) -> StateUpdate {
let mut update = StateUpdate::from(data);
attempt_talk(data, &mut update);
update
}
fn stand(&self, data: &JoinData, _: &mut OutputEvents) -> StateUpdate { fn stand(&self, data: &JoinData, _: &mut OutputEvents) -> StateUpdate {
let mut update = StateUpdate::from(data); let mut update = StateUpdate::from(data);
update.character = CharacterState::Idle(Data { is_sneaking: false }); update.character = CharacterState::Idle(Data { is_sneaking: false });
update update
} }
fn talk(&self, data: &JoinData, _: &mut OutputEvents) -> StateUpdate {
let mut update = StateUpdate::from(data);
attempt_talk(data, &mut update);
update
}
} }

View File

@ -476,7 +476,7 @@ fn swim_move(
}; };
// Autoswim to stay afloat // Autoswim to stay afloat
let move_z = if submersion < 1.0 && data.inputs.move_z.abs() < std::f32::EPSILON { let move_z = if submersion < 1.0 && data.inputs.move_z.abs() < f32::EPSILON {
(submersion - 0.1).max(0.0) (submersion - 0.1).max(0.0)
} else { } else {
data.inputs.move_z data.inputs.move_z
@ -524,7 +524,7 @@ pub fn fly_move(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32)
Body::Ship(ship) if ship.can_fly() => { Body::Ship(ship) if ship.can_fly() => {
let regulate_density = |min: f32, max: f32, def: f32, rate: f32| -> Density { let regulate_density = |min: f32, max: f32, def: f32, rate: f32| -> Density {
// Reset to default on no input // Reset to default on no input
let change = if data.inputs.move_z.abs() > std::f32::EPSILON { let change = if data.inputs.move_z.abs() > f32::EPSILON {
-data.inputs.move_z -data.inputs.move_z
} else { } else {
(def - data.density.0).max(-1.0).min(1.0) (def - data.density.0).max(-1.0).min(1.0)

View File

@ -239,7 +239,7 @@ impl<'a> PhysicsData<'a> {
// //
// Other advantage of early-return is that we don't // Other advantage of early-return is that we don't
// later divide by zero and return NaN // later divide by zero and return NaN
if len < std::f32::EPSILON * 10.0 { if len < f32::EPSILON * 10.0 {
Some((*p0, *p0)) Some((*p0, *p0))
} else { } else {
// Apply orientation to origins of prism. // Apply orientation to origins of prism.
@ -1897,7 +1897,7 @@ struct ColliderContext<'a> {
/// Find pushback vector and collision_distance we assume between this /// Find pushback vector and collision_distance we assume between this
/// colliders. /// colliders.
fn projection_between(c0: ColliderContext, c1: ColliderContext) -> (Vec2<f32>, f32) { fn projection_between(c0: ColliderContext, c1: ColliderContext) -> (Vec2<f32>, f32) {
const DIFF_THRESHOLD: f32 = std::f32::EPSILON; const DIFF_THRESHOLD: f32 = f32::EPSILON;
let our_radius = c0.previous_cache.neighborhood_radius; let our_radius = c0.previous_cache.neighborhood_radius;
let their_radius = c1.previous_cache.neighborhood_radius; let their_radius = c1.previous_cache.neighborhood_radius;
let collision_dist = our_radius + their_radius; let collision_dist = our_radius + their_radius;

View File

@ -377,11 +377,11 @@ mod v1 {
// An unban record following a ban is valid if the role of the person doing the // An unban record following a ban is valid if the role of the person doing the
// unbanning is at least the privilege level of the person who did the ban. // unbanning is at least the privilege level of the person who did the ban.
(BanAction::Unban(unban), Some(BanAction::Ban(ban))) => { (BanAction::Unban(unban), Some(BanAction::Ban(ban))) => {
if unban.performed_by_role >= ban.performed_by_role() { return if unban.performed_by_role >= ban.performed_by_role() {
return Ok(()); Ok(())
} else { } else {
return Err(BanErrorKind::PermissionDenied(BanKind::Unban)); Err(BanErrorKind::PermissionDenied(BanKind::Unban))
} };
}, },
}; };

View File

@ -36,7 +36,7 @@ impl IndexOwned {
impl World { impl World {
pub fn generate(_seed: u32) -> (Self, IndexOwned) { (Self, IndexOwned) } pub fn generate(_seed: u32) -> (Self, IndexOwned) { (Self, IndexOwned) }
pub fn tick(&self, dt: Duration) {} pub fn tick(&self) {}
#[inline(always)] #[inline(always)]
pub const fn map_size_lg(&self) -> MapSizeLg { DEFAULT_WORLD_CHUNKS_LG } pub const fn map_size_lg(&self) -> MapSizeLg { DEFAULT_WORLD_CHUNKS_LG }

View File

@ -59,10 +59,10 @@ pub fn criterion_benchmark(c: &mut Criterion) {
// The region to actually mesh // The region to actually mesh
let min_z = volume let min_z = volume
.iter() .iter()
.fold(std::i32::MAX, |min, (_, chunk)| chunk.get_min_z().min(min)); .fold(i32::MAX, |min, (_, chunk)| chunk.get_min_z().min(min));
let max_z = volume let max_z = volume
.iter() .iter()
.fold(std::i32::MIN, |max, (_, chunk)| chunk.get_max_z().max(max)); .fold(i32::MIN, |max, (_, chunk)| chunk.get_max_z().max(max));
let aabb = Aabb { let aabb = Aabb {
min: Vec3::from(aabr.min) + Vec3::unit_z() * (min_z - 1), min: Vec3::from(aabr.min) + Vec3::unit_z() * (min_z - 1),