Merge branch 'xvar/clippy-fixes-collapsible_if' into 'master'

Fixed suppressed clippy warnings for #587 - collapsible_if

See merge request veloren/veloren!1064
This commit is contained in:
Imbris 2020-06-12 20:27:13 +00:00
commit 38ec0fde63
17 changed files with 375 additions and 427 deletions

View File

@ -79,7 +79,6 @@ fn nth_word(line: &str, n: usize) -> Option<usize> {
}
#[allow(clippy::chars_next_cmp)] // TODO: Pending review in #587
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
pub fn complete(line: &str, client: &Client) -> Vec<String> {
let word = if line.chars().last().map_or(true, char::is_whitespace) {
""
@ -93,29 +92,27 @@ pub fn complete(line: &str, client: &Client) -> Vec<String> {
if i == 0 {
// Completing chat command name
complete_command(word)
} else {
if let Ok(cmd) = cmd.parse::<ChatCommand>() {
if let Some(arg) = cmd.data().args.get(i - 1) {
// Complete ith argument
arg.complete(word, &client)
} else {
// Complete past the last argument
match cmd.data().args.last() {
Some(ArgumentSpec::SubCommand) => {
if let Some(index) = nth_word(line, cmd.data().args.len()) {
complete(&line[index..], &client)
} else {
vec![]
}
},
Some(ArgumentSpec::Message) => complete_player(word, &client),
_ => vec![], // End of command. Nothing to complete
}
}
} else if let Ok(cmd) = cmd.parse::<ChatCommand>() {
if let Some(arg) = cmd.data().args.get(i - 1) {
// Complete ith argument
arg.complete(word, &client)
} else {
// Completing for unknown chat command
complete_player(word, &client)
// Complete past the last argument
match cmd.data().args.last() {
Some(ArgumentSpec::SubCommand) => {
if let Some(index) = nth_word(line, cmd.data().args.len()) {
complete(&line[index..], &client)
} else {
vec![]
}
},
Some(ArgumentSpec::Message) => complete_player(word, &client),
_ => vec![], // End of command. Nothing to complete
}
}
} else {
// Completing for unknown chat command
complete_player(word, &client)
}
} else {
// Not completing a command

View File

@ -702,7 +702,7 @@ impl Client {
}
/// Handle new server messages.
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
fn handle_new_messages(&mut self) -> Result<Vec<Event>, Error> {
let mut frontend_events = Vec::new();
@ -713,12 +713,12 @@ impl Client {
let duration_since_last_pong = self.state.get_time() - self.last_server_pong;
// Dispatch a notification to the HUD warning they will be kicked in {n} seconds
if duration_since_last_pong >= SERVER_TIMEOUT_GRACE_PERIOD {
if self.state.get_time() - duration_since_last_pong > 0. {
frontend_events.push(Event::DisconnectionNotification(
(self.state.get_time() - duration_since_last_pong).round() as u64,
));
}
if duration_since_last_pong >= SERVER_TIMEOUT_GRACE_PERIOD
&& self.state.get_time() - duration_since_last_pong > 0.
{
frontend_events.push(Event::DisconnectionNotification(
(self.state.get_time() - duration_since_last_pong).round() as u64,
));
}
}

View File

@ -224,7 +224,6 @@ fn handle_goto(
}
}
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::option_map_unit_fn)] // TODO: Pending review in #587
fn handle_kill(
server: &mut Server,
@ -235,12 +234,10 @@ fn handle_kill(
) {
let reason = if client == target {
comp::HealthSource::Suicide
} else if let Some(uid) = server.state.read_storage::<Uid>().get(client) {
comp::HealthSource::Attack { by: *uid }
} else {
if let Some(uid) = server.state.read_storage::<Uid>().get(client) {
comp::HealthSource::Attack { by: *uid }
} else {
comp::HealthSource::Command
}
comp::HealthSource::Command
};
server
.state
@ -385,7 +382,6 @@ fn handle_alias(
}
}
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::identity_conversion)] // TODO: Pending review in #587
#[allow(clippy::useless_format)] // TODO: Pending review in #587
fn handle_tp(
@ -401,20 +397,18 @@ fn handle_tp(
.join()
.find(|(_, player)| player.alias == alias)
.map(|(entity, _)| entity)
} else if client != target {
Some(client)
} else {
if client != target {
Some(client)
} else {
server.notify_client(
client,
ServerMsg::private("You must specify a player name".to_string()),
);
server.notify_client(
client,
ServerMsg::private(String::from(action.help_string())),
);
return;
}
server.notify_client(
client,
ServerMsg::private("You must specify a player name".to_string()),
);
server.notify_client(
client,
ServerMsg::private(String::from(action.help_string())),
);
return;
};
if let Some(_pos) = server.state.read_component_cloned::<comp::Pos>(target) {
if let Some(player) = opt_player {

View File

@ -24,7 +24,6 @@ pub fn handle_damage(server: &Server, uid: Uid, change: HealthChange) {
}
}
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::option_map_unit_fn)] // TODO: Pending review in #587
pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSource) {
let state = server.state_mut();
@ -102,224 +101,222 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
.ecs()
.write_storage::<comp::CharacterState>()
.insert(entity, comp::CharacterState::default());
} else {
if state.ecs().read_storage::<comp::Agent>().contains(entity) {
// Replace npc with loot
let _ = state
.ecs()
.write_storage()
.insert(entity, Body::Object(object::Body::Pouch));
} else if state.ecs().read_storage::<comp::Agent>().contains(entity) {
// Replace npc with loot
let _ = state
.ecs()
.write_storage()
.insert(entity, Body::Object(object::Body::Pouch));
let mut item_drops = state.ecs().write_storage::<comp::ItemDrop>();
let item = if let Some(item_drop) = item_drops.get(entity).cloned() {
item_drops.remove(entity);
item_drop.0
} else {
assets::load_expect_cloned::<Item>(
[
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.veloritefrag",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.collar",
"common.items.collar",
"common.items.collar",
"common.items.collar",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.velorite",
"common.items.armor.ring.ring_0",
"common.items.armor.neck.neck_0",
"common.items.mushroom",
"common.items.coconut",
"common.items.coconut",
"common.items.coconut",
"common.items.coconut",
"common.items.coconut",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.weapons.tool.broom",
"common.items.weapons.tool.shovel-1",
"common.items.weapons.staff.staff_nature",
"common.items.flowers.yellow",
"common.items.armor.pants.worker_blue_0",
"common.items.armor.chest.worker_yellow_0",
"common.items.armor.chest.worker_green_0",
"common.items.armor.chest.worker_orange_0",
"common.items.armor.back.short_0",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.sword.starter_sword",
"common.items.weapons.axe.starter_axe",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.hammer.starter_hammer",
"common.items.weapons.bow.starter_bow",
"common.items.weapons.staff.starter_staff",
"common.items.weapons.sword.starter_sword",
"common.items.weapons.axe.starter_axe",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.hammer.starter_hammer",
"common.items.weapons.bow.starter_bow",
"common.items.weapons.staff.starter_staff",
"common.items.weapons.sword.starter_sword",
"common.items.weapons.axe.starter_axe",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.hammer.starter_hammer",
"common.items.weapons.bow.starter_bow",
"common.items.weapons.staff.starter_staff",
"common.items.weapons.sword.greatsword_2h_simple-0",
"common.items.weapons.sword.greatsword_2h_simple-1",
"common.items.weapons.sword.greatsword_2h_simple-2",
"common.items.weapons.sword.long_2h_simple-0",
"common.items.weapons.sword.long_2h_simple-1",
"common.items.weapons.sword.long_2h_simple-2",
"common.items.weapons.sword.long_2h_simple-3",
"common.items.weapons.sword.long_2h_simple-4",
"common.items.weapons.sword.long_2h_simple-5",
]
.choose(&mut rand::thread_rng())
.unwrap(),
)
};
let _ = state.ecs().write_storage().insert(entity, item);
state.ecs().write_storage::<comp::Stats>().remove(entity);
state.ecs().write_storage::<comp::Agent>().remove(entity);
state
.ecs()
.write_storage::<comp::LightEmitter>()
.remove(entity);
state
.ecs()
.write_storage::<comp::CharacterState>()
.remove(entity);
state
.ecs()
.write_storage::<comp::Controller>()
.remove(entity);
let mut item_drops = state.ecs().write_storage::<comp::ItemDrop>();
let item = if let Some(item_drop) = item_drops.get(entity).cloned() {
item_drops.remove(entity);
item_drop.0
} else {
if let Err(err) = state.delete_entity_recorded(entity) {
error!("Failed to delete destroyed entity: {:?}", err);
}
}
assets::load_expect_cloned::<Item>(
[
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.veloritefrag",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.cheese",
"common.items.mushroom",
"common.items.apple",
"common.items.collar",
"common.items.collar",
"common.items.collar",
"common.items.collar",
"common.items.collar",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.veloritefrag",
"common.items.velorite",
"common.items.armor.ring.ring_0",
"common.items.armor.neck.neck_0",
"common.items.mushroom",
"common.items.coconut",
"common.items.coconut",
"common.items.coconut",
"common.items.coconut",
"common.items.coconut",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.potion_minor",
"common.items.weapons.tool.broom",
"common.items.weapons.tool.shovel-1",
"common.items.weapons.staff.staff_nature",
"common.items.flowers.yellow",
"common.items.armor.pants.worker_blue_0",
"common.items.armor.chest.worker_yellow_0",
"common.items.armor.chest.worker_green_0",
"common.items.armor.chest.worker_orange_0",
"common.items.armor.back.short_0",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.sword.starter_sword",
"common.items.weapons.axe.starter_axe",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.hammer.starter_hammer",
"common.items.weapons.bow.starter_bow",
"common.items.weapons.staff.starter_staff",
"common.items.weapons.sword.starter_sword",
"common.items.weapons.axe.starter_axe",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.hammer.starter_hammer",
"common.items.weapons.bow.starter_bow",
"common.items.weapons.staff.starter_staff",
"common.items.weapons.sword.starter_sword",
"common.items.weapons.axe.starter_axe",
"common.items.weapons.staff.staff_nature",
"common.items.weapons.hammer.starter_hammer",
"common.items.weapons.bow.starter_bow",
"common.items.weapons.staff.starter_staff",
"common.items.weapons.sword.greatsword_2h_simple-0",
"common.items.weapons.sword.greatsword_2h_simple-1",
"common.items.weapons.sword.greatsword_2h_simple-2",
"common.items.weapons.sword.long_2h_simple-0",
"common.items.weapons.sword.long_2h_simple-1",
"common.items.weapons.sword.long_2h_simple-2",
"common.items.weapons.sword.long_2h_simple-3",
"common.items.weapons.sword.long_2h_simple-4",
"common.items.weapons.sword.long_2h_simple-5",
]
.choose(&mut rand::thread_rng())
.unwrap(),
)
};
// TODO: Add Delete(time_left: Duration) component
/*
// If not a player delete the entity
if let Err(err) = state.delete_entity_recorded(entity) {
error!("Failed to delete destroyed entity: {:?}", err);
}
*/
let _ = state.ecs().write_storage().insert(entity, item);
state.ecs().write_storage::<comp::Stats>().remove(entity);
state.ecs().write_storage::<comp::Agent>().remove(entity);
state
.ecs()
.write_storage::<comp::LightEmitter>()
.remove(entity);
state
.ecs()
.write_storage::<comp::CharacterState>()
.remove(entity);
state
.ecs()
.write_storage::<comp::Controller>()
.remove(entity);
} else {
let _ = state
.delete_entity_recorded(entity)
.map_err(|err| error!("Failed to delete destroyed entity: {:?}", err));
}
// TODO: Add Delete(time_left: Duration) component
/*
// If not a player delete the entity
if let Err(err) = state.delete_entity_recorded(entity) {
error!("Failed to delete destroyed entity: {:?}", err);
}
*/
}
pub fn handle_land_on_ground(server: &Server, entity: EcsEntity, vel: Vec3<f32>) {

View File

@ -30,7 +30,6 @@ pub fn snuff_lantern(storage: &mut WriteStorage<comp::LightEmitter>, entity: Ecs
}
#[allow(clippy::block_in_if_condition_stmt)] // TODO: Pending review in #587
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::let_and_return)] // TODO: Pending review in #587
pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::InventoryManip) {
let state = server.state_mut();
@ -95,12 +94,11 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
entity,
comp::InventoryUpdate::new(comp::InventoryUpdateEvent::CollectFailed),
);
} else {
if block.is_collectible() && state.try_set_block(pos, Block::empty()).is_some()
{
comp::Item::try_reclaim_from_block(block)
.map(|item| state.give_item(entity, item));
}
} else if block.is_collectible()
&& state.try_set_block(pos, Block::empty()).is_some()
{
comp::Item::try_reclaim_from_block(block)
.map(|item| state.give_item(entity, item));
}
}
},

