mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix warnings
This commit is contained in:
parent
5260c82c4a
commit
e5aa8cd3b7
@ -116,7 +116,7 @@ impl BlockKind {
|
|||||||
|
|
||||||
/// # Format
|
/// # Format
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```ignore
|
||||||
/// BBBBBBBB CCCCCCCC AAAAAIII IIIIIIII
|
/// BBBBBBBB CCCCCCCC AAAAAIII IIIIIIII
|
||||||
/// ```
|
/// ```
|
||||||
/// - `0..8` : BlockKind
|
/// - `0..8` : BlockKind
|
||||||
@ -194,13 +194,6 @@ impl Block {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub const fn air(sprite: SpriteKind) -> Self { Self::unfilled(BlockKind::Air, sprite) }
|
pub const fn air(sprite: SpriteKind) -> Self { Self::unfilled(BlockKind::Air, sprite) }
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub const fn lava(sprite: SpriteKind) -> Self {
|
|
||||||
// TODO: Is this valid? I don't think so, lava is filled. Debug panic will catch
|
|
||||||
// it if not though.
|
|
||||||
Self::unfilled(BlockKind::Lava, sprite)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn empty() -> Self { Self::air(SpriteKind::Empty) }
|
pub const fn empty() -> Self { Self::air(SpriteKind::Empty) }
|
||||||
|
|
||||||
@ -260,7 +253,7 @@ impl Block {
|
|||||||
pub fn get_attr<A: sprite::Attribute>(&self) -> Result<A, sprite::AttributeError<A::Error>> {
|
pub fn get_attr<A: sprite::Attribute>(&self) -> Result<A, sprite::AttributeError<A::Error>> {
|
||||||
match self.sprite_category() {
|
match self.sprite_category() {
|
||||||
Some(category) => category.read_attr(*self),
|
Some(category) => category.read_attr(*self),
|
||||||
None => return Err(sprite::AttributeError::NotPresent),
|
None => Err(sprite::AttributeError::NotPresent),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +264,7 @@ impl Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(super) const fn to_be_u32(&self) -> u32 {
|
pub(super) const fn to_be_u32(self) -> u32 {
|
||||||
u32::from_be_bytes([self.kind as u8, self.data[0], self.data[1], self.data[2]])
|
u32::from_be_bytes([self.kind as u8, self.data[0], self.data[1], self.data[2]])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +659,7 @@ impl Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_u32(&self) -> u32 {
|
pub fn to_u32(self) -> u32 {
|
||||||
u32::from_le_bytes([self.kind as u8, self.data[0], self.data[1], self.data[2]])
|
u32::from_le_bytes([self.kind as u8, self.data[0], self.data[1], self.data[2]])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,10 @@ use hashbrown::HashMap;
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{convert::TryFrom, fmt};
|
use std::{
|
||||||
|
convert::{Infallible, TryFrom},
|
||||||
|
fmt,
|
||||||
|
};
|
||||||
use strum::EnumIter;
|
use strum::EnumIter;
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -323,8 +326,6 @@ sprites! {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
use core::convert::Infallible;
|
|
||||||
|
|
||||||
attributes! {
|
attributes! {
|
||||||
Ori { bits: 4, err: Infallible, from: |bits| Ok(Self(bits as u8)), into: |Ori(x)| x as u16 },
|
Ori { bits: 4, err: Infallible, from: |bits| Ok(Self(bits as u8)), into: |Ori(x)| x as u16 },
|
||||||
Growth { bits: 4, err: Infallible, from: |bits| Ok(Self(bits as u8)), into: |Growth(x)| x as u16 },
|
Growth { bits: 4, err: Infallible, from: |bits| Ok(Self(bits as u8)), into: |Growth(x)| x as u16 },
|
||||||
|
@ -128,7 +128,7 @@ macro_rules! sprites {
|
|||||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize, EnumIter, FromPrimitive)]
|
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize, EnumIter, FromPrimitive)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum SpriteKind {
|
pub enum SpriteKind {
|
||||||
$($($sprite_name = crate::terrain::sprite::gen_discriminant(crate::terrain::sprite::Category::$category_name, $sprite_id),)*)*
|
$($($sprite_name = $crate::terrain::sprite::gen_discriminant($crate::terrain::sprite::Category::$category_name, $sprite_id),)*)*
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -197,12 +197,15 @@ macro_rules! attributes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(impl Attribute for $name {
|
$(
|
||||||
const INDEX: usize = Attributes::$name as usize;
|
#[allow(clippy::all)]
|
||||||
const BITS: u8 = $bits;
|
impl Attribute for $name {
|
||||||
type Error = $err;
|
const INDEX: usize = Attributes::$name as usize;
|
||||||
#[inline(always)] fn from_bits(bits: u16) -> Result<Self, Self::Error> { $from_bits(bits) }
|
const BITS: u8 = $bits;
|
||||||
#[inline(always)] fn into_bits(self) -> u16 { $into_bits(self) }
|
type Error = $err;
|
||||||
})*
|
#[inline(always)] fn from_bits(bits: u16) -> Result<Self, Self::Error> { $from_bits(bits) }
|
||||||
|
#[inline(always)] fn into_bits(self) -> u16 { $into_bits(self) }
|
||||||
|
}
|
||||||
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ impl TryFrom<HashMap<SpriteKind, Option<SpriteConfig<String>>>> for SpriteSpec {
|
|||||||
type Error = SpritesMissing;
|
type Error = SpritesMissing;
|
||||||
|
|
||||||
fn try_from(
|
fn try_from(
|
||||||
mut map: HashMap<SpriteKind, Option<SpriteConfig<String>>>,
|
map: HashMap<SpriteKind, Option<SpriteConfig<String>>>,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
Ok(Self(map))
|
Ok(Self(map))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user