mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'xmac94x/steal-sharps-clippy-improvements' into 'master'
Xmac94x/steal sharps clippy improvements See merge request veloren/veloren!3612
This commit is contained in:
commit
aea4aca057
@ -1,6 +1,6 @@
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(clippy::clone_on_ref_ptr)]
|
||||
#![feature(label_break_value, option_zip)]
|
||||
#![feature(label_break_value, option_zip, bool_to_option)]
|
||||
|
||||
pub mod addr;
|
||||
pub mod error;
|
||||
@ -318,7 +318,7 @@ impl Client {
|
||||
server_info.git_hash,
|
||||
server_info.git_date,
|
||||
common::util::GIT_HASH.to_string(),
|
||||
common::util::GIT_DATE.to_string(),
|
||||
*common::util::GIT_DATE,
|
||||
);
|
||||
}
|
||||
// Pass the server info back to the caller to ensure they can access it even
|
||||
@ -2568,7 +2568,7 @@ impl Client {
|
||||
pub fn players(&self) -> impl Iterator<Item = &str> {
|
||||
self.player_list()
|
||||
.values()
|
||||
.filter_map(|player_info| player_info.is_online.then(|| &*player_info.player_alias))
|
||||
.filter_map(|player_info| player_info.is_online.then_some(&*player_info.player_alias))
|
||||
}
|
||||
|
||||
/// Return true if this client is a moderator on the server
|
||||
|
@ -17,7 +17,7 @@ fn main() {
|
||||
// Note: It will compare commits. As long as the commits do not diverge from the
|
||||
// server no version change will be detected.
|
||||
match Command::new("git")
|
||||
.args(&[
|
||||
.args([
|
||||
"log",
|
||||
"-n",
|
||||
"1",
|
||||
@ -40,7 +40,7 @@ fn main() {
|
||||
// Note: It will compare commits. As long as the commits do not diverge from the
|
||||
// server no version change will be detected.
|
||||
match Command::new("git")
|
||||
.args(&["describe", "--exact-match", "--tags", "HEAD"])
|
||||
.args(["describe", "--exact-match", "--tags", "HEAD"])
|
||||
.output()
|
||||
{
|
||||
Ok(output) => match String::from_utf8(output.stdout) {
|
||||
|
@ -5,7 +5,7 @@ use std::{collections::HashMap, time::Instant};
|
||||
/// measuring the level of threads a unit of code ran on. Use Rayon when it ran
|
||||
/// on their threadpool. Use Exact when you know on how many threads your code
|
||||
/// ran on exactly.
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub enum ParMode {
|
||||
None, /* Job is not running at all */
|
||||
Single,
|
||||
@ -14,7 +14,7 @@ pub enum ParMode {
|
||||
}
|
||||
|
||||
//TODO: make use of the phase of a system for advanced scheduling and logging
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
pub enum Phase {
|
||||
Create,
|
||||
Review,
|
||||
@ -22,7 +22,7 @@ pub enum Phase {
|
||||
}
|
||||
|
||||
//TODO: make use of the origin of the system for better logging
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum Origin {
|
||||
Common,
|
||||
Client,
|
||||
|
@ -28,7 +28,7 @@ pub enum ClientMsg {
|
||||
2nd Level Enums
|
||||
*/
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ClientType {
|
||||
/// Regular Client like Voxygen who plays the game
|
||||
Game,
|
||||
@ -39,7 +39,7 @@ pub enum ClientType {
|
||||
Bot { privileged: bool },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ClientRegister {
|
||||
pub token_or_username: String,
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ impl<T: Serialize> CompressedData<T> {
|
||||
|
||||
let buf = Vec::with_capacity(uncompressed.len() / 10);
|
||||
let mut encoder = DeflateEncoder::new(buf, Compression::new(level));
|
||||
encoder.write_all(&*uncompressed).expect(EXPECT_MSG);
|
||||
encoder.write_all(&uncompressed).expect(EXPECT_MSG);
|
||||
let compressed = encoder.finish().expect(EXPECT_MSG);
|
||||
CompressedData {
|
||||
data: compressed,
|
||||
@ -60,9 +60,9 @@ impl<T: for<'a> Deserialize<'a>> CompressedData<T> {
|
||||
flate2::read::DeflateDecoder::new(&*self.data)
|
||||
.read_to_end(&mut uncompressed)
|
||||
.ok()?;
|
||||
bincode::deserialize(&*uncompressed).ok()
|
||||
bincode::deserialize(&uncompressed).ok()
|
||||
} else {
|
||||
bincode::deserialize(&*self.data).ok()
|
||||
bincode::deserialize(&self.data).ok()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,7 +237,7 @@ impl<const N: u32> VoxelImageEncoding for QuadPngEncoding<N> {
|
||||
CompressionType::Rle,
|
||||
FilterType::Up,
|
||||
);
|
||||
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
.ok()?;
|
||||
indices[i] = buf.len();
|
||||
Some(())
|
||||
@ -253,7 +253,7 @@ impl<const N: u32> VoxelImageEncoding for QuadPngEncoding<N> {
|
||||
FilterType::Sub,
|
||||
);
|
||||
png.write_image(
|
||||
&*ws.3.as_raw(),
|
||||
ws.3.as_raw(),
|
||||
ws.3.width(),
|
||||
ws.3.height(),
|
||||
image::ColorType::Rgb8,
|
||||
@ -513,7 +513,7 @@ impl<const AVERAGE_PALETTE: bool> VoxelImageEncoding for TriPngEncoding<AVERAGE_
|
||||
CompressionType::Rle,
|
||||
FilterType::Up,
|
||||
);
|
||||
png.write_image(&*x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
png.write_image(x.as_raw(), x.width(), x.height(), image::ColorType::L8)
|
||||
.ok()?;
|
||||
indices[i] = buf.len();
|
||||
Some(())
|
||||
|
@ -22,7 +22,7 @@ pub use self::{
|
||||
use common::character::CharacterId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum PresenceKind {
|
||||
Spectator,
|
||||
Character(CharacterId),
|
||||
@ -36,7 +36,7 @@ impl PresenceKind {
|
||||
pub fn controlling_char(&self) -> bool { matches!(self, Self::Character(_) | Self::Possessor) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum PingMsg {
|
||||
Ping,
|
||||
Pong,
|
||||
|
@ -267,7 +267,7 @@ pub enum DisconnectReason {
|
||||
Kicked(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum RegisterError {
|
||||
AuthError(String),
|
||||
Banned(String),
|
||||
|
@ -8,7 +8,7 @@ pub enum CalendarEvent {
|
||||
Christmas = 0,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Calendar {
|
||||
events: Vec<CalendarEvent>,
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ pub type CharacterId = i64;
|
||||
pub const MAX_NAME_LENGTH: usize = 20;
|
||||
|
||||
/// The minimum character data we need to create a new character on the server.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Character {
|
||||
pub id: Option<CharacterId>,
|
||||
pub alias: String,
|
||||
|
@ -39,7 +39,7 @@ impl ChatCommandData {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
|
||||
pub enum KitSpec {
|
||||
Item(String),
|
||||
ModularWeapon {
|
||||
@ -47,7 +47,7 @@ pub enum KitSpec {
|
||||
material: comp::item::Material,
|
||||
},
|
||||
}
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
|
||||
pub struct KitManifest(pub HashMap<String, Vec<(KitSpec, u32)>>);
|
||||
impl assets::Asset for KitManifest {
|
||||
type Loader = assets::RonLoader;
|
||||
@ -55,7 +55,7 @@ impl assets::Asset for KitManifest {
|
||||
const EXTENSION: &'static str = "ron";
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
|
||||
pub struct SkillPresetManifest(pub HashMap<String, Vec<(Skill, u8)>>);
|
||||
impl assets::Asset for SkillPresetManifest {
|
||||
type Loader = assets::RonLoader;
|
||||
@ -875,7 +875,7 @@ impl FromStr for ServerChatCommand {
|
||||
.filter_map(|c| c.short_keyword().map(|s| (s, c)))
|
||||
.chain(Self::iter().map(|c| (c.keyword(), c)))
|
||||
// Find command with matching string as keyword
|
||||
.find_map(|(kwd, command)| (kwd == keyword).then(|| command))
|
||||
.find_map(|(kwd, command)| (kwd == keyword).then_some(command))
|
||||
// Return error if not found
|
||||
.ok_or(())
|
||||
}
|
||||
|
@ -901,7 +901,7 @@ pub struct Knockback {
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum KnockbackDir {
|
||||
Away,
|
||||
Towards,
|
||||
|
@ -326,7 +326,7 @@ impl From<MovementAbility> for Ability {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
pub enum AuxiliaryAbility {
|
||||
MainWeapon(usize),
|
||||
OffWeapon(usize),
|
||||
|
@ -21,7 +21,7 @@ pub const TRADE_INTERACTION_TIME: f32 = 300.0;
|
||||
const AWARENESS_DECREMENT_CONSTANT: f32 = 2.1;
|
||||
const SECONDS_BEFORE_FORGET_SOUNDS: f64 = 180.0;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Alignment {
|
||||
/// Wild animals and gentle giants
|
||||
Wild,
|
||||
@ -37,7 +37,7 @@ pub enum Alignment {
|
||||
Passive,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Mark {
|
||||
Merchant,
|
||||
Guard,
|
||||
|
@ -4,7 +4,7 @@ use vek::Vec2;
|
||||
/// This component exists in order to fix a bug that caused entities
|
||||
/// such as campfires to duplicate because the chunk was double-loaded.
|
||||
/// See https://gitlab.com/veloren/veloren/-/merge_requests/1543
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Anchor {
|
||||
/// An entity with an Entity Anchor will be destroyed when its anchor Entity
|
||||
/// no longer exists
|
||||
|
@ -70,7 +70,7 @@ pub enum AuraTarget {
|
||||
All,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum Specifier {
|
||||
WardingAura,
|
||||
HealingAura,
|
||||
|
@ -34,7 +34,7 @@ impl std::ops::Deref for BeamSegment {
|
||||
fn deref(&self) -> &Properties { &self.properties }
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Beam {
|
||||
pub hit_entities: Vec<Uid>,
|
||||
pub tick_dur: Duration,
|
||||
@ -45,7 +45,7 @@ impl Component for Beam {
|
||||
type Storage = specs::DenseVecStorage<Self>;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum FrontendSpecifier {
|
||||
Flamethrower,
|
||||
LifestealBeam,
|
||||
|
@ -10,13 +10,13 @@ pub struct Body {
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self {
|
||||
species,
|
||||
body_type,
|
||||
|
@ -106,7 +106,7 @@ make_case_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
*(&ALL_OBJECTS).choose(&mut rng).unwrap()
|
||||
*ALL_OBJECTS.choose(&mut rng).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ make_proj_elim!(
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ impl Body {
|
||||
Self::random_with(&mut rng)
|
||||
}
|
||||
|
||||
pub fn random_with(rng: &mut impl rand::Rng) -> Self { *(&ALL_BODIES).choose(rng).unwrap() }
|
||||
pub fn random_with(rng: &mut impl rand::Rng) -> Self { *ALL_BODIES.choose(rng).unwrap() }
|
||||
|
||||
pub fn random_airship_with(rng: &mut impl rand::Rng) -> Self {
|
||||
*(&ALL_AIRSHIPS).choose(rng).unwrap()
|
||||
*ALL_AIRSHIPS.choose(rng).unwrap()
|
||||
}
|
||||
|
||||
pub fn random_ship_with(rng: &mut impl rand::Rng) -> Self { *(&ALL_SHIPS).choose(rng).unwrap() }
|
||||
pub fn random_ship_with(rng: &mut impl rand::Rng) -> Self { *ALL_SHIPS.choose(rng).unwrap() }
|
||||
|
||||
/// Return the structure manifest that this ship uses. `None` means that it
|
||||
/// should be derived from the collider.
|
||||
|
@ -10,13 +10,13 @@ pub struct Body {
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
|
||||
let species = *ALL_SPECIES.choose(&mut rng).unwrap();
|
||||
Self::random_with(&mut rng, &species)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
|
||||
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
|
||||
let body_type = *ALL_BODY_TYPES.choose(rng).unwrap();
|
||||
Self { species, body_type }
|
||||
}
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ impl PartialEq for Buff {
|
||||
}
|
||||
|
||||
/// Source of the de/buff
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
pub enum BuffSource {
|
||||
/// Applied by a character
|
||||
Character { by: Uid },
|
||||
@ -505,7 +505,7 @@ impl Buffs {
|
||||
self.kinds
|
||||
.get(&kind)
|
||||
.map(|ids| ids.iter())
|
||||
.unwrap_or_else(|| (&[]).iter())
|
||||
.unwrap_or_else(|| [].iter())
|
||||
.map(move |id| (*id, &self.buffs[id]))
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use specs::Component;
|
||||
use std::collections::BTreeMap;
|
||||
use vek::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum InventoryEvent {
|
||||
Pickup(Uid),
|
||||
Swap(InvSlotId, InvSlotId),
|
||||
@ -31,7 +31,7 @@ pub enum InventoryEvent {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum InventoryAction {
|
||||
Swap(EquipSlot, Slot),
|
||||
Drop(EquipSlot),
|
||||
@ -40,7 +40,7 @@ pub enum InventoryAction {
|
||||
Collect(Vec3<i32>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum InventoryManip {
|
||||
Pickup(Uid),
|
||||
Collect(Vec3<i32>),
|
||||
@ -93,7 +93,7 @@ impl From<InventoryEvent> for InventoryManip {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum CraftEvent {
|
||||
Simple {
|
||||
recipe: String,
|
||||
@ -115,7 +115,7 @@ pub enum CraftEvent {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum GroupManip {
|
||||
Leave,
|
||||
Kick(Uid),
|
||||
@ -136,7 +136,7 @@ pub enum UtteranceKind {
|
||||
* sounds */
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ControlEvent {
|
||||
//ToggleLantern,
|
||||
EnableLantern,
|
||||
@ -230,7 +230,7 @@ pub struct InputAttr {
|
||||
pub target_entity: Option<Uid>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Climb {
|
||||
Up,
|
||||
Down,
|
||||
|
@ -66,7 +66,7 @@ impl Energy {
|
||||
// NaN does not need to be handled here as rust will automatically change to 0 when casting to u32
|
||||
.clamp(0.0, Self::MAX_SCALED_ENERGY as f32) as u32;
|
||||
|
||||
(maximum != self.maximum).then(|| maximum)
|
||||
(maximum != self.maximum).then_some(maximum)
|
||||
}
|
||||
|
||||
/// Updates the maximum value for energy.
|
||||
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::f32::consts::PI;
|
||||
use vek::*;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum LiquidKind {
|
||||
Water,
|
||||
Lava,
|
||||
|
@ -38,7 +38,7 @@ pub struct GroupInfo {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Role {
|
||||
Member,
|
||||
Pet,
|
||||
@ -504,7 +504,7 @@ impl GroupManager {
|
||||
self.groups[group.0 as usize].leader = new_leader;
|
||||
|
||||
// Point to new leader
|
||||
members(group, &*groups, entities, alignments, uids).for_each(|(e, role)| match role {
|
||||
members(group, groups, entities, alignments, uids).for_each(|(e, role)| match role {
|
||||
Role::Member => notifier(e, ChangeNotification::NewLeader(new_leader)),
|
||||
Role::Pet => {},
|
||||
});
|
||||
|
@ -105,7 +105,7 @@ impl Health {
|
||||
// NaN does not need to be handled here as rust will automatically change to 0 when casting to u32
|
||||
.clamp(0.0, Self::MAX_SCALED_HEALTH as f32) as u32;
|
||||
|
||||
(maximum != self.maximum).then(|| maximum)
|
||||
(maximum != self.maximum).then_some(maximum)
|
||||
}
|
||||
|
||||
/// Updates the maximum value for health.
|
||||
@ -172,8 +172,8 @@ impl Health {
|
||||
.damage_contributors
|
||||
.entry(attacker)
|
||||
.or_insert((0, change.time));
|
||||
(*entry).0 += u64::try_from(-delta).unwrap_or(0);
|
||||
(*entry).1 = change.time
|
||||
entry.0 += u64::try_from(-delta).unwrap_or(0);
|
||||
entry.1 = change.time
|
||||
}
|
||||
|
||||
// Prune any damage contributors who haven't contributed damage for over the
|
||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
use specs::{Component, DenseVecStorage, DerefFlaggedStorage};
|
||||
use vek::geom::Aabb;
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CanBuild {
|
||||
pub enabled: bool,
|
||||
pub build_areas: HashSet<Id<Aabb<i32>>>,
|
||||
|
@ -35,7 +35,7 @@ impl Armor {
|
||||
}
|
||||
|
||||
/// longitudinal and lateral friction, only meaningful for footwear
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Friction {
|
||||
Normal,
|
||||
Ski,
|
||||
|
@ -210,7 +210,7 @@ impl TagExampleInfo for Material {
|
||||
fn exemplar_identifier(&self) -> Option<&str> { self.asset_identifier() }
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ItemTag {
|
||||
/// Used to indicate that an item is composed of this material
|
||||
Material(Material),
|
||||
@ -559,7 +559,7 @@ impl TryFrom<(&Item, &AbilityMap, &MaterialStatManifest)> for ItemConfig {
|
||||
ability_map.get_ability_set(key)
|
||||
};
|
||||
let abilities = if let Some(set_key) = item.ability_spec() {
|
||||
if let Some(set) = ability_map.get_ability_set(&*set_key) {
|
||||
if let Some(set) = ability_map.get_ability_set(&set_key) {
|
||||
set.clone().modified_by_tool(tool)
|
||||
} else {
|
||||
error!(
|
||||
|
@ -239,7 +239,7 @@ pub enum ModularComponent {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum WeaponName {
|
||||
Universal(String),
|
||||
HandednessDependent {
|
||||
|
@ -798,7 +798,7 @@ fn default_main_tool(body: &Body) -> Item {
|
||||
#[derive(Clone)]
|
||||
pub struct LoadoutBuilder(Loadout);
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Deserialize, Serialize, Debug, EnumIter)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Deserialize, Serialize, Debug, EnumIter)]
|
||||
pub enum Preset {
|
||||
HuskSummon,
|
||||
}
|
||||
@ -1083,7 +1083,7 @@ impl LoadoutBuilder {
|
||||
// Panic if item doesn't correspond to slot
|
||||
assert!(
|
||||
item.as_ref()
|
||||
.map_or(true, |item| equip_slot.can_hold(&*item.kind()))
|
||||
.map_or(true, |item| equip_slot.can_hold(&item.kind()))
|
||||
);
|
||||
|
||||
self.0.swap(equip_slot, item);
|
||||
|
@ -559,7 +559,7 @@ impl Inventory {
|
||||
#[must_use = "Returned items will be lost if not used"]
|
||||
pub fn equip(&mut self, inv_slot: InvSlotId) -> Vec<Item> {
|
||||
self.get(inv_slot)
|
||||
.and_then(|item| self.loadout.get_slot_to_equip_into(&*item.kind()))
|
||||
.and_then(|item| self.loadout.get_slot_to_equip_into(&item.kind()))
|
||||
.map(|equip_slot| self.swap_inventory_loadout(inv_slot, equip_slot))
|
||||
.unwrap_or_else(Vec::new)
|
||||
}
|
||||
@ -570,7 +570,7 @@ impl Inventory {
|
||||
pub fn free_after_equip(&self, inv_slot: InvSlotId) -> i32 {
|
||||
let (inv_slot_for_equipped, slots_from_equipped) = self
|
||||
.get(inv_slot)
|
||||
.and_then(|item| self.loadout.get_slot_to_equip_into(&*item.kind()))
|
||||
.and_then(|item| self.loadout.get_slot_to_equip_into(&item.kind()))
|
||||
.and_then(|equip_slot| self.equipped(equip_slot))
|
||||
.map_or((1, 0), |item| (0, item.slots().len()));
|
||||
|
||||
|
@ -6,12 +6,12 @@ use crate::comp::inventory::{
|
||||
loadout::LoadoutSlotId,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum SlotError {
|
||||
InventoryFull,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
||||
pub enum Slot {
|
||||
Inventory(InvSlotId),
|
||||
Equip(EquipSlot),
|
||||
|
@ -459,7 +459,7 @@ impl EqualitySet {
|
||||
let canonical_itemname = self
|
||||
.equivalence_class
|
||||
.get(item_name)
|
||||
.map_or(item_name, |i| &*i);
|
||||
.map_or(item_name, |i| i);
|
||||
|
||||
canonical_itemname
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specs::Component;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum InviteKind {
|
||||
Group,
|
||||
Trade,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum InviteResponse {
|
||||
Accept,
|
||||
Decline,
|
||||
|
@ -3,7 +3,7 @@ use crate::uid::Uid;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specs::Component;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Object {
|
||||
Bomb {
|
||||
owner: Option<Uid>,
|
||||
|
@ -156,14 +156,14 @@ impl Component for Collider {
|
||||
type Storage = DerefFlaggedStorage<Self, VecStorage<Self>>;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Sticky;
|
||||
|
||||
impl Component for Sticky {
|
||||
type Storage = DerefFlaggedStorage<Self, NullStorage<Self>>;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Immovable;
|
||||
|
||||
impl Component for Immovable {
|
||||
@ -213,7 +213,7 @@ impl Component for PhysicsState {
|
||||
|
||||
/// Used to forcefully update the position, velocity, and orientation of the
|
||||
/// client
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ForceUpdate {
|
||||
flag: bool,
|
||||
counter: u64,
|
||||
|
@ -35,7 +35,7 @@ impl std::ops::Deref for Shockwave {
|
||||
fn deref(&self) -> &Properties { &self.properties }
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ShockwaveHitEntities {
|
||||
pub hit_entities: Vec<Uid>,
|
||||
}
|
||||
@ -44,7 +44,7 @@ impl Component for ShockwaveHitEntities {
|
||||
type Storage = specs::DenseVecStorage<Self>;
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum FrontendSpecifier {
|
||||
Ground,
|
||||
Fire,
|
||||
|
@ -232,7 +232,7 @@ impl SkillGroup {
|
||||
/// Contains all of a player's skill groups and skills. Provides methods for
|
||||
/// manipulating assigned skills and skill groups including unlocking skills,
|
||||
/// refunding skills etc.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct SkillSet {
|
||||
skill_groups: HashMap<SkillGroupKind, SkillGroup>,
|
||||
skills: HashMap<Skill, u16>,
|
||||
@ -567,7 +567,7 @@ pub enum SpRewardError {
|
||||
Overflow,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Copy, Deserialize, Serialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Deserialize, Serialize)]
|
||||
pub enum SkillsPersistenceError {
|
||||
HashMismatch,
|
||||
DeserializationFailure,
|
||||
|
@ -12,14 +12,14 @@ use crate::{
|
||||
use serde::Deserialize;
|
||||
use vek::*;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, PartialEq)]
|
||||
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
|
||||
pub enum NameKind {
|
||||
Name(String),
|
||||
Automatic,
|
||||
Uninit,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, PartialEq)]
|
||||
#[derive(Debug, Deserialize, Clone, PartialEq, Eq)]
|
||||
pub enum BodyBuilder {
|
||||
RandomWith(String),
|
||||
Exact(Body),
|
||||
|
@ -76,7 +76,7 @@ impl<T> Lottery<T> {
|
||||
pub fn total(&self) -> f32 { self.total }
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||
pub enum LootSpec<T: AsRef<str>> {
|
||||
/// Asset specifier
|
||||
Item(T),
|
||||
|
@ -7,7 +7,7 @@ use rand::seq::SliceRandom;
|
||||
use serde::Deserialize;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub enum NpcKind {
|
||||
Humanoid,
|
||||
Wolf,
|
||||
|
@ -191,7 +191,7 @@ impl Recipe {
|
||||
for (inv_slot_id, slot) in inv.slots_with_id() {
|
||||
if let Some(item) = slot
|
||||
.as_ref()
|
||||
.filter(|item| item.matches_recipe_input(&*input, amount))
|
||||
.filter(|item| item.matches_recipe_input(input, amount))
|
||||
{
|
||||
*input_max.entry(inv_slot_id).or_insert(0) += item.amount();
|
||||
}
|
||||
@ -241,7 +241,7 @@ fn inventory_contains_ingredients<'a, I: Iterator<Item = (&'a RecipeInput, u32)>
|
||||
for (inv_slot_id, slot) in inv.slots_with_id() {
|
||||
if let Some(item) = slot
|
||||
.as_ref()
|
||||
.filter(|item| item.matches_recipe_input(&*input, amount))
|
||||
.filter(|item| item.matches_recipe_input(input, amount))
|
||||
{
|
||||
let claim = slot_claims.entry(inv_slot_id).or_insert(0);
|
||||
slots.push((i as u32, inv_slot_id));
|
||||
|
@ -9,7 +9,7 @@ use tracing::warn;
|
||||
/// `SkillSetBuilder` preset. Consider using loading from assets, when possible.
|
||||
/// When you're adding new enum variant,
|
||||
/// handle it in [`with_preset`](SkillSetBuilder::with_preset) method
|
||||
#[derive(Copy, Clone, PartialEq, Serialize, Deserialize, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
|
||||
pub enum Preset {
|
||||
Rank1,
|
||||
Rank2,
|
||||
|
@ -181,7 +181,7 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
/// Used to specify a particular effect for frontend purposes
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum FrontendSpecifier {
|
||||
GroundCleave,
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
|
||||
/// Separated out to condense update portions of character state
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct StaticData {
|
||||
/// Time required to draw weapon
|
||||
pub buildup_duration: Duration,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
/// Struct containing data that does not change over the course of the
|
||||
/// character state
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Default)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||||
pub struct Data {
|
||||
pub is_sneaking: bool,
|
||||
// None means unknown
|
||||
|
@ -175,7 +175,7 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum MovementBehavior {
|
||||
Stationary,
|
||||
ForwardGround,
|
||||
@ -183,7 +183,7 @@ pub enum MovementBehavior {
|
||||
Walking,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum FrontendSpecifier {
|
||||
CultistVortex,
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use std::time::Duration;
|
||||
use vek::Vec3;
|
||||
|
||||
/// Separated out to condense update portions of character state
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct StaticData {
|
||||
/// Buildup to sprite interaction
|
||||
pub buildup_duration: Duration,
|
||||
@ -32,7 +32,7 @@ pub struct StaticData {
|
||||
pub was_sneak: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
/// Struct containing data that does not change over the course of the
|
||||
/// character state
|
||||
@ -128,7 +128,7 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
/// Used to control effects based off of the type of sprite interacted with
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum SpriteInteractKind {
|
||||
Chest,
|
||||
Harvestable,
|
||||
|
@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
|
||||
/// Separated out to condense update portions of character state
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct StaticData {
|
||||
/// Buildup to item use
|
||||
pub buildup_duration: Duration,
|
||||
@ -39,7 +39,7 @@ pub struct StaticData {
|
||||
pub was_sneak: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
/// Struct containing data that does not change over the course of the
|
||||
/// character state
|
||||
@ -163,7 +163,7 @@ impl CharacterBehavior for Data {
|
||||
}
|
||||
|
||||
/// Used to control effects based off of the type of item used
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ItemUseKind {
|
||||
Consumable(ConsumableKind),
|
||||
}
|
||||
|
@ -1199,7 +1199,7 @@ pub enum ForcedMovement {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum MovementDirection {
|
||||
Look,
|
||||
Move,
|
||||
@ -1253,7 +1253,7 @@ impl AbilityInfo {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum HandInfo {
|
||||
TwoHanded,
|
||||
MainHand,
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Data {
|
||||
pub is_sneaking: bool,
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum SiteKindMeta {
|
||||
Dungeon(DungeonKindMeta),
|
||||
Cave,
|
||||
@ -9,13 +9,13 @@ pub enum SiteKindMeta {
|
||||
Void,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum DungeonKindMeta {
|
||||
Old,
|
||||
Gnarling,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum SettlementKindMeta {
|
||||
Default,
|
||||
Cliff,
|
||||
|
@ -12,7 +12,7 @@ use vek::*;
|
||||
|
||||
make_case_elim!(
|
||||
structure_block,
|
||||
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize)]
|
||||
#[repr(u8)]
|
||||
pub enum StructureBlock {
|
||||
None = 0,
|
||||
|
@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
|
||||
use strum::EnumIter;
|
||||
use tracing::{trace, warn};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum TradePhase {
|
||||
Mutate,
|
||||
Review,
|
||||
@ -22,7 +22,7 @@ pub enum TradePhase {
|
||||
/// Clients submit `TradeAction` to the server, which adds the Uid of the
|
||||
/// player out-of-band (i.e. without trusting the client to say who it's
|
||||
/// accepting on behalf of)
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum TradeAction {
|
||||
AddItem {
|
||||
item: InvSlotId,
|
||||
@ -41,7 +41,7 @@ pub enum TradeAction {
|
||||
Decline,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum TradeResult {
|
||||
Completed,
|
||||
Declined,
|
||||
@ -73,7 +73,7 @@ pub enum TradeResult {
|
||||
/// trading currently-equipped items (since `EquipSlot`s are disjoint from
|
||||
/// `InvSlotId`s), which avoids the issues associated with trading equipped bags
|
||||
/// that may still have contents.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct PendingTrade {
|
||||
/// `parties[0]` is the entity that initiated the trade, parties[1] is the
|
||||
/// other entity that's being traded with
|
||||
@ -239,7 +239,7 @@ impl Trades {
|
||||
None => return,
|
||||
}
|
||||
}
|
||||
trade.process_trade_action(party, action, &*inventories);
|
||||
trade.process_trade_action(party, action, &inventories);
|
||||
} else {
|
||||
warn!(
|
||||
"An entity who is not a party to trade {:?} tried to modify it",
|
||||
|
@ -13,7 +13,7 @@ pub enum PluginError {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum PluginModuleError {
|
||||
InstantiationError(InstantiationError),
|
||||
InstantiationError(Box<InstantiationError>),
|
||||
MemoryAllocation(MemoryAllocationError),
|
||||
MemoryUninit(ExportError),
|
||||
FindFunction(ExportError),
|
||||
|
@ -114,7 +114,7 @@ pub struct PluginMgr {
|
||||
|
||||
impl PluginMgr {
|
||||
pub fn from_assets() -> Result<Self, PluginError> {
|
||||
let mut assets_path = (&*ASSETS_PATH).clone();
|
||||
let mut assets_path = (*ASSETS_PATH).clone();
|
||||
assets_path.push("plugins");
|
||||
info!("Searching {:?} for plugins...", assets_path);
|
||||
Self::from_dir(assets_path)
|
||||
|
@ -37,7 +37,7 @@ impl PluginModule {
|
||||
// We are creating an enironnement
|
||||
let store = Store::new(&engine);
|
||||
// We are compiling the WASM file in the previously generated environement
|
||||
let module = Module::new(&store, &wasm_data).expect("Can't compile");
|
||||
let module = Module::new(&store, wasm_data).expect("Can't compile");
|
||||
|
||||
// This is the function imported into the wasm environement
|
||||
fn raw_emit_actions(env: &HostFunctionEnvironement, ptr: i64, len: i64) {
|
||||
@ -79,7 +79,7 @@ impl PluginModule {
|
||||
|
||||
// Create an instance (Code execution environement)
|
||||
let instance = Instance::new(&module, &import_object)
|
||||
.map_err(PluginModuleError::InstantiationError)?;
|
||||
.map_err(|err| PluginModuleError::InstantiationError(Box::new(err)))?;
|
||||
Ok(Self {
|
||||
memory_manager,
|
||||
ecs,
|
||||
|
@ -212,7 +212,7 @@ impl<'a> System<'a> for Sys {
|
||||
for (kind, ids) in buff_comp_kinds.iter() {
|
||||
if kind.queues() {
|
||||
if let Some((Some(buff), id)) =
|
||||
ids.get(0).map(|id| (buff_comp_buffs.get_mut(id), id))
|
||||
ids.first().map(|id| (buff_comp_buffs.get_mut(id), id))
|
||||
{
|
||||
tick_buff(*id, buff, dt, |id| expired_buffs.push(id));
|
||||
}
|
||||
@ -262,7 +262,7 @@ impl<'a> System<'a> for Sys {
|
||||
buff.kind,
|
||||
buff.time,
|
||||
&read_data,
|
||||
&mut *stat,
|
||||
&mut stat,
|
||||
health,
|
||||
energy,
|
||||
entity,
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(bool_to_option, let_else, btree_drain_filter)]
|
||||
#![feature(let_else, btree_drain_filter, bool_to_option)]
|
||||
#![allow(clippy::option_map_unit_fn)]
|
||||
|
||||
mod aura;
|
||||
|
@ -540,7 +540,7 @@ impl<'a> PhysicsData<'a> {
|
||||
.join()
|
||||
{
|
||||
let vol = match collider {
|
||||
Collider::Voxel { id } => voxel_colliders_manifest.colliders.get(&*id),
|
||||
Collider::Voxel { id } => voxel_colliders_manifest.colliders.get(id),
|
||||
Collider::Volume(vol) => Some(&**vol),
|
||||
_ => None,
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ fn main() {
|
||||
.short('m')
|
||||
.long("mode")
|
||||
.takes_value(true)
|
||||
.possible_values(&["server", "client", "both"])
|
||||
.possible_values(["server", "client", "both"])
|
||||
.default_value("both")
|
||||
.help(
|
||||
"choose whether you want to start the server or client or both needed for \
|
||||
@ -50,7 +50,7 @@ fn main() {
|
||||
.long("protocol")
|
||||
.takes_value(true)
|
||||
.default_value("tcp")
|
||||
.possible_values(&["tcp", "upd", "mpsc"])
|
||||
.possible_values(["tcp", "upd", "mpsc"])
|
||||
.help(
|
||||
"underlying protocol used for this test, mpsc can only combined with mode=both",
|
||||
),
|
||||
@ -61,7 +61,7 @@ fn main() {
|
||||
.long("trace")
|
||||
.takes_value(true)
|
||||
.default_value("warn")
|
||||
.possible_values(&["trace", "debug", "info", "warn", "error"])
|
||||
.possible_values(["trace", "debug", "info", "warn", "error"])
|
||||
.help("set trace level, not this has a performance impact!"),
|
||||
)
|
||||
.get_matches();
|
||||
|
@ -22,7 +22,7 @@ pub enum Command {
|
||||
Get(u32),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct FileInfo {
|
||||
id: u32,
|
||||
pub path: String,
|
||||
|
@ -34,7 +34,7 @@ fn main() {
|
||||
.long("trace")
|
||||
.takes_value(true)
|
||||
.default_value("warn")
|
||||
.possible_values(&["trace", "debug", "info", "warn", "error"])
|
||||
.possible_values(["trace", "debug", "info", "warn", "error"])
|
||||
.help("set trace level, not this has a performance impact!"),
|
||||
)
|
||||
.get_matches();
|
||||
|
@ -36,7 +36,7 @@ fn main() {
|
||||
.short('m')
|
||||
.long("mode")
|
||||
.takes_value(true)
|
||||
.possible_values(&["server", "client", "both"])
|
||||
.possible_values(["server", "client", "both"])
|
||||
.default_value("both")
|
||||
.help(
|
||||
"choose whether you want to start the server or client or both needed for \
|
||||
@ -63,7 +63,7 @@ fn main() {
|
||||
.long("protocol")
|
||||
.takes_value(true)
|
||||
.default_value("tcp")
|
||||
.possible_values(&["tcp", "udp", "mpsc"])
|
||||
.possible_values(["tcp", "udp", "mpsc"])
|
||||
.help(
|
||||
"underlying protocol used for this test, mpsc can only combined with mode=both",
|
||||
),
|
||||
@ -74,7 +74,7 @@ fn main() {
|
||||
.long("trace")
|
||||
.takes_value(true)
|
||||
.default_value("warn")
|
||||
.possible_values(&["trace", "debug", "info", "warn", "error"])
|
||||
.possible_values(["trace", "debug", "info", "warn", "error"])
|
||||
.help("set trace level, not this has a performance impact!"),
|
||||
)
|
||||
.get_matches();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/// All possible Errors that can happen during Handshake [`InitProtocol`]
|
||||
///
|
||||
/// [`InitProtocol`]: crate::InitProtocol
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum InitProtocolError<E: std::fmt::Debug + Send> {
|
||||
Custom(E),
|
||||
/// expected Handshake, didn't get handshake
|
||||
@ -13,7 +13,7 @@ pub enum InitProtocolError<E: std::fmt::Debug + Send> {
|
||||
}
|
||||
|
||||
/// When you return closed you must stay closed!
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ProtocolError<E: std::fmt::Debug + Send> {
|
||||
/// Custom Error on the underlying I/O,
|
||||
/// e.g. the TCP, UDP or MPSC connection is dropped by the OS
|
||||
|
@ -9,7 +9,7 @@ use bytes::Bytes;
|
||||
/// [`SendProtocol`]: crate::SendProtocol
|
||||
/// [`RecvProtocol`]: crate::RecvProtocol
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(test, derive(PartialEq))]
|
||||
#[cfg_attr(test, derive(PartialEq, Eq))]
|
||||
pub enum ProtocolEvent {
|
||||
Shutdown,
|
||||
OpenStream {
|
||||
|
@ -14,7 +14,7 @@ const FRAME_RAW: u8 = 8;
|
||||
//const FRAME_RESERVED_3: u8 = 13;
|
||||
|
||||
/// Used for Communication between Channel <----(TCP/UDP)----> Channel
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum InitFrame {
|
||||
Handshake {
|
||||
magic_number: [u8; 7],
|
||||
@ -30,7 +30,7 @@ pub enum InitFrame {
|
||||
}
|
||||
|
||||
/// Used for OUT TCP Communication between Channel --(TCP)--> Channel
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum OTFrame {
|
||||
Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully),
|
||||
* Participant is deleted */
|
||||
@ -55,7 +55,7 @@ pub enum OTFrame {
|
||||
}
|
||||
|
||||
/// Used for IN TCP Communication between Channel <--(TCP)-- Channel
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum ITFrame {
|
||||
Shutdown, /* Shutdown this channel gracefully, if all channels are shutdown (gracefully),
|
||||
* Participant is deleted */
|
||||
@ -113,7 +113,7 @@ impl InitFrame {
|
||||
}
|
||||
|
||||
pub(crate) fn read_frame(bytes: &mut BytesMut) -> Option<Self> {
|
||||
let frame_no = match bytes.get(0) {
|
||||
let frame_no = match bytes.first() {
|
||||
Some(&f) => f,
|
||||
None => return None,
|
||||
};
|
||||
@ -454,7 +454,7 @@ mod tests {
|
||||
magic_number: VELOREN_MAGIC_NUMBER,
|
||||
version: VELOREN_NETWORK_VERSION,
|
||||
};
|
||||
let _ = InitFrame::write_bytes(frame1, &mut buffer);
|
||||
InitFrame::write_bytes(frame1, &mut buffer);
|
||||
buffer.truncate(6); // simulate partial retrieve
|
||||
let frame1d = InitFrame::read_frame(&mut buffer);
|
||||
assert_eq!(frame1d, None);
|
||||
@ -474,7 +474,7 @@ mod tests {
|
||||
let mut buffer = BytesMut::with_capacity(50);
|
||||
|
||||
let frame1 = InitFrame::Raw(b"foobar".to_vec());
|
||||
let _ = InitFrame::write_bytes(frame1.clone(), &mut buffer);
|
||||
InitFrame::write_bytes(frame1.clone(), &mut buffer);
|
||||
buffer[1] = 255;
|
||||
let framed = InitFrame::read_frame(&mut buffer);
|
||||
assert_eq!(framed, Some(frame1));
|
||||
@ -485,7 +485,7 @@ mod tests {
|
||||
let mut buffer = BytesMut::with_capacity(50);
|
||||
|
||||
let frame1 = InitFrame::Raw(b"foobar".to_vec());
|
||||
let _ = InitFrame::write_bytes(frame1, &mut buffer);
|
||||
InitFrame::write_bytes(frame1, &mut buffer);
|
||||
buffer[1] = 3;
|
||||
let framed = InitFrame::read_frame(&mut buffer);
|
||||
// we accept a different frame here, as it's RAW and debug only!
|
||||
|
@ -18,7 +18,7 @@ use tracing::info;
|
||||
#[cfg(feature = "trace_pedantic")]
|
||||
use tracing::trace;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub enum QuicDataFormatStream {
|
||||
Main,
|
||||
Reliable(Sid),
|
||||
|
@ -121,7 +121,7 @@ pub enum NetworkConnectError {
|
||||
}
|
||||
|
||||
/// Error type thrown by [`Participants`](Participant) methods
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum ParticipantError {
|
||||
///Participant was closed by remote side
|
||||
ParticipantDisconnected,
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(clippy::clone_on_ref_ptr)]
|
||||
#![feature(bool_to_option)]
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[global_allocator]
|
||||
|
@ -13,7 +13,7 @@ use vek::Vec2;
|
||||
/// Deferring allows us to remove code duplication and maybe serialize ONCE,
|
||||
/// send to MULTIPLE clients
|
||||
/// TODO: store a urgent flag and seperate even more, 5 ticks vs 5 seconds
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ChunkSendEntry {
|
||||
pub(crate) entity: Entity,
|
||||
pub(crate) chunk_key: Vec2<i32>,
|
||||
|
@ -517,7 +517,7 @@ fn handle_give_item(
|
||||
) -> CmdResult<()> {
|
||||
if let (Some(item_name), give_amount_opt) = parse_cmd_args!(args, String, u32) {
|
||||
let give_amount = give_amount_opt.unwrap_or(1);
|
||||
if let Ok(item) = Item::new_from_asset(&item_name.replace('/', ".").replace('\\', ".")) {
|
||||
if let Ok(item) = Item::new_from_asset(&item_name.replace(['/', '\\'], ".")) {
|
||||
let mut item: Item = item;
|
||||
let mut res = Ok(());
|
||||
|
||||
@ -1844,7 +1844,7 @@ fn handle_kill_npcs(
|
||||
true
|
||||
};
|
||||
|
||||
should_kill.then(|| entity)
|
||||
should_kill.then_some(entity)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
@ -278,7 +278,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt
|
||||
let entry = damage_contributors
|
||||
.entry(DamageContrib::Group(*group))
|
||||
.or_insert((0, 0.0));
|
||||
(*entry).0 += damage;
|
||||
entry.0 += damage;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ impl Server {
|
||||
use std::fs;
|
||||
|
||||
match || -> Result<_, Box<dyn std::error::Error>> {
|
||||
let key = fs::read(&key_file_path)?;
|
||||
let key = fs::read(key_file_path)?;
|
||||
let key = if key_file_path.extension().map_or(false, |x| x == "der") {
|
||||
rustls::PrivateKey(key)
|
||||
} else {
|
||||
@ -506,7 +506,7 @@ impl Server {
|
||||
.ok_or("No valid pem key in file")?;
|
||||
rustls::PrivateKey(key)
|
||||
};
|
||||
let cert_chain = fs::read(&cert_file_path)?;
|
||||
let cert_chain = fs::read(cert_file_path)?;
|
||||
let cert_chain = if cert_file_path.extension().map_or(false, |x| x == "der")
|
||||
{
|
||||
vec![rustls::Certificate(cert_chain)]
|
||||
@ -585,7 +585,7 @@ impl Server {
|
||||
let editable_settings = self.state.ecs().fetch::<EditableSettings>();
|
||||
ServerInfo {
|
||||
name: settings.server_name.clone(),
|
||||
description: (&*editable_settings.server_description).clone(),
|
||||
description: (*editable_settings.server_description).clone(),
|
||||
git_hash: common::util::GIT_HASH.to_string(),
|
||||
git_date: common::util::GIT_DATE.to_string(),
|
||||
auth_provider: settings.auth_server_address.clone(),
|
||||
|
@ -86,7 +86,7 @@ impl CharacterLoader {
|
||||
// This connection -must- remain read-only to avoid lock contention with the
|
||||
// CharacterUpdater thread.
|
||||
let mut conn =
|
||||
establish_connection(&*settings.read().unwrap(), ConnectionMode::ReadOnly);
|
||||
establish_connection(&settings.read().unwrap(), ConnectionMode::ReadOnly);
|
||||
|
||||
for request in internal_rx {
|
||||
conn.update_log_mode(&settings);
|
||||
|
@ -83,7 +83,7 @@ impl CharacterUpdater {
|
||||
// Unwrap here is safe as there is no code that can panic when the write lock is
|
||||
// taken that could cause the RwLock to become poisoned.
|
||||
let mut conn =
|
||||
establish_connection(&*settings.read().unwrap(), ConnectionMode::ReadWrite);
|
||||
establish_connection(&settings.read().unwrap(), ConnectionMode::ReadWrite);
|
||||
while let Ok(updates) = update_rx.recv() {
|
||||
match updates {
|
||||
CharacterUpdaterEvent::BatchUpdate(updates) => {
|
||||
|
@ -63,12 +63,12 @@ impl VelorenConnection {
|
||||
let settings = database_settings
|
||||
.read()
|
||||
.expect("DatabaseSettings RwLock was poisoned");
|
||||
if self.sql_log_mode == (*settings).sql_log_mode {
|
||||
if self.sql_log_mode == settings.sql_log_mode {
|
||||
return;
|
||||
}
|
||||
|
||||
set_log_mode(&mut self.connection, (*settings).sql_log_mode);
|
||||
self.sql_log_mode = (*settings).sql_log_mode;
|
||||
set_log_mode(&mut self.connection, settings.sql_log_mode);
|
||||
self.sql_log_mode = settings.sql_log_mode;
|
||||
|
||||
info!(
|
||||
"SQL log mode for connection changed to {:?}",
|
||||
@ -106,13 +106,13 @@ pub struct DatabaseSettings {
|
||||
pub sql_log_mode: SqlLogMode,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ConnectionMode {
|
||||
ReadOnly,
|
||||
ReadWrite,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum SqlLogMode {
|
||||
/// Logging is disabled
|
||||
Disabled,
|
||||
@ -199,10 +199,8 @@ pub(crate) fn establish_connection(
|
||||
settings: &DatabaseSettings,
|
||||
connection_mode: ConnectionMode,
|
||||
) -> VelorenConnection {
|
||||
fs::create_dir_all(&settings.db_dir).expect(&*format!(
|
||||
"Failed to create saves directory: {:?}",
|
||||
&settings.db_dir
|
||||
));
|
||||
fs::create_dir_all(&settings.db_dir)
|
||||
.unwrap_or_else(|_| panic!("Failed to create saves directory: {:?}", &settings.db_dir));
|
||||
|
||||
let open_flags = OpenFlags::SQLITE_OPEN_PRIVATE_CACHE
|
||||
| OpenFlags::SQLITE_OPEN_NO_MUTEX
|
||||
|
@ -88,7 +88,7 @@ impl Entity {
|
||||
.into()
|
||||
},
|
||||
_ => {
|
||||
let species = *(&comp::humanoid::ALL_SPECIES)
|
||||
let species = *comp::humanoid::ALL_SPECIES
|
||||
.choose(&mut self.rng(PERM_SPECIES))
|
||||
.unwrap();
|
||||
comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into()
|
||||
@ -102,7 +102,7 @@ impl Entity {
|
||||
| RtSimEntityKind::Alchemist
|
||||
| RtSimEntityKind::Blacksmith
|
||||
| RtSimEntityKind::Merchant => {
|
||||
let species = *(&comp::humanoid::ALL_SPECIES)
|
||||
let species = *comp::humanoid::ALL_SPECIES
|
||||
.choose(&mut self.rng(PERM_SPECIES))
|
||||
.unwrap();
|
||||
comp::humanoid::Body::random_with(&mut self.rng(PERM_BODY), &species).into()
|
||||
|
@ -703,8 +703,10 @@ impl StateExt for State {
|
||||
msg: &str,
|
||||
) -> bool {
|
||||
let mut automod = self.ecs().write_resource::<AutoMod>();
|
||||
let Some(client) = self.ecs().read_storage::<Client>().get(entity) else { return true };
|
||||
let Some(player) = self.ecs().read_storage::<Player>().get(entity) else { return true };
|
||||
let client = self.ecs().read_storage::<Client>();
|
||||
let player = self.ecs().read_storage::<Player>();
|
||||
let Some(client) = client.get(entity) else { return true };
|
||||
let Some(player) = player.get(entity) else { return true };
|
||||
|
||||
match automod.validate_chat_msg(
|
||||
player.uuid(),
|
||||
|
@ -557,7 +557,7 @@ impl<'a> AgentData<'a> {
|
||||
tgt_pos: &Pos,
|
||||
) {
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*terrain,
|
||||
terrain,
|
||||
self.pos.0,
|
||||
self.vel.0,
|
||||
tgt_pos.0,
|
||||
@ -666,7 +666,7 @@ impl<'a> AgentData<'a> {
|
||||
}
|
||||
|
||||
if let Some((bearing, speed)) = agent.chaser.chase(
|
||||
&*terrain,
|
||||
terrain,
|
||||
self.pos.0,
|
||||
self.vel.0,
|
||||
// Away from the target (ironically)
|
||||
|
@ -393,7 +393,7 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
let outcomes = outcomes
|
||||
.iter()
|
||||
.filter(|o| o.get_pos().and_then(&is_near).unwrap_or(true))
|
||||
.filter(|o| o.get_pos().and_then(is_near).unwrap_or(true))
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
@ -136,9 +136,9 @@ impl<'a> System<'a> for Sys {
|
||||
&ecs_world,
|
||||
#[cfg(feature = "plugins")]
|
||||
&read_data._plugin_mgr,
|
||||
&*read_data.editable_settings.admins,
|
||||
&*read_data.editable_settings.whitelist,
|
||||
&*read_data.editable_settings.banlist,
|
||||
&read_data.editable_settings.admins,
|
||||
&read_data.editable_settings.whitelist,
|
||||
&read_data.editable_settings.banlist,
|
||||
player_count >= max_players,
|
||||
) {
|
||||
None => return Ok(()),
|
||||
@ -232,11 +232,11 @@ impl<'a> System<'a> for Sys {
|
||||
time_of_day: *read_data.time_of_day,
|
||||
max_group_size: read_data.settings.max_player_group_size,
|
||||
client_timeout: read_data.settings.client_timeout,
|
||||
world_map: (&*read_data.map).clone(),
|
||||
world_map: (*read_data.map).clone(),
|
||||
recipe_book: default_recipe_book().cloned(),
|
||||
component_recipe_book: default_component_recipe_book().cloned(),
|
||||
material_stats: (&*read_data.material_stats).clone(),
|
||||
ability_map: (&*read_data.ability_map).clone(),
|
||||
material_stats: (*read_data.material_stats).clone(),
|
||||
ability_map: (*read_data.ability_map).clone(),
|
||||
})?;
|
||||
debug!("Done initial sync with client.");
|
||||
|
||||
|
@ -436,7 +436,7 @@ impl NpcData {
|
||||
comp::Agent::from_body(&body)
|
||||
.with_behavior(
|
||||
Behavior::default()
|
||||
.maybe_with_capabilities(can_speak.then(|| BehaviorCapability::SPEAK))
|
||||
.maybe_with_capabilities(can_speak.then_some(BehaviorCapability::SPEAK))
|
||||
.with_trade_site(trade_for_site),
|
||||
)
|
||||
.with_patrol_origin(pos)
|
||||
|
@ -286,17 +286,17 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Sandcrawler, _) => (2.5, 7.0, -5.5),
|
||||
},
|
||||
scaler: match (body.species, body.body_type) {
|
||||
(Tarantula, _) => (1.0),
|
||||
(Blackwidow, _) => (1.0),
|
||||
(Antlion, _) => (1.0),
|
||||
(Hornbeetle, _) => (0.8),
|
||||
(Leafbeetle, _) => (0.8),
|
||||
(Stagbeetle, _) => (0.8),
|
||||
(Weevil, _) => (0.8),
|
||||
(Cavespider, _) => (1.0),
|
||||
(Moltencrawler, _) => (0.8),
|
||||
(Mosscrawler, _) => (0.8),
|
||||
(Sandcrawler, _) => (0.8),
|
||||
(Tarantula, _) => 1.0,
|
||||
(Blackwidow, _) => 1.0,
|
||||
(Antlion, _) => 1.0,
|
||||
(Hornbeetle, _) => 0.8,
|
||||
(Leafbeetle, _) => 0.8,
|
||||
(Stagbeetle, _) => 0.8,
|
||||
(Weevil, _) => 0.8,
|
||||
(Cavespider, _) => 1.0,
|
||||
(Moltencrawler, _) => 0.8,
|
||||
(Mosscrawler, _) => 0.8,
|
||||
(Sandcrawler, _) => 0.8,
|
||||
},
|
||||
// Z ori (front, front center, back center, center)
|
||||
leg_ori: match (body.species, body.body_type) {
|
||||
|
@ -276,24 +276,24 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(WealdWyvern, _) => (0.5, 0.0, -3.5),
|
||||
},
|
||||
scaler: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (1.0),
|
||||
(Cockatrice, _) => (1.0),
|
||||
(Roc, _) => (1.0),
|
||||
(Phoenix, _) => 1.0,
|
||||
(Cockatrice, _) => 1.0,
|
||||
(Roc, _) => 1.0,
|
||||
(FlameWyvern, _)
|
||||
| (CloudWyvern, _)
|
||||
| (FrostWyvern, _)
|
||||
| (SeaWyvern, _)
|
||||
| (WealdWyvern, _) => (1.0),
|
||||
| (WealdWyvern, _) => 1.0,
|
||||
},
|
||||
feed: match (body.species, body.body_type) {
|
||||
(Phoenix, _) => (-0.65),
|
||||
(Cockatrice, _) => (-0.5),
|
||||
(Roc, _) => (-0.4),
|
||||
(Phoenix, _) => -0.65,
|
||||
(Cockatrice, _) => -0.5,
|
||||
(Roc, _) => -0.4,
|
||||
(FlameWyvern, _)
|
||||
| (CloudWyvern, _)
|
||||
| (FrostWyvern, _)
|
||||
| (SeaWyvern, _)
|
||||
| (WealdWyvern, _) => (-0.65),
|
||||
| (WealdWyvern, _) => -0.65,
|
||||
},
|
||||
wyvern: matches!(
|
||||
(body.species, body.body_type),
|
||||
|
@ -167,7 +167,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Reddragon, _) => (6.0, -2.0, -10.5),
|
||||
},
|
||||
height: match (body.species, body.body_type) {
|
||||
(Reddragon, _) => (1.0),
|
||||
(Reddragon, _) => 1.0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -331,42 +331,42 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
_ => (0.0, 1.0),
|
||||
},
|
||||
scaler: match (body.species, body.body_type) {
|
||||
(Crocodile, _) => (1.05),
|
||||
(SeaCrocodile, _) => (1.05),
|
||||
(Alligator, _) => (1.12),
|
||||
(Salamander, _) => (1.12),
|
||||
(Monitor, _) => (0.9),
|
||||
(Asp, _) => (1.12),
|
||||
(Rocksnapper, _) => (1.12),
|
||||
(Rootsnapper, _) => (1.12),
|
||||
(Reefsnapper, _) => (1.12),
|
||||
(Hakulaq, _) => (1.05),
|
||||
(Dagon, _) => (1.05),
|
||||
(Pangolin, _) => (1.05),
|
||||
(Maneater, _) => (1.12),
|
||||
(Lavadrake, _) => (1.12),
|
||||
(Icedrake, _) => (1.12),
|
||||
(Basilisk, _) => (1.3),
|
||||
_ => (0.9),
|
||||
(Crocodile, _) => 1.05,
|
||||
(SeaCrocodile, _) => 1.05,
|
||||
(Alligator, _) => 1.12,
|
||||
(Salamander, _) => 1.12,
|
||||
(Monitor, _) => 0.9,
|
||||
(Asp, _) => 1.12,
|
||||
(Rocksnapper, _) => 1.12,
|
||||
(Rootsnapper, _) => 1.12,
|
||||
(Reefsnapper, _) => 1.12,
|
||||
(Hakulaq, _) => 1.05,
|
||||
(Dagon, _) => 1.05,
|
||||
(Pangolin, _) => 1.05,
|
||||
(Maneater, _) => 1.12,
|
||||
(Lavadrake, _) => 1.12,
|
||||
(Icedrake, _) => 1.12,
|
||||
(Basilisk, _) => 1.3,
|
||||
_ => 0.9,
|
||||
},
|
||||
tempo: match (body.species, body.body_type) {
|
||||
(Crocodile, _) => (0.7),
|
||||
(SeaCrocodile, _) => (0.7),
|
||||
(Alligator, _) => (0.7),
|
||||
(Salamander, _) => (0.85),
|
||||
(Monitor, _) => (1.4),
|
||||
(Tortoise, _) => (0.7),
|
||||
(Rocksnapper, _) => (0.7),
|
||||
(Rootsnapper, _) => (0.7),
|
||||
(Reefsnapper, _) => (0.7),
|
||||
(Hakulaq, _) => (1.2),
|
||||
(Dagon, _) => (1.2),
|
||||
(Pangolin, _) => (1.15),
|
||||
(Maneater, _) => (0.9),
|
||||
(Lavadrake, _) => (1.1),
|
||||
(Icedrake, _) => (1.1),
|
||||
(Basilisk, _) => (0.8),
|
||||
_ => (1.0),
|
||||
(Crocodile, _) => 0.7,
|
||||
(SeaCrocodile, _) => 0.7,
|
||||
(Alligator, _) => 0.7,
|
||||
(Salamander, _) => 0.85,
|
||||
(Monitor, _) => 1.4,
|
||||
(Tortoise, _) => 0.7,
|
||||
(Rocksnapper, _) => 0.7,
|
||||
(Rootsnapper, _) => 0.7,
|
||||
(Reefsnapper, _) => 0.7,
|
||||
(Hakulaq, _) => 1.2,
|
||||
(Dagon, _) => 1.2,
|
||||
(Pangolin, _) => 1.15,
|
||||
(Maneater, _) => 0.9,
|
||||
(Lavadrake, _) => 1.1,
|
||||
(Icedrake, _) => 1.1,
|
||||
(Basilisk, _) => 0.8,
|
||||
_ => 1.0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user