View File

@ -129,7 +129,6 @@ impl CombatEventMapper {
}
}
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
fn map_event(
character_state: &CharacterState,
previous_state: &PreviousEntityState,
@ -151,22 +150,16 @@ impl CombatEventMapper {
CharacterAbilityType::from(character_state),
ToolCategory::from(data.kind),
);
} else {
if let Some(wield_event) = match (
previous_state.weapon_drawn,
character_state.is_dodge(),
Self::weapon_drawn(character_state),
) {
(false, false, true) => {
Some(SfxEvent::Wield(ToolCategory::from(data.kind)))
},
(true, false, false) => {
Some(SfxEvent::Unwield(ToolCategory::from(data.kind)))
},
_ => None,
} {
return wield_event;
}
} else if let Some(wield_event) = match (
previous_state.weapon_drawn,
character_state.is_dodge(),
Self::weapon_drawn(character_state),
) {
(false, false, true) => Some(SfxEvent::Wield(ToolCategory::from(data.kind))),
(true, false, false) => Some(SfxEvent::Unwield(ToolCategory::from(data.kind))),
_ => None,
} {
return wield_event;
}
}
}

View File

@ -146,7 +146,6 @@ impl<'a> Widget for Chat<'a> {
#[allow(clippy::unused_unit)] // TODO: Pending review in #587
fn style(&self) -> Self::Style { () }
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::redundant_clone)] // TODO: Pending review in #587
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
@ -200,24 +199,20 @@ impl<'a> Widget for Chat<'a> {
state.update(|s| s.input.retain(|c| c != '\t'));
//tab_dir + 1
}
if !state.completions.is_empty() {
if tab_dir != 0 || state.completions_index.is_none() {
state.update(|s| {
let len = s.completions.len();
s.completions_index = Some(
(s.completions_index.unwrap_or(0) + (tab_dir + len as isize) as usize)
% len,
);
if let Some(replacement) = &s.completions.get(s.completions_index.unwrap())
{
let (completed, offset) =
do_tab_completion(cursor, &s.input, replacement);
force_cursor =
cursor_offset_to_index(offset, &completed, &ui, &self.fonts);
s.input = completed;
}
});
}
if !state.completions.is_empty() && (tab_dir != 0 || state.completions_index.is_none())
{
state.update(|s| {
let len = s.completions.len();
s.completions_index = Some(
(s.completions_index.unwrap_or(0) + (tab_dir + len as isize) as usize)
% len,
);
if let Some(replacement) = &s.completions.get(s.completions_index.unwrap()) {
let (completed, offset) = do_tab_completion(cursor, &s.input, replacement);
force_cursor = cursor_offset_to_index(offset, &completed, &ui, &self.fonts);
s.input = completed;
}
});
}
false
} else if let Some(cursor) = state.input.find('\t') {
@ -236,10 +231,8 @@ impl<'a> Widget for Chat<'a> {
if s.history_pos < s.history.len() {
s.history_pos += 1;
}
} else {
if s.history_pos > 0 {
s.history_pos -= 1;
}
} else if s.history_pos > 0 {
s.history_pos -= 1;
}
if s.history_pos > 0 {
s.input = s.history.get(s.history_pos - 1).unwrap().to_owned();
@ -368,17 +361,16 @@ impl<'a> Widget for Chat<'a> {
// Chat Arrow
// Check if already at bottom.
if !Self::scrolled_to_bottom(state, ui) {
if Button::image(self.imgs.chat_arrow)
if !Self::scrolled_to_bottom(state, ui)
&& Button::image(self.imgs.chat_arrow)
.w_h(20.0, 20.0)
.hover_image(self.imgs.chat_arrow_mo)
.press_image(self.imgs.chat_arrow_press)
.bottom_right_with_margins_on(state.ids.message_box_bg, 0.0, -22.0)
.set(state.ids.chat_arrow, ui)
.was_clicked()
{
ui.scroll_widget(state.ids.message_box, [0.0, std::f64::MAX]);
}
{
ui.scroll_widget(state.ids.message_box, [0.0, std::f64::MAX]);
}
// We've started a new tab completion. Populate tab completion suggestions.

View File

@ -399,7 +399,6 @@ impl CharSelectionUi {
// TODO: Split this into multiple modules or functions.
#[allow(clippy::clone_on_copy)] // TODO: Pending review in #587
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::useless_let_if_seq)] // TODO: Pending review in #587
#[allow(clippy::unnecessary_operation)] // TODO: Pending review in #587
fn update_layout(&mut self, client: &mut Client) -> Vec<Event> {
@ -826,15 +825,14 @@ impl CharSelectionUi {
.image_color(color)
.set(self.ids.character_box_2, ui_widgets)
.was_clicked()
&& !character_limit_reached
{
if !character_limit_reached {
self.mode = Mode::Create {
name: "Character Name".to_string(),
body: humanoid::Body::random(),
loadout: comp::Loadout::default(),
tool: Some(STARTER_SWORD),
};
}
self.mode = Mode::Create {
name: "Character Name".to_string(),
body: humanoid::Body::random(),
loadout: comp::Loadout::default(),
tool: Some(STARTER_SWORD),
};
}
// LOADING SCREEN HERE
@ -903,21 +901,19 @@ impl CharSelectionUi {
.set(self.ids.create_button, ui_widgets)
.was_clicked()
{}
} else {
if create_button
.set(self.ids.create_button, ui_widgets)
.was_clicked()
{
self.info_content = InfoContent::CreatingCharacter;
} else if create_button
.set(self.ids.create_button, ui_widgets)
.was_clicked()
{
self.info_content = InfoContent::CreatingCharacter;
events.push(Event::AddCharacter {
alias: name.clone(),
tool: tool.map(|tool| tool.to_string()),
body: comp::Body::Humanoid(body.clone()),
});
events.push(Event::AddCharacter {
alias: name.clone(),
tool: tool.map(|tool| tool.to_string()),
body: comp::Body::Humanoid(body.clone()),
});
to_select = true;
}
to_select = true;
}
// Character Name Input
Rectangle::fill_with([320.0, 50.0], color::rgba(0.0, 0.0, 0.0, 0.97))

View File

@ -206,7 +206,7 @@ impl<'a, V: RectRasterableVol<Vox = Block> + ReadVol + Debug>
type Supplement = Aabb<i32>;
type TranslucentPipeline = FluidPipeline;
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::collapsible_if)]
#[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

View File

@ -46,7 +46,7 @@ gfx_defines! {
}
impl Vertex {
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::collapsible_if)]
pub fn new(pos: Vec3<f32>, norm: Vec3<f32>, col: Rgb<f32>, ao: f32, bone_idx: u8) -> Self {
let norm_bits = if norm.x != 0.0 {
if norm.x < 0.0 { 0 } else { 1 }

View File

@ -45,7 +45,7 @@ gfx_defines! {
}
impl Vertex {
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::collapsible_if)]
pub fn new(pos: Vec3<f32>, norm: Vec3<f32>, col: Rgb<f32>, ao: f32) -> Self {
let norm_bits = if norm.x != 0.0 {
if norm.x < 0.0 { 0 } else { 1 }

View File

@ -368,7 +368,6 @@ impl<'a> Widget for Tooltip<'a> {
fn style(&self) -> Self::Style { self.style.clone() }
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
fn update(self, args: widget::UpdateArgs<Self>) {
let widget::UpdateArgs {
id,
@ -440,13 +439,11 @@ impl<'a> Widget for Tooltip<'a> {
if !self.title_text.is_empty() {
desc.down_from(state.ids.title, V_PAD * 0.5 + title_space)
.align_left_of(state.ids.title)
} else if self.image.is_some() {
desc.right_from(state.ids.image, H_PAD)
.align_top_of(state.ids.image)
} else {
if self.image.is_some() {
desc.right_from(state.ids.image, H_PAD)
.align_top_of(state.ids.image)
} else {
desc.top_left_with_margins_on(state.ids.image_frame, V_PAD, H_PAD)
}
desc.top_left_with_margins_on(state.ids.image_frame, V_PAD, H_PAD)
}
.set(state.ids.desc, ui);
}

View File

@ -9,7 +9,6 @@ use veloren_world::{
const W: usize = 1024;
const H: usize = 1024;
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::needless_update)] // TODO: Pending review in #587
#[allow(clippy::unused_io_amount)] // TODO: Pending review in #587
fn main() {

View File

@ -168,7 +168,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
type Index = Vec2<i32>;
type Sample = Option<ColumnSample<'a>>;
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::float_cmp)] // TODO: Pending review in #587
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
#[allow(clippy::nonminimal_bool)] // TODO: Pending review in #587
@ -679,36 +678,33 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
let (_, dist, _, (river_t, _, downhill_river_chunk)) =
if let Some(dist) = max_border_river_dist {
dist
} else {
if lake_dist
<= TerrainChunkSize::RECT_SIZE.x as f64 * 1.0
|| in_bounds
{
let gouge_factor = 0.0;
return Some((
in_bounds
|| downhill_water_alt
.max(river_chunk.water_alt)
> alt_for_river,
Some(lake_dist as f32),
alt_for_river,
(downhill_water_alt
} else if lake_dist
<= TerrainChunkSize::RECT_SIZE.x as f64 * 1.0
|| in_bounds
{
let gouge_factor = 0.0;
return Some((
in_bounds
|| downhill_water_alt
.max(river_chunk.water_alt)
- river_gouge),
alt_for_river,
river_scale_factor as f32
* (1.0 - gouge_factor),
));
} else {
return Some((
false,
Some(lake_dist as f32),
alt_for_river,
downhill_water_alt,
alt_for_river,
river_scale_factor as f32,
));
}
> alt_for_river,
Some(lake_dist as f32),
alt_for_river,
(downhill_water_alt.max(river_chunk.water_alt)
- river_gouge),
alt_for_river,
river_scale_factor as f32
* (1.0 - gouge_factor),
));
} else {
return Some((
false,
Some(lake_dist as f32),
alt_for_river,
downhill_water_alt,
alt_for_river,
river_scale_factor as f32,
));
};
let lake_dist = dist.y;

View File

@ -687,7 +687,6 @@ fn get_max_slope(
/// Copyright 2003 by the American Geophysical Union
/// 10.1029/135GM09
#[allow(clippy::assign_op_pattern)] // TODO: Pending review in #587
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::many_single_char_names)]
#[allow(clippy::too_many_arguments)]
fn erode(
@ -1388,19 +1387,17 @@ fn erode(
// NOTE: If we want erosion to proceed underwater, use h_j here instead
// of wh_j.
new_h_i = wh_j;
} else {
if compute_stats && new_h_i > 0.0 {
let dxy = (uniform_idx_as_vec2(posi) - uniform_idx_as_vec2(posj))
.map(|e| e as f64);
let neighbor_distance = (neighbor_coef * dxy).magnitude();
let dz = (new_h_i - wh_j).max(0.0);
let mag_slope = dz / neighbor_distance;
} else if compute_stats && new_h_i > 0.0 {
let dxy = (uniform_idx_as_vec2(posi) - uniform_idx_as_vec2(posj))
.map(|e| e as f64);
let neighbor_distance = (neighbor_coef * dxy).magnitude();
let dz = (new_h_i - wh_j).max(0.0);
let mag_slope = dz / neighbor_distance;
nland += 1;
sumsed_land += sed;
sumh += new_h_i;
sums += mag_slope;
}
nland += 1;
sumsed_land += sed;
sumh += new_h_i;
sums += mag_slope;
}
} else {
new_h_i = old_elev_i;
@ -1628,15 +1625,13 @@ fn erode(
if compute_stats {
ncorr += 1;
}
} else {
if compute_stats && new_h_i > 0.0 {
let dz = (new_h_i - h_j).max(0.0);
let slope = dz / neighbor_distance;
sums += slope;
nland += 1;
sumh += new_h_i;
sumsed_land += sed;
}
} else if compute_stats && new_h_i > 0.0 {
let dz = (new_h_i - h_j).max(0.0);
let slope = dz / neighbor_distance;
sums += slope;
nland += 1;
sumh += new_h_i;
sumsed_land += sed;
}
if compute_stats {
ntherm += 1;

View File

@ -1821,7 +1821,6 @@ pub struct RegionInfo {
}
impl SimChunk {
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::if_same_then_else)] // TODO: Pending review in #587
fn generate(posi: usize, gen_ctx: &GenCtx, gen_cdf: &GenCdf) -> Self {
let pos = uniform_idx_as_vec2(posi);
@ -2012,23 +2011,21 @@ impl SimChunk {
} else {
ForestKind::Savannah
}
} else if humidity > CONFIG.jungle_hum {
// Temperate climate with jungle humidity...
// https://en.wikipedia.org/wiki/Humid_subtropical_climates are often
// densely wooded and full of water. Semitropical rainforests, basically.
// For now we just treet them like other rainforests.
ForestKind::Oak
} else if humidity > CONFIG.forest_hum {
// Moderate climate, moderate humidity.
ForestKind::Oak
} else if humidity > CONFIG.desert_hum {
// With moderate temperature and low humidity, we should probably see
// something different from savannah, but oh well...
ForestKind::Savannah
} else {
if humidity > CONFIG.jungle_hum {
// Temperate climate with jungle humidity...
// https://en.wikipedia.org/wiki/Humid_subtropical_climates are often
// densely wooded and full of water. Semitropical rainforests, basically.
// For now we just treet them like other rainforests.
ForestKind::Oak
} else if humidity > CONFIG.forest_hum {
// Moderate climate, moderate humidity.
ForestKind::Oak
} else if humidity > CONFIG.desert_hum {
// With moderate temperature and low humidity, we should probably see
// something different from savannah, but oh well...
ForestKind::Savannah
} else {
ForestKind::Savannah
}
ForestKind::Savannah
}
} else {
// For now we don't take humidity into account for cold climates (but we really

View File

@ -481,7 +481,6 @@ impl Settlement {
}
}
#[allow(clippy::collapsible_if)] // TODO: Pending review in #587
#[allow(clippy::identity_op)] // TODO: Pending review in #587
#[allow(clippy::modulo_one)] // TODO: Pending review in #587
pub fn apply_to<'a>(
@ -645,14 +644,12 @@ impl Settlement {
})
.map(|kind| Block::new(kind, Rgb::white()));
}
} else {
if roll(0, 20) == 0 {
surface_block =
Some(Block::new(BlockKind::ShortGrass, Rgb::white()));
} else if roll(1, 30) == 0 {
surface_block =
Some(Block::new(BlockKind::MediumGrass, Rgb::white()));
}
} else if roll(0, 20) == 0 {
surface_block =
Some(Block::new(BlockKind::ShortGrass, Rgb::white()));
} else if roll(1, 30) == 0 {
surface_block =
Some(Block::new(BlockKind::MediumGrass, Rgb::white()));
}
Some(if in_furrow { dirt } else { mound })