mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed suppressed clippy warnings for #587 - collapsible_if
This commit is contained in:
@ -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 {
|
||||
|
@ -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>) {
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user