Merge branch 'update-toolchain' into 'master'

update toolchain to `nightly-2020-12-09`

See merge request veloren/veloren!1606
This commit is contained in:
Marcel 2020-12-10 15:03:52 +00:00
commit 3c9e8a4479
39 changed files with 250 additions and 242 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -73,7 +73,7 @@ lazy_static! {
impl FromStr for NpcKind {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let npc_names = &*NPC_NAMES;
ALL_NPCS
.iter()
@ -126,13 +126,14 @@ impl FromStr for NpcBody {
/// associated species, generate the species randomly within it; if an
/// explicit species is found, generate a random member of the species;
/// 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 {
/// 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
/// 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, ()> {
fn parse<
'a,

View File

@ -133,21 +133,13 @@ impl Body {
}
pub fn can_fly(&self) -> bool {
match self {
Body::BirdMedium(_) => true,
Body::Dragon(_) => true,
Body::BirdSmall(_) => true,
_ => false,
}
matches!(
self,
Body::BirdMedium(_) | Body::Dragon(_) | Body::BirdSmall(_)
)
}
#[allow(clippy::match_like_matches_macro)]
pub fn can_climb(&self) -> bool {
match self {
Body::Humanoid(_) => true,
_ => false,
}
}
pub fn can_climb(&self) -> bool { matches!(self, Body::Humanoid(_)) }
}
/// 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 might not otherwise be available at runtime.
#[inline(always)]
#[allow(clippy::result_unit_err)]
pub const fn new(map_size_lg: Vec2<u32>) -> Result<Self, ()> {
// Assertion on dimensions: must be between
// 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
// river.
.min_by(|&(ap, _, a), &(bp, _, b)| {
(a, ap < 0.0 || ap > 1.0, ap)
.partial_cmp(&(b, bp < 0.0 || bp > 1.0, bp))
(a, !(0.0..=1.0).contains(&ap), ap)
.partial_cmp(&(b, !(0.0..=1.0).contains(&bp), bp))
.unwrap()
});
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 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)
} else if h <= 2.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 len_sq = from.magnitude_squared();
len_sq < 0.999 || len_sq > 1.001
!(0.999..=1.001).contains(&len_sq)
};
if unnormalized {
@ -132,7 +132,7 @@ fn slerp_normalized(from: vek::Vec3<f32>, to: vek::Vec3<f32>, factor: f32) -> ve
{
let unnormalized = {
let len_sq = from.magnitude_squared();
len_sq < 0.999 || len_sq > 1.001
!(0.999..=1.001).contains(&len_sq)
};
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!");
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 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())
} else {
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())
} else {
format!("{} ({})", DISPLAY_VERSION.as_str(), GIT_VERSION.to_string())

View File

@ -1 +1 @@
nightly-2020-10-25
nightly-2020-12-09

View File

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

View File

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

View File

@ -204,12 +204,14 @@ impl Tui {
let block = Block::default().borders(Borders::ALL);
let mut wrap = Wrap::default();
wrap.scroll_callback = Some(Box::new(|text_area, lines| {
LOG.resize(text_area.height as usize);
let len = lines.len() as u16;
(len.saturating_sub(text_area.height), 0)
}));
let wrap = Wrap {
scroll_callback: Some(Box::new(|text_area, lines| {
LOG.resize(text_area.height as usize);
let len = lines.len() as u16;
(len.saturating_sub(text_area.height), 0)
})),
..Default::default()
};
let logger = Paragraph::new(LOG.inner.lock().unwrap().clone())
.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(
server: &Server,
pos: Vec3<f32>,
@ -565,9 +566,18 @@ pub fn handle_explosion(
// Add an outcome
// Uses radius as outcome power, makes negative if explosion has healing effect
let outcome_power = explosion.radius
* if explosion.effects.iter().any(
|e| matches!(e, RadiusEffect::Entity(_, Effect::Damage(Damage { source: DamageSource::Healing, .. })))
) {
* if explosion.effects.iter().any(|e| {
matches!(
e,
RadiusEffect::Entity(
_,
Effect::Damage(Damage {
source: DamageSource::Healing,
..
})
)
)
}) {
-1.0
} else {
1.0

View File

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

View File

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

View File

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

View File

@ -44,13 +44,13 @@ impl Animation for DashAnimation {
let movement1abs = movement1base * pullback;
let movement2abs = movement2base * pullback;
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())
* ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin())
* ((anim_time as f32 * 16.0_f32 + PI * 0.25).sin())
* chargemovementbase
* pullback;
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 =
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 legswing = legtell * pullback;
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())
* ((anim_time as f32 * 16.0 as f32 + PI * 0.25).sin())
* ((anim_time as f32 * 16.0_f32 + PI * 0.25).sin())
* chargemovementbase
* pullback;
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)
* Quaternion::rotation_z(short * -0.06 + twitch1 * 0.2);

View File

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

View File

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

View File

@ -80,17 +80,17 @@ impl State {
ItemKind,
};
if let ItemKind::Tool(kind) = kind {
match &kind.kind {
ToolKind::Staff => true,
ToolKind::Debug => true,
ToolKind::Sword => true,
ToolKind::Hammer => true,
ToolKind::Axe => true,
ToolKind::Bow => true,
ToolKind::Unique(UniqueKind::QuadMedQuick) => true,
ToolKind::Unique(UniqueKind::QuadLowBreathe) => true,
_ => false,
}
matches!(
&kind.kind,
ToolKind::Staff
| ToolKind::Debug
| ToolKind::Sword
| ToolKind::Hammer
| ToolKind::Axe
| ToolKind::Bow
| ToolKind::Unique(UniqueKind::QuadMedQuick)
| ToolKind::Unique(UniqueKind::QuadLowBreathe)
)
} else {
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
// hotbar keys
event if !self.show.ui => {
if let WinEvent::InputUpdate(key, state) = event {
if let Some(slot) = try_hotbar_slot_from_input(key) {
handle_slot(
slot,
state,
&mut self.events,
&mut self.slot_manager,
&mut self.hotbar,
);
true
} else {
false
}
WinEvent::InputUpdate(key, state) if !self.show.ui => {
if let Some(slot) = try_hotbar_slot_from_input(key) {
handle_slot(
slot,
state,
&mut self.events,
&mut self.slot_manager,
&mut self.hotbar,
);
true
} else {
false
}
@ -2660,15 +2656,15 @@ impl Hud {
// conrod eats tabs. Un-eat a tabstop so tab completion can work
if self.ui.ui.global_input().events().any(|event| {
use conrod_core::{event, input};
matches!(event,
/* event::Event::Raw(event::Input::Press(input::Button::Keyboard(input::Key::Tab))) | */
event::Event::Ui(event::Ui::Press(
_,
event::Press {
button: event::Button::Keyboard(input::Key::Tab),
..
},
)))
matches!(
event,
/* event::Event::Raw(event::Input::Press(input::Button::Keyboard(input::Key::
* Tab))) | */
event::Event::Ui(event::Ui::Press(_, event::Press {
button: event::Button::Keyboard(input::Key::Tab),
..
},))
)
}) {
self.ui
.ui

View File

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

View File

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

View File

@ -234,7 +234,7 @@ where
let pos = Vec3::new(pos.z, pos.x, pos.y);
let uv = Vec2::new(Vec3::unit_y(), Vec3::unit_z());
let norm = Vec3::unit_x();
let atlas_pos = if let Some(atlas_pos) = add_to_atlas(
let atlas_pos = add_to_atlas(
atlas,
&mut todo_rects,
pos,
@ -244,11 +244,7 @@ where
faces_forward,
max_size,
col_lights_size,
) {
atlas_pos
} else {
return;
};
);
create_quad_greedy(
pos,
dim,
@ -279,7 +275,7 @@ where
let pos = Vec3::new(pos.y, pos.z, pos.x);
let uv = Vec2::new(Vec3::unit_z(), Vec3::unit_x());
let norm = Vec3::unit_y();
let atlas_pos = if let Some(atlas_pos) = add_to_atlas(
let atlas_pos = add_to_atlas(
atlas,
&mut todo_rects,
pos,
@ -289,11 +285,7 @@ where
faces_forward,
max_size,
col_lights_size,
) {
atlas_pos
} else {
return;
};
);
create_quad_greedy(
pos,
dim,
@ -324,7 +316,7 @@ where
let pos = Vec3::new(pos.x, pos.y, pos.z);
let uv = Vec2::new(Vec3::unit_x(), Vec3::unit_y());
let norm = Vec3::unit_z();
let atlas_pos = if let Some(atlas_pos) = add_to_atlas(
let atlas_pos = add_to_atlas(
atlas,
&mut todo_rects,
pos,
@ -334,11 +326,7 @@ where
faces_forward,
max_size,
col_lights_size,
) {
atlas_pos
} else {
return;
};
);
create_quad_greedy(
pos,
dim,
@ -444,7 +432,7 @@ fn add_to_atlas(
faces_forward: bool,
max_size: guillotiere::Size,
cur_size: &mut Vec2<u16>,
) -> Option<guillotiere::Rectangle> {
) -> guillotiere::Rectangle {
// TODO: Check this conversion.
let atlas_rect;
loop {
@ -502,7 +490,7 @@ fn add_to_atlas(
atlas_rect,
if faces_forward { norm } else { -norm },
));
Some(atlas_rect)
atlas_rect
}
/// 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::needless_range_loop)] // 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(
self,
(range, max_texture_size, _boi): Self::Supplement,

View File

@ -79,7 +79,7 @@ where
height,
gfx::texture::AaMode::Single,
),
1 as gfx::texture::Level,
1_u8,
gfx::memory::Bind::SHADER_RESOURCE,
gfx::memory::Usage::Dynamic,
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> {
let max_texture_size = renderer.max_texture_size();
let atlas_size =

View File

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

View File

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

View File

@ -30,19 +30,23 @@ impl Event {
}
pub fn is_keyboard_or_mouse(&self) -> bool {
matches!(self.0,
matches!(
self.0,
Input::Press(_)
| Input::Release(_)
| Input::Motion(_)
| Input::Touch(_)
| Input::Text(_))
| Input::Release(_)
| Input::Motion(_)
| Input::Touch(_)
| Input::Text(_)
)
}
pub fn is_keyboard(&self) -> bool {
matches!(self.0,
matches!(
self.0,
Input::Press(Button::Keyboard(_))
| Input::Release(Button::Keyboard(_))
| Input::Text(_))
| Input::Release(Button::Keyboard(_))
| Input::Text(_)
)
}
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::eval_order_dependence)]
#[allow(clippy::result_unit_err)]
pub fn generate_chunk(
&self,
index: IndexRef,

View File

@ -995,14 +995,15 @@ fn erode(
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 elev = vec![0.0 as Compute; 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 deltah = vec![0.0 as Compute; map_size_lg.chunks_len()].into_boxed_slice();
let mut lake_water_volume: Box<[Compute]> =
vec![0.0_f64; 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 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
let tol1 = 1.0e-4 as Compute * (maxh as Compute + 1.0);
let tol2 = 1.0e-3 as Compute * (max_uplift as Compute + 1.0);
let tol1: Compute = 1.0e-4_f64 * (maxh as Compute + 1.0);
let tol2: Compute = 1.0e-3_f64 * (max_uplift as Compute + 1.0);
let tol = tol1.max(tol2);
let mut err = 2.0 * tol;
@ -1032,7 +1033,7 @@ fn erode(
// 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 n_gs_stream_power_law = 0;
@ -1219,7 +1220,7 @@ fn erode(
let start_time = Instant::now();
// TODO: Consider taking advantage of multi-receiver flow here.
// 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)
.enumerate()
.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.
#[allow(clippy::result_unit_err)]
pub fn get_horizon_map<F: Float + Sync, A: Send, H: Send>(
map_size_lg: MapSizeLg,
bounds: Aabr<i32>,

View File

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

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));
for i in 0..PLOT_COUNT {
if let Some(base_tile) = self.land.find_tile_near(origin, |plot| match plot {
Some(Plot::Field { .. }) => true,
Some(Plot::Dirt) => true,
_ => false,
if let Some(base_tile) = self.land.find_tile_near(origin, |plot| {
matches!(plot, Some(Plot::Field { .. }) | Some(Plot::Dirt))
}) {
// self.land
// .plot_at_mut(base_tile)