adjust fmt and clippy after toolchain upgrade

This commit is contained in:
Marcel Märtens 2020-12-10 12:50:48 +01:00
parent b2a814b1d7
commit ccb01e1898
38 changed files with 249 additions and 241 deletions

View File

@ -1338,6 +1338,7 @@ impl Client {
Ok(()) Ok(())
} }
#[allow(clippy::unnecessary_wraps)]
fn handle_server_in_game_msg( fn handle_server_in_game_msg(
&mut self, &mut self,
frontend_events: &mut Vec<Event>, frontend_events: &mut Vec<Event>,
@ -1492,6 +1493,7 @@ impl Client {
Ok(()) Ok(())
} }
#[allow(clippy::unnecessary_wraps)]
fn handle_server_character_screen_msg( fn handle_server_character_screen_msg(
&mut self, &mut self,
events: &mut Vec<Event>, events: &mut Vec<Event>,
@ -1765,7 +1767,7 @@ impl Client {
comp::ChatType::Online(uid) => { comp::ChatType::Online(uid) => {
// Default message formats if no localized message string is set by hud // Default message formats if no localized message string is set by hud
// Needed for cli clients that don't set localization info // Needed for cli clients that don't set localization info
if message == "" { if message.is_empty() {
format!("[{}] came online", alias_of_uid(uid)) format!("[{}] came online", alias_of_uid(uid))
} else { } else {
message.replace("{name}", &alias_of_uid(uid)) message.replace("{name}", &alias_of_uid(uid))
@ -1774,7 +1776,7 @@ impl Client {
comp::ChatType::Offline(uid) => { comp::ChatType::Offline(uid) => {
// Default message formats if no localized message string is set by hud // Default message formats if no localized message string is set by hud
// Needed for cli clients that don't set localization info // Needed for cli clients that don't set localization info
if message == "" { if message.is_empty() {
format!("[{}] went offline", alias_of_uid(uid)) format!("[{}] went offline", alias_of_uid(uid))
} else { } else {
message.replace("{name}", &alias_of_uid(uid)) message.replace("{name}", &alias_of_uid(uid))
@ -1788,7 +1790,7 @@ impl Client {
comp::ChatType::Kill(kill_source, victim) => { comp::ChatType::Kill(kill_source, victim) => {
// Default message formats if no localized message string is set by hud // Default message formats if no localized message string is set by hud
// Needed for cli clients that don't set localization info // Needed for cli clients that don't set localization info
if message == "" { if message.is_empty() {
match kill_source { match kill_source {
KillSource::Player(attacker_uid, KillType::Melee) => format!( KillSource::Player(attacker_uid, KillType::Melee) => format!(
"[{}] killed [{}]", "[{}] killed [{}]",

View File

@ -82,20 +82,21 @@ pub enum CharacterState {
impl CharacterState { impl CharacterState {
pub fn is_wield(&self) -> bool { pub fn is_wield(&self) -> bool {
matches!(self, matches!(
self,
CharacterState::Wielding CharacterState::Wielding
| CharacterState::BasicMelee(_) | CharacterState::BasicMelee(_)
| CharacterState::BasicRanged(_) | CharacterState::BasicRanged(_)
| CharacterState::DashMelee(_) | CharacterState::DashMelee(_)
| CharacterState::ComboMelee(_) | CharacterState::ComboMelee(_)
| CharacterState::BasicBlock | CharacterState::BasicBlock
| CharacterState::LeapMelee(_) | CharacterState::LeapMelee(_)
| CharacterState::SpinMelee(_) | CharacterState::SpinMelee(_)
| CharacterState::ChargedMelee(_) | CharacterState::ChargedMelee(_)
| CharacterState::ChargedRanged(_) | CharacterState::ChargedRanged(_)
| CharacterState::RepeaterRanged(_) | CharacterState::RepeaterRanged(_)
| CharacterState::Shockwave(_) | CharacterState::Shockwave(_)
| CharacterState::BasicBeam(_) | CharacterState::BasicBeam(_)
) )
} }
@ -104,35 +105,37 @@ impl CharacterState {
} }
pub fn is_attack(&self) -> bool { pub fn is_attack(&self) -> bool {
matches!(self, matches!(
self,
CharacterState::BasicMelee(_) CharacterState::BasicMelee(_)
| CharacterState::BasicRanged(_) | CharacterState::BasicRanged(_)
| CharacterState::DashMelee(_) | CharacterState::DashMelee(_)
| CharacterState::ComboMelee(_) | CharacterState::ComboMelee(_)
| CharacterState::LeapMelee(_) | CharacterState::LeapMelee(_)
| CharacterState::SpinMelee(_) | CharacterState::SpinMelee(_)
| CharacterState::ChargedMelee(_) | CharacterState::ChargedMelee(_)
| CharacterState::ChargedRanged(_) | CharacterState::ChargedRanged(_)
| CharacterState::RepeaterRanged(_) | CharacterState::RepeaterRanged(_)
| CharacterState::Shockwave(_) | CharacterState::Shockwave(_)
| CharacterState::BasicBeam(_) | CharacterState::BasicBeam(_)
) )
} }
pub fn is_aimed(&self) -> bool { pub fn is_aimed(&self) -> bool {
matches!(self, matches!(
self,
CharacterState::BasicMelee(_) CharacterState::BasicMelee(_)
| CharacterState::BasicRanged(_) | CharacterState::BasicRanged(_)
| CharacterState::DashMelee(_) | CharacterState::DashMelee(_)
| CharacterState::ComboMelee(_) | CharacterState::ComboMelee(_)
| CharacterState::BasicBlock | CharacterState::BasicBlock
| CharacterState::LeapMelee(_) | CharacterState::LeapMelee(_)
| CharacterState::ChargedMelee(_) | CharacterState::ChargedMelee(_)
| CharacterState::ChargedRanged(_) | CharacterState::ChargedRanged(_)
| CharacterState::RepeaterRanged(_) | CharacterState::RepeaterRanged(_)
| CharacterState::Shockwave(_) | CharacterState::Shockwave(_)
| CharacterState::BasicBeam(_) | CharacterState::BasicBeam(_)
| CharacterState::Wielding | CharacterState::Wielding
) )
} }

View File

@ -144,10 +144,13 @@ impl PartialEq for ItemDef {
impl ItemDef { impl ItemDef {
pub fn is_stackable(&self) -> bool { pub fn is_stackable(&self) -> bool {
matches!(self.kind, ItemKind::Consumable { .. } matches!(
| ItemKind::Ingredient { .. } self.kind,
| ItemKind::Throwable { .. } ItemKind::Consumable { .. }
| ItemKind::Utility { .. }) | ItemKind::Ingredient { .. }
| ItemKind::Throwable { .. }
| ItemKind::Utility { .. }
)
} }
} }

View File

@ -70,20 +70,20 @@ impl EquipSlot {
impl ArmorSlot { impl ArmorSlot {
fn can_hold(self, armor: &item::armor::ArmorKind) -> bool { fn can_hold(self, armor: &item::armor::ArmorKind) -> bool {
use item::armor::ArmorKind; use item::armor::ArmorKind;
match (self, armor) { matches!(
(Self::Head, ArmorKind::Head(_)) => true, (self, armor),
(Self::Neck, ArmorKind::Neck(_)) => true, (Self::Head, ArmorKind::Head(_))
(Self::Shoulders, ArmorKind::Shoulder(_)) => true, | (Self::Neck, ArmorKind::Neck(_))
(Self::Chest, ArmorKind::Chest(_)) => true, | (Self::Shoulders, ArmorKind::Shoulder(_))
(Self::Hands, ArmorKind::Hand(_)) => true, | (Self::Chest, ArmorKind::Chest(_))
(Self::Ring, ArmorKind::Ring(_)) => true, | (Self::Hands, ArmorKind::Hand(_))
(Self::Back, ArmorKind::Back(_)) => true, | (Self::Ring, ArmorKind::Ring(_))
(Self::Belt, ArmorKind::Belt(_)) => true, | (Self::Back, ArmorKind::Back(_))
(Self::Legs, ArmorKind::Pants(_)) => true, | (Self::Belt, ArmorKind::Belt(_))
(Self::Feet, ArmorKind::Foot(_)) => true, | (Self::Legs, ArmorKind::Pants(_))
(Self::Tabard, ArmorKind::Tabard(_)) => true, | (Self::Feet, ArmorKind::Foot(_))
_ => false, | (Self::Tabard, ArmorKind::Tabard(_))
} )
} }
} }

View File

@ -73,7 +73,7 @@ lazy_static! {
impl FromStr for NpcKind { impl FromStr for NpcKind {
type Err = (); type Err = ();
fn from_str(s: &str) -> Result<Self, ()> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let npc_names = &*NPC_NAMES; let npc_names = &*NPC_NAMES;
ALL_NPCS ALL_NPCS
.iter() .iter()
@ -126,13 +126,14 @@ impl FromStr for NpcBody {
/// associated species, generate the species randomly within it; if an /// associated species, generate the species randomly within it; if an
/// explicit species is found, generate a random member of the species; /// explicit species is found, generate a random member of the species;
/// otherwise, return Err(()). /// otherwise, return Err(()).
fn from_str(s: &str) -> Result<Self, ()> { Self::from_str_with(s, kind_to_body) } fn from_str(s: &str) -> Result<Self, Self::Err> { Self::from_str_with(s, kind_to_body) }
} }
impl NpcBody { impl NpcBody {
/// If there is an exact name match for a body kind, call kind_to_body on /// If there is an exact name match for a body kind, call kind_to_body on
/// it. Otherwise, if an explicit species is found, generate a random /// it. Otherwise, if an explicit species is found, generate a random
/// member of the species; otherwise, return Err(()). /// member of the species; otherwise, return Err(()).
#[allow(clippy::result_unit_err)]
pub fn from_str_with(s: &str, kind_to_body: fn(NpcKind) -> Body) -> Result<Self, ()> { pub fn from_str_with(s: &str, kind_to_body: fn(NpcKind) -> Body) -> Result<Self, ()> {
fn parse< fn parse<
'a, 'a,

View File

@ -133,21 +133,13 @@ impl Body {
} }
pub fn can_fly(&self) -> bool { pub fn can_fly(&self) -> bool {
match self { matches!(
Body::BirdMedium(_) => true, self,
Body::Dragon(_) => true, Body::BirdMedium(_) | Body::Dragon(_) | Body::BirdSmall(_)
Body::BirdSmall(_) => true, )
_ => false,
}
} }
#[allow(clippy::match_like_matches_macro)] pub fn can_climb(&self) -> bool { matches!(self, Body::Humanoid(_)) }
pub fn can_climb(&self) -> bool {
match self {
Body::Humanoid(_) => true,
_ => false,
}
}
} }
/// Handles updating `Components` to move player based on state of `JoinData` /// Handles updating `Components` to move player based on state of `JoinData`

View File

@ -155,6 +155,7 @@ impl MapSizeLg {
/// that these invariants indeed hold, safely opening up optimizations /// that these invariants indeed hold, safely opening up optimizations
/// that might not otherwise be available at runtime. /// that might not otherwise be available at runtime.
#[inline(always)] #[inline(always)]
#[allow(clippy::result_unit_err)]
pub const fn new(map_size_lg: Vec2<u32>) -> Result<Self, ()> { pub const fn new(map_size_lg: Vec2<u32>) -> Result<Self, ()> {
// Assertion on dimensions: must be between // Assertion on dimensions: must be between
// 0 and ([MAX_WORLD_BLOCKS_LG] - [TERRAIN_CHUNK_BLOCKS_LG]) // 0 and ([MAX_WORLD_BLOCKS_LG] - [TERRAIN_CHUNK_BLOCKS_LG])

View File

@ -259,8 +259,8 @@ pub fn quadratic_nearest_point(
// In the (unlikely?) case that distances are equal, prefer the earliest point along the // In the (unlikely?) case that distances are equal, prefer the earliest point along the
// river. // river.
.min_by(|&(ap, _, a), &(bp, _, b)| { .min_by(|&(ap, _, a), &(bp, _, b)| {
(a, ap < 0.0 || ap > 1.0, ap) (a, !(0.0..=1.0).contains(&ap), ap)
.partial_cmp(&(b, bp < 0.0 || bp > 1.0, bp)) .partial_cmp(&(b, !(0.0..=1.0).contains(&bp), bp))
.unwrap() .unwrap()
}); });
min_root min_root

View File

@ -81,7 +81,7 @@ pub fn hsv_to_rgb(hsv: Vec3<f32>) -> Rgb<f32> {
let x = c * (1.0 - (h % 2.0 - 1.0).abs()); let x = c * (1.0 - (h % 2.0 - 1.0).abs());
let m = v - c; let m = v - c;
let (r, g, b) = if h >= 0.0 && h <= 1.0 { let (r, g, b) = if (0.0..=1.0).contains(&h) {
(c, x, 0.0) (c, x, 0.0)
} else if h <= 2.0 { } else if h <= 2.0 {
(x, c, 0.0) (x, c, 0.0)

View File

@ -119,7 +119,7 @@ fn slerp_normalized(from: vek::Vec3<f32>, to: vek::Vec3<f32>, factor: f32) -> ve
{ {
let unnormalized = { let unnormalized = {
let len_sq = from.magnitude_squared(); let len_sq = from.magnitude_squared();
len_sq < 0.999 || len_sq > 1.001 !(0.999..=1.001).contains(&len_sq)
}; };
if unnormalized { if unnormalized {
@ -132,7 +132,7 @@ fn slerp_normalized(from: vek::Vec3<f32>, to: vek::Vec3<f32>, factor: f32) -> ve
{ {
let unnormalized = { let unnormalized = {
let len_sq = from.magnitude_squared(); let len_sq = from.magnitude_squared();
len_sq < 0.999 || len_sq > 1.001 !(0.999..=1.001).contains(&len_sq)
}; };
if unnormalized { if unnormalized {

View File

@ -13,12 +13,12 @@ lazy_static::lazy_static! {
static ref GIT_DATETIME: &'static str = GIT_VERSION.split('/').nth(1).expect("failed to retrieve git_datetime!"); static ref GIT_DATETIME: &'static str = GIT_VERSION.split('/').nth(1).expect("failed to retrieve git_datetime!");
pub static ref GIT_DATE: String = GIT_DATETIME.split('-').take(3).collect::<Vec<&str>>().join("-"); pub static ref GIT_DATE: String = GIT_DATETIME.split('-').take(3).collect::<Vec<&str>>().join("-");
pub static ref GIT_TIME: &'static str = GIT_DATETIME.split('-').nth(3).expect("failed to retrieve git_time!"); pub static ref GIT_TIME: &'static str = GIT_DATETIME.split('-').nth(3).expect("failed to retrieve git_time!");
pub static ref DISPLAY_VERSION: String = if GIT_TAG == "" { pub static ref DISPLAY_VERSION: String = if GIT_TAG.is_empty() {
format!("{}-{}", VELOREN_VERSION_STAGE, GIT_DATE.to_string()) format!("{}-{}", VELOREN_VERSION_STAGE, GIT_DATE.to_string())
} else { } else {
format!("{}-{}", VELOREN_VERSION_STAGE, GIT_TAG.to_string()) format!("{}-{}", VELOREN_VERSION_STAGE, GIT_TAG.to_string())
}; };
pub static ref DISPLAY_VERSION_LONG: String = if GIT_TAG == "" { pub static ref DISPLAY_VERSION_LONG: String = if GIT_TAG.is_empty() {
format!("{} ({})", DISPLAY_VERSION.as_str(), GIT_HASH.to_string()) format!("{} ({})", DISPLAY_VERSION.as_str(), GIT_HASH.to_string())
} else { } else {
format!("{} ({})", DISPLAY_VERSION.as_str(), GIT_VERSION.to_string()) format!("{} ({})", DISPLAY_VERSION.as_str(), GIT_VERSION.to_string())

View File

@ -56,7 +56,9 @@ pub fn init(basic: bool) {
.with_env_filter(filter); .with_env_filter(filter);
if basic { if basic {
subscriber.with_writer(|| StandardStream::stdout(ColorChoice::Auto)).init(); subscriber
.with_writer(|| StandardStream::stdout(ColorChoice::Auto))
.init();
} else { } else {
subscriber.with_writer(|| LOG.clone()).init(); subscriber.with_writer(|| LOG.clone()).init();
} }

View File

@ -25,6 +25,7 @@ use tracing::info;
const TPS: u64 = 30; const TPS: u64 = 30;
#[allow(clippy::unnecessary_wraps)]
fn main() -> io::Result<()> { fn main() -> io::Result<()> {
let matches = App::new("Veloren server cli") let matches = App::new("Veloren server cli")
.version(common::util::DISPLAY_VERSION_LONG.as_str()) .version(common::util::DISPLAY_VERSION_LONG.as_str())

View File

@ -204,12 +204,14 @@ impl Tui {
let block = Block::default().borders(Borders::ALL); let block = Block::default().borders(Borders::ALL);
let mut wrap = Wrap::default(); let wrap = Wrap {
wrap.scroll_callback = Some(Box::new(|text_area, lines| { scroll_callback: Some(Box::new(|text_area, lines| {
LOG.resize(text_area.height as usize); LOG.resize(text_area.height as usize);
let len = lines.len() as u16; let len = lines.len() as u16;
(len.saturating_sub(text_area.height), 0) (len.saturating_sub(text_area.height), 0)
})); })),
..Default::default()
};
let logger = Paragraph::new(LOG.inner.lock().unwrap().clone()) let logger = Paragraph::new(LOG.inner.lock().unwrap().clone())
.block(block) .block(block)

View File

@ -552,6 +552,7 @@ pub fn handle_respawn(server: &Server, entity: EcsEntity) {
} }
} }
#[allow(clippy::blocks_in_if_conditions)]
pub fn handle_explosion( pub fn handle_explosion(
server: &Server, server: &Server,
pos: Vec3<f32>, pos: Vec3<f32>,
@ -565,9 +566,18 @@ pub fn handle_explosion(
// Add an outcome // Add an outcome
// Uses radius as outcome power, makes negative if explosion has healing effect // Uses radius as outcome power, makes negative if explosion has healing effect
let outcome_power = explosion.radius let outcome_power = explosion.radius
* if explosion.effects.iter().any( * if explosion.effects.iter().any(|e| {
|e| matches!(e, RadiusEffect::Entity(_, Effect::Damage(Damage { source: DamageSource::Healing, .. }))) matches!(
) { e,
RadiusEffect::Entity(
_,
Effect::Damage(Damage {
source: DamageSource::Healing,
..
})
)
)
}) {
-1.0 -1.0
} else { } else {
1.0 1.0

View File

@ -572,6 +572,7 @@ mod tests {
use vek::Vec3; use vek::Vec3;
// Helper function // Helper function
#[allow(clippy::unnecessary_wraps)]
fn test_cylinder(pos: comp::Pos) -> Option<Cylinder> { fn test_cylinder(pos: comp::Pos) -> Option<Cylinder> {
Some(Cylinder::from_components(pos.0, None, None, None)) Some(Cylinder::from_components(pos.0, None, None, None))
} }

View File

@ -14,6 +14,7 @@ use tracing::{debug, error, warn};
impl Sys { impl Sys {
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
#[allow(clippy::unnecessary_wraps)]
fn handle_general_msg( fn handle_general_msg(
server_emitter: &mut common::event::Emitter<'_, ServerEvent>, server_emitter: &mut common::event::Emitter<'_, ServerEvent>,
new_chat_msgs: &mut Vec<(Option<specs::Entity>, UnresolvedChatMsg)>, new_chat_msgs: &mut Vec<(Option<specs::Entity>, UnresolvedChatMsg)>,

View File

@ -38,7 +38,7 @@ impl Sys {
None => { None => {
debug!(?entity, "client is not in_game, ignoring msg"); debug!(?entity, "client is not in_game, ignoring msg");
trace!(?msg, "ignored msg content"); trace!(?msg, "ignored msg content");
if matches!(msg, ClientGeneral::TerrainChunkRequest{ .. }) { if matches!(msg, ClientGeneral::TerrainChunkRequest { .. }) {
network_metrics.chunks_request_dropped.inc(); network_metrics.chunks_request_dropped.inc();
} }
return Ok(()); return Ok(());

View File

@ -44,13 +44,13 @@ impl Animation for DashAnimation {
let movement1abs = movement1base * pullback; let movement1abs = movement1base * pullback;
let movement2abs = movement2base * pullback; let movement2abs = movement2base * pullback;
let short = (((1.0) let short = (((1.0)
/ (0.72 + 0.28 * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()).powi(2))) / (0.72 + 0.28 * ((anim_time as f32 * 16.0_f32 + PI * 0.25).sin()).powi(2)))
.sqrt()) .sqrt())
* ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()) * ((anim_time as f32 * 16.0_f32 + PI * 0.25).sin())
* chargemovementbase * chargemovementbase
* pullback; * pullback;
let shortalt = let shortalt =
(anim_time as f32 * 16.0 as f32 + PI * 0.25).sin() * chargemovementbase * pullback; (anim_time as f32 * 16.0_f32 + PI * 0.25).sin() * chargemovementbase * pullback;
next.head_upper.orientation = next.head_upper.orientation =
Quaternion::rotation_x(movement1abs * 0.4 + movement2abs * 0.3) Quaternion::rotation_x(movement1abs * 0.4 + movement2abs * 0.3)

View File

@ -49,13 +49,13 @@ impl Animation for DashAnimation {
let legtwitch = (legtell * 6.0).sin() * pullback; let legtwitch = (legtell * 6.0).sin() * pullback;
let legswing = legtell * pullback; let legswing = legtell * pullback;
let short = (((1.0) let short = (((1.0)
/ (0.72 + 0.28 * ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()).powi(2))) / (0.72 + 0.28 * ((anim_time as f32 * 16.0_f32 + PI * 0.25).sin()).powi(2)))
.sqrt()) .sqrt())
* ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin()) * ((anim_time as f32 * 16.0_f32 + PI * 0.25).sin())
* chargemovementbase * chargemovementbase
* pullback; * pullback;
let shortalt = let shortalt =
(anim_time as f32 * 16.0 as f32 + PI * 0.25).sin() * chargemovementbase * pullback; (anim_time as f32 * 16.0_f32 + PI * 0.25).sin() * chargemovementbase * pullback;
next.head.orientation = Quaternion::rotation_x(movement1abs * -0.2 + movement2abs * 0.8) next.head.orientation = Quaternion::rotation_x(movement1abs * -0.2 + movement2abs * 0.8)
* Quaternion::rotation_z(short * -0.06 + twitch1 * 0.2); * Quaternion::rotation_z(short * -0.06 + twitch1 * 0.2);

View File

@ -8,16 +8,17 @@ use std::time::{Duration, Instant};
#[test] #[test]
fn maps_wield_while_equipping() { fn maps_wield_while_equipping() {
let mut loadout = Loadout::default(); let loadout = Loadout {
active_item: Some(ItemConfig {
loadout.active_item = Some(ItemConfig { item: Item::new_from_asset_expect("common.items.weapons.axe.starter_axe"),
item: Item::new_from_asset_expect("common.items.weapons.axe.starter_axe"), ability1: None,
ability1: None, ability2: None,
ability2: None, ability3: None,
ability3: None, block_ability: None,
block_ability: None, dodge_ability: None,
dodge_ability: None, }),
}); ..Default::default()
};
let result = CombatEventMapper::map_event( let result = CombatEventMapper::map_event(
&CharacterState::Equipping(states::equipping::Data { &CharacterState::Equipping(states::equipping::Data {
@ -39,16 +40,17 @@ fn maps_wield_while_equipping() {
#[test] #[test]
fn maps_unwield() { fn maps_unwield() {
let mut loadout = Loadout::default(); let loadout = Loadout {
active_item: Some(ItemConfig {
loadout.active_item = Some(ItemConfig { item: Item::new_from_asset_expect("common.items.weapons.bow.starter_bow"),
item: Item::new_from_asset_expect("common.items.weapons.bow.starter_bow"), ability1: None,
ability1: None, ability2: None,
ability2: None, ability3: None,
ability3: None, block_ability: None,
block_ability: None, dodge_ability: None,
dodge_ability: None, }),
}); ..Default::default()
};
let result = CombatEventMapper::map_event( let result = CombatEventMapper::map_event(
&CharacterState::default(), &CharacterState::default(),
@ -65,16 +67,17 @@ fn maps_unwield() {
#[test] #[test]
fn maps_basic_melee() { fn maps_basic_melee() {
let mut loadout = Loadout::default(); let loadout = Loadout {
active_item: Some(ItemConfig {
loadout.active_item = Some(ItemConfig { item: Item::new_from_asset_expect("common.items.weapons.axe.starter_axe"),
item: Item::new_from_asset_expect("common.items.weapons.axe.starter_axe"), ability1: None,
ability1: None, ability2: None,
ability2: None, ability3: None,
ability3: None, block_ability: None,
block_ability: None, dodge_ability: None,
dodge_ability: None, }),
}); ..Default::default()
};
let result = CombatEventMapper::map_event( let result = CombatEventMapper::map_event(
&CharacterState::BasicMelee(states::basic_melee::Data { &CharacterState::BasicMelee(states::basic_melee::Data {
@ -108,16 +111,17 @@ fn maps_basic_melee() {
#[test] #[test]
fn matches_ability_stage() { fn matches_ability_stage() {
let mut loadout = Loadout::default(); let loadout = Loadout {
active_item: Some(ItemConfig {
loadout.active_item = Some(ItemConfig { item: Item::new_from_asset_expect("common.items.weapons.sword.starter_sword"),
item: Item::new_from_asset_expect("common.items.weapons.sword.starter_sword"), ability1: None,
ability1: None, ability2: None,
ability2: None, ability3: None,
ability3: None, block_ability: None,
block_ability: None, dodge_ability: None,
dodge_ability: None, }),
}); ..Default::default()
};
let result = CombatEventMapper::map_event( let result = CombatEventMapper::map_event(
&CharacterState::ComboMelee(states::combo_melee::Data { &CharacterState::ComboMelee(states::combo_melee::Data {
@ -169,16 +173,17 @@ fn matches_ability_stage() {
#[test] #[test]
fn ignores_different_ability_stage() { fn ignores_different_ability_stage() {
let mut loadout = Loadout::default(); let loadout = Loadout {
active_item: Some(ItemConfig {
loadout.active_item = Some(ItemConfig { item: Item::new_from_asset_expect("common.items.weapons.sword.starter_sword"),
item: Item::new_from_asset_expect("common.items.weapons.sword.starter_sword"), ability1: None,
ability1: None, ability2: None,
ability2: None, ability3: None,
ability3: None, block_ability: None,
block_ability: None, dodge_ability: None,
dodge_ability: None, }),
}); ..Default::default()
};
let result = CombatEventMapper::map_event( let result = CombatEventMapper::map_event(
&CharacterState::ComboMelee(states::combo_melee::Data { &CharacterState::ComboMelee(states::combo_melee::Data {

View File

@ -391,8 +391,8 @@ impl<'a> Widget for Group<'a> {
// Health Text // Health Text
let txt = format!( let txt = format!(
"{}/{}", "{}/{}",
health.current() / 10 as u32, health.current() / 10_u32,
health.maximum() / 10 as u32, health.maximum() / 10_u32,
); );
// Change font size depending on health amount // Change font size depending on health amount
let font_size = match health.maximum() { let font_size = match health.maximum() {

View File

@ -80,17 +80,17 @@ impl State {
ItemKind, ItemKind,
}; };
if let ItemKind::Tool(kind) = kind { if let ItemKind::Tool(kind) = kind {
match &kind.kind { matches!(
ToolKind::Staff => true, &kind.kind,
ToolKind::Debug => true, ToolKind::Staff
ToolKind::Sword => true, | ToolKind::Debug
ToolKind::Hammer => true, | ToolKind::Sword
ToolKind::Axe => true, | ToolKind::Hammer
ToolKind::Bow => true, | ToolKind::Axe
ToolKind::Unique(UniqueKind::QuadMedQuick) => true, | ToolKind::Bow
ToolKind::Unique(UniqueKind::QuadLowBreathe) => true, | ToolKind::Unique(UniqueKind::QuadMedQuick)
_ => false, | ToolKind::Unique(UniqueKind::QuadLowBreathe)
} )
} else { } else {
false false
} }

View File

@ -2519,20 +2519,16 @@ impl Hud {
// If not showing the ui don't allow keys that change the ui state but do listen for // If not showing the ui don't allow keys that change the ui state but do listen for
// hotbar keys // hotbar keys
event if !self.show.ui => { WinEvent::InputUpdate(key, state) if !self.show.ui => {
if let WinEvent::InputUpdate(key, state) = event { if let Some(slot) = try_hotbar_slot_from_input(key) {
if let Some(slot) = try_hotbar_slot_from_input(key) { handle_slot(
handle_slot( slot,
slot, state,
state, &mut self.events,
&mut self.events, &mut self.slot_manager,
&mut self.slot_manager, &mut self.hotbar,
&mut self.hotbar, );
); true
true
} else {
false
}
} else { } else {
false false
} }
@ -2660,15 +2656,15 @@ impl Hud {
// conrod eats tabs. Un-eat a tabstop so tab completion can work // conrod eats tabs. Un-eat a tabstop so tab completion can work
if self.ui.ui.global_input().events().any(|event| { if self.ui.ui.global_input().events().any(|event| {
use conrod_core::{event, input}; use conrod_core::{event, input};
matches!(event, matches!(
/* event::Event::Raw(event::Input::Press(input::Button::Keyboard(input::Key::Tab))) | */ event,
event::Event::Ui(event::Ui::Press( /* event::Event::Raw(event::Input::Press(input::Button::Keyboard(input::Key::
_, * Tab))) | */
event::Press { event::Event::Ui(event::Ui::Press(_, event::Press {
button: event::Button::Keyboard(input::Key::Tab), button: event::Button::Keyboard(input::Key::Tab),
.. ..
}, },))
))) )
}) { }) {
self.ui self.ui
.ui .ui

View File

@ -21,6 +21,7 @@ use common::{
use std::panic; use std::panic;
use tracing::{error, info, warn}; use tracing::{error, info, warn};
#[allow(clippy::manual_unwrap_or)]
fn main() { fn main() {
// Load the settings // Load the settings
// Note: This won't log anything due to it being called before // Note: This won't log anything due to it being called before

View File

@ -263,7 +263,7 @@ impl Controls {
.padding(3) .padding(3)
.width(Length::Fill); .width(Length::Fill);
let bg_img = if matches!(&self.screen, Screen::Connecting {..}) { let bg_img = if matches!(&self.screen, Screen::Connecting { .. }) {
self.bg_img self.bg_img
} else { } else {
self.imgs.bg self.imgs.bg
@ -333,7 +333,7 @@ impl Controls {
}; };
}, },
Message::ShowServers => { Message::ShowServers => {
if matches!(&self.screen, Screen::Login {..}) { if matches!(&self.screen, Screen::Login { .. }) {
self.selected_server_index = self.selected_server_index =
servers.iter().position(|f| f == &self.login_info.server); servers.iter().position(|f| f == &self.login_info.server);
self.screen = Screen::Servers { self.screen = Screen::Servers {
@ -418,7 +418,7 @@ impl Controls {
// Connection successful of failed // Connection successful of failed
fn exit_connect_screen(&mut self) { fn exit_connect_screen(&mut self) {
if matches!(&self.screen, Screen::Connecting {..}) { if matches!(&self.screen, Screen::Connecting { .. }) {
self.screen = Screen::Login { self.screen = Screen::Login {
screen: login::Screen::new(), screen: login::Screen::new(),
error: None, error: None,
@ -444,7 +444,7 @@ impl Controls {
} }
fn connection_error(&mut self, error: String) { fn connection_error(&mut self, error: String) {
if matches!(&self.screen, Screen::Connecting {..}) { if matches!(&self.screen, Screen::Connecting { .. }) {
self.screen = Screen::Login { self.screen = Screen::Login {
screen: login::Screen::new(), screen: login::Screen::new(),
error: Some(error), error: Some(error),

View File

@ -234,7 +234,7 @@ where
let pos = Vec3::new(pos.z, pos.x, pos.y); let pos = Vec3::new(pos.z, pos.x, pos.y);
let uv = Vec2::new(Vec3::unit_y(), Vec3::unit_z()); let uv = Vec2::new(Vec3::unit_y(), Vec3::unit_z());
let norm = Vec3::unit_x(); let norm = Vec3::unit_x();
let atlas_pos = if let Some(atlas_pos) = add_to_atlas( let atlas_pos = add_to_atlas(
atlas, atlas,
&mut todo_rects, &mut todo_rects,
pos, pos,
@ -244,11 +244,7 @@ where
faces_forward, faces_forward,
max_size, max_size,
col_lights_size, col_lights_size,
) { );
atlas_pos
} else {
return;
};
create_quad_greedy( create_quad_greedy(
pos, pos,
dim, dim,
@ -279,7 +275,7 @@ where
let pos = Vec3::new(pos.y, pos.z, pos.x); let pos = Vec3::new(pos.y, pos.z, pos.x);
let uv = Vec2::new(Vec3::unit_z(), Vec3::unit_x()); let uv = Vec2::new(Vec3::unit_z(), Vec3::unit_x());
let norm = Vec3::unit_y(); let norm = Vec3::unit_y();
let atlas_pos = if let Some(atlas_pos) = add_to_atlas( let atlas_pos = add_to_atlas(
atlas, atlas,
&mut todo_rects, &mut todo_rects,
pos, pos,
@ -289,11 +285,7 @@ where
faces_forward, faces_forward,
max_size, max_size,
col_lights_size, col_lights_size,
) { );
atlas_pos
} else {
return;
};
create_quad_greedy( create_quad_greedy(
pos, pos,
dim, dim,
@ -324,7 +316,7 @@ where
let pos = Vec3::new(pos.x, pos.y, pos.z); let pos = Vec3::new(pos.x, pos.y, pos.z);
let uv = Vec2::new(Vec3::unit_x(), Vec3::unit_y()); let uv = Vec2::new(Vec3::unit_x(), Vec3::unit_y());
let norm = Vec3::unit_z(); let norm = Vec3::unit_z();
let atlas_pos = if let Some(atlas_pos) = add_to_atlas( let atlas_pos = add_to_atlas(
atlas, atlas,
&mut todo_rects, &mut todo_rects,
pos, pos,
@ -334,11 +326,7 @@ where
faces_forward, faces_forward,
max_size, max_size,
col_lights_size, col_lights_size,
) { );
atlas_pos
} else {
return;
};
create_quad_greedy( create_quad_greedy(
pos, pos,
dim, dim,
@ -444,7 +432,7 @@ fn add_to_atlas(
faces_forward: bool, faces_forward: bool,
max_size: guillotiere::Size, max_size: guillotiere::Size,
cur_size: &mut Vec2<u16>, cur_size: &mut Vec2<u16>,
) -> Option<guillotiere::Rectangle> { ) -> guillotiere::Rectangle {
// TODO: Check this conversion. // TODO: Check this conversion.
let atlas_rect; let atlas_rect;
loop { loop {
@ -502,7 +490,7 @@ fn add_to_atlas(
atlas_rect, atlas_rect,
if faces_forward { norm } else { -norm }, if faces_forward { norm } else { -norm },
)); ));
Some(atlas_rect) atlas_rect
} }
/// We deferred actually recording the colors within the rectangles in order to /// We deferred actually recording the colors within the rectangles in order to

View File

@ -265,8 +265,6 @@ impl<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug + 'static>
#[allow(clippy::many_single_char_names)] #[allow(clippy::many_single_char_names)]
#[allow(clippy::needless_range_loop)] // TODO: Pending review in #587 #[allow(clippy::needless_range_loop)] // TODO: Pending review in #587
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587 #[allow(clippy::or_fun_call)] // TODO: Pending review in #587
#[allow(clippy::panic_params)] // TODO: Pending review in #587
fn generate_mesh( fn generate_mesh(
self, self,
(range, max_texture_size, _boi): Self::Supplement, (range, max_texture_size, _boi): Self::Supplement,

View File

@ -79,7 +79,7 @@ where
height, height,
gfx::texture::AaMode::Single, gfx::texture::AaMode::Single,
), ),
1 as gfx::texture::Level, 1_u8,
gfx::memory::Bind::SHADER_RESOURCE, gfx::memory::Bind::SHADER_RESOURCE,
gfx::memory::Usage::Dynamic, gfx::memory::Usage::Dynamic,
Some(<<F as gfx::format::Formatted>::Channel as gfx::format::ChannelTyped>::get_channel_type()), Some(<<F as gfx::format::Formatted>::Channel as gfx::format::ChannelTyped>::get_channel_type()),

View File

@ -3693,6 +3693,7 @@ impl FigureColLights {
}) })
} }
#[allow(clippy::unnecessary_wraps)]
fn make_atlas(renderer: &mut Renderer) -> Result<AtlasAllocator, RenderError> { fn make_atlas(renderer: &mut Renderer) -> Result<AtlasAllocator, RenderError> {
let max_texture_size = renderer.max_texture_size(); let max_texture_size = renderer.max_texture_size();
let atlas_size = let atlas_size =

View File

@ -433,7 +433,7 @@ impl<V: RectRasterableVol> Terrain<V> {
max_texture_size, max_texture_size,
gfx::texture::AaMode::Single, gfx::texture::AaMode::Single,
), ),
1 as gfx::texture::Level, 1_u8,
gfx::memory::Bind::SHADER_RESOURCE, gfx::memory::Bind::SHADER_RESOURCE,
gfx::memory::Usage::Dynamic, gfx::memory::Usage::Dynamic,
(0, 0), (0, 0),

View File

@ -927,10 +927,8 @@ impl PlayState for SessionState {
HudEvent::DropSlot(x) => { HudEvent::DropSlot(x) => {
let mut client = self.client.borrow_mut(); let mut client = self.client.borrow_mut();
client.drop_slot(x); client.drop_slot(x);
if let comp::slot::Slot::Equip(equip_slot) = x { if let comp::slot::Slot::Equip(comp::slot::EquipSlot::Lantern) = x {
if let comp::slot::EquipSlot::Lantern = equip_slot { client.disable_lantern();
client.disable_lantern();
}
} }
}, },
HudEvent::ChangeHotbarState(state) => { HudEvent::ChangeHotbarState(state) => {

View File

@ -30,19 +30,23 @@ impl Event {
} }
pub fn is_keyboard_or_mouse(&self) -> bool { pub fn is_keyboard_or_mouse(&self) -> bool {
matches!(self.0, matches!(
self.0,
Input::Press(_) Input::Press(_)
| Input::Release(_) | Input::Release(_)
| Input::Motion(_) | Input::Motion(_)
| Input::Touch(_) | Input::Touch(_)
| Input::Text(_)) | Input::Text(_)
)
} }
pub fn is_keyboard(&self) -> bool { pub fn is_keyboard(&self) -> bool {
matches!(self.0, matches!(
self.0,
Input::Press(Button::Keyboard(_)) Input::Press(Button::Keyboard(_))
| Input::Release(Button::Keyboard(_)) | Input::Release(Button::Keyboard(_))
| Input::Text(_)) | Input::Text(_)
)
} }
pub fn new_resize(dims: Vec2<f64>) -> Self { Self(Input::Resize(dims.x, dims.y)) } pub fn new_resize(dims: Vec2<f64>) -> Self { Self(Input::Resize(dims.x, dims.y)) }

View File

@ -145,6 +145,7 @@ impl World {
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587 #[allow(clippy::or_fun_call)] // TODO: Pending review in #587
#[allow(clippy::eval_order_dependence)] #[allow(clippy::eval_order_dependence)]
#[allow(clippy::result_unit_err)]
pub fn generate_chunk( pub fn generate_chunk(
&self, &self,
index: IndexRef, index: IndexRef,

View File

@ -995,14 +995,15 @@ fn erode(
debug!("Computed stream power factors..."); debug!("Computed stream power factors...");
let mut lake_water_volume = vec![0.0 as Compute; map_size_lg.chunks_len()].into_boxed_slice(); let mut lake_water_volume: Box<[Compute]> =
let mut elev = vec![0.0 as Compute; map_size_lg.chunks_len()].into_boxed_slice(); vec![0.0_f64; map_size_lg.chunks_len()].into_boxed_slice();
let mut h_p = vec![0.0 as Compute; map_size_lg.chunks_len()].into_boxed_slice(); let mut elev: Box<[Compute]> = vec![0_f64; map_size_lg.chunks_len()].into_boxed_slice();
let mut deltah = vec![0.0 as Compute; map_size_lg.chunks_len()].into_boxed_slice(); let mut h_p: Box<[Compute]> = vec![0_f64; map_size_lg.chunks_len()].into_boxed_slice();
let mut deltah: Box<[Compute]> = vec![0_f64; map_size_lg.chunks_len()].into_boxed_slice();
// calculate the elevation / SPL, including sediment flux // calculate the elevation / SPL, including sediment flux
let tol1 = 1.0e-4 as Compute * (maxh as Compute + 1.0); let tol1: Compute = 1.0e-4_f64 * (maxh as Compute + 1.0);
let tol2 = 1.0e-3 as Compute * (max_uplift as Compute + 1.0); let tol2: Compute = 1.0e-3_f64 * (max_uplift as Compute + 1.0);
let tol = tol1.max(tol2); let tol = tol1.max(tol2);
let mut err = 2.0 * tol; let mut err = 2.0 * tol;
@ -1032,7 +1033,7 @@ fn erode(
// Gauss-Seidel iteration // Gauss-Seidel iteration
let mut lake_silt = vec![0.0 as Compute; map_size_lg.chunks_len()].into_boxed_slice(); let mut lake_silt: Box<[Compute]> = vec![0.0_f64; map_size_lg.chunks_len()].into_boxed_slice();
let mut lake_sill = vec![-1isize; map_size_lg.chunks_len()].into_boxed_slice(); let mut lake_sill = vec![-1isize; map_size_lg.chunks_len()].into_boxed_slice();
let mut n_gs_stream_power_law = 0; let mut n_gs_stream_power_law = 0;
@ -1219,7 +1220,7 @@ fn erode(
let start_time = Instant::now(); let start_time = Instant::now();
// TODO: Consider taking advantage of multi-receiver flow here. // TODO: Consider taking advantage of multi-receiver flow here.
// Iterate in ascending height order. // Iterate in ascending height order.
let mut sum_err = 0.0 as Compute; let mut sum_err: Compute = 0.0_f64;
itertools::izip!(&*mstack, &*elev, &*b_stack, &*h_t_stack, &*dh_stack, &*h_p) itertools::izip!(&*mstack, &*elev, &*b_stack, &*h_t_stack, &*dh_stack, &*h_p)
.enumerate() .enumerate()
.rev() .rev()

View File

@ -366,6 +366,7 @@ pub fn get_oceans<F: Float>(map_size_lg: MapSizeLg, oldh: impl Fn(usize) -> F +
} }
/// Finds the horizon map for sunlight for the given chunks. /// Finds the horizon map for sunlight for the given chunks.
#[allow(clippy::result_unit_err)]
pub fn get_horizon_map<F: Float + Sync, A: Send, H: Send>( pub fn get_horizon_map<F: Float + Sync, A: Send, H: Send>(
map_size_lg: MapSizeLg, map_size_lg: MapSizeLg,
bounds: Aabr<i32>, bounds: Aabr<i32>,

View File

@ -224,13 +224,10 @@ pub enum Tile {
impl Tile { impl Tile {
fn is_passable(&self) -> bool { fn is_passable(&self) -> bool {
match self { matches!(
Tile::UpStair(_) => true, self,
Tile::DownStair(_) => true, Tile::UpStair(_) | Tile::DownStair(_) | Tile::Room(_) | Tile::Tunnel
Tile::Room(_) => true, )
Tile::Tunnel => true,
_ => false,
}
} }
} }

View File

@ -294,10 +294,8 @@ impl Settlement {
let mut origin = Vec2::new(ctx.rng.gen_range(-2, 3), ctx.rng.gen_range(-2, 3)); let mut origin = Vec2::new(ctx.rng.gen_range(-2, 3), ctx.rng.gen_range(-2, 3));
for i in 0..PLOT_COUNT { for i in 0..PLOT_COUNT {
if let Some(base_tile) = self.land.find_tile_near(origin, |plot| match plot { if let Some(base_tile) = self.land.find_tile_near(origin, |plot| {
Some(Plot::Field { .. }) => true, matches!(plot, Some(Plot::Field { .. }) | Some(Plot::Dirt))
Some(Plot::Dirt) => true,
_ => false,
}) { }) {
// self.land // self.land
// .plot_at_mut(base_tile) // .plot_at_mut(base_tile)