extended clippy from quality.sh

This commit is contained in:
Marcel Märtens 2023-09-28 17:57:09 +02:00
parent 540f0d10f2
commit df03c92741
49 changed files with 124 additions and 140 deletions

View File

@ -22,7 +22,7 @@ pub struct Tui {
impl Tui { impl Tui {
pub fn new() -> (Self, async_channel::Receiver<Cmd>) { pub fn new() -> (Self, async_channel::Receiver<Cmd>) {
let (mut commands_s, commands_r) = async_channel::unbounded(); let (commands_s, commands_r) = async_channel::unbounded();
let handle = thread::spawn(move || { let handle = thread::spawn(move || {
thread::sleep(Duration::from_millis(20)); thread::sleep(Duration::from_millis(20));
@ -36,7 +36,7 @@ impl Tui {
) )
.unwrap(); .unwrap();
while let Ok(cmd) = readline.readline("\n\nbotclient> ") { while let Ok(cmd) = readline.readline("\n\nbotclient> ") {
let keep_going = Self::process_command(&cmd, &mut commands_s); let keep_going = Self::process_command(&cmd, &commands_s);
readline.add_history_entry(cmd).unwrap(); readline.add_history_entry(cmd).unwrap();
if !keep_going { if !keep_going {
break; break;
@ -47,7 +47,7 @@ impl Tui {
(Self { _handle: handle }, commands_r) (Self { _handle: handle }, commands_r)
} }
pub fn process_command(cmd: &str, command_s: &mut async_channel::Sender<Cmd>) -> bool { pub fn process_command(cmd: &str, command_s: &async_channel::Sender<Cmd>) -> bool {
let matches = Command::new("veloren-botclient") let matches = Command::new("veloren-botclient")
.version(common::util::DISPLAY_VERSION_LONG.as_str()) .version(common::util::DISPLAY_VERSION_LONG.as_str())
.author("The veloren devs <https://gitlab.com/veloren/veloren>") .author("The veloren devs <https://gitlab.com/veloren/veloren>")

View File

@ -749,12 +749,12 @@ pub mod asset_tweak {
run_with_file(tweak_path, |file| { run_with_file(tweak_path, |file| {
file.write_all( file.write_all(
br#" br"
(( ((
such: 5, such: 5,
field: 35.752346, field: 35.752346,
)) ))
"#, ",
) )
.expect("failed to write to the file"); .expect("failed to write to the file");

View File

@ -100,11 +100,11 @@ fn input_validated_string(prompt: &str, check: &dyn Fn(&str) -> bool) -> String
} }
fn main() { fn main() {
let prompt = r#" let prompt = r"
Stub implementation. Stub implementation.
If you want to migrate new assets, edit `v1` and `v2` modules. If you want to migrate new assets, edit `v1` and `v2` modules.
If you want to migrate old assets, check commit history. If you want to migrate old assets, check commit history.
"#; ";
println!("{prompt}"); println!("{prompt}");
let old_dir = input_validated_string( let old_dir = input_validated_string(

View File

@ -1185,7 +1185,7 @@ mod tests {
init(); init();
info!("init"); info!("init");
let mut stock: hashbrown::HashMap<Good, f32> = vec![ let mut stock: hashbrown::HashMap<Good, f32> = [
(Good::Ingredients, 50.0), (Good::Ingredients, 50.0),
(Good::Tools, 10.0), (Good::Tools, 10.0),
(Good::Armor, 10.0), (Good::Armor, 10.0),

View File

@ -16,7 +16,7 @@ impl<T> Id<T> {
impl<T> Copy for Id<T> {} impl<T> Copy for Id<T> {}
impl<T> Clone for Id<T> { impl<T> Clone for Id<T> {
fn clone(&self) -> Self { Self(self.0, PhantomData) } fn clone(&self) -> Self { *self }
} }
impl<T> Eq for Id<T> {} impl<T> Eq for Id<T> {}
impl<T> PartialEq for Id<T> { impl<T> PartialEq for Id<T> {

View File

@ -141,6 +141,7 @@ pub fn create_player(state: &mut State) -> Entity {
.build() .build()
} }
#[allow(clippy::needless_pass_by_ref_mut)]
pub fn generate_chunk(state: &mut State, chunk_pos: Vec2<i32>) { pub fn generate_chunk(state: &mut State, chunk_pos: Vec2<i32>) {
let (x, y) = chunk_pos.map(|e| e.to_le_bytes()).into_tuple(); let (x, y) = chunk_pos.map(|e| e.to_le_bytes()).into_tuple();
let mut rng = SmallRng::from_seed([ let mut rng = SmallRng::from_seed([

View File

@ -864,7 +864,7 @@ mod tests {
async fn mock_mpsc( async fn mock_mpsc(
cid: Cid, cid: Cid,
_runtime: &Arc<Runtime>, _runtime: &Arc<Runtime>,
create_channel: &mut mpsc::UnboundedSender<S2bCreateChannel>, create_channel: &mpsc::UnboundedSender<S2bCreateChannel>,
) -> Protocols { ) -> Protocols {
let (s1, r1) = mpsc::channel(100); let (s1, r1) = mpsc::channel(100);
let (s2, r2) = mpsc::channel(100); let (s2, r2) = mpsc::channel(100);
@ -887,14 +887,14 @@ mod tests {
a2b_open_stream_s, a2b_open_stream_s,
b2a_stream_opened_r, b2a_stream_opened_r,
mut b2a_event_r, mut b2a_event_r,
mut s2b_create_channel_s, s2b_create_channel_s,
s2b_shutdown_bparticipant_s, s2b_shutdown_bparticipant_s,
b2s_prio_statistic_r, b2s_prio_statistic_r,
_b2a_bandwidth_stats_r, _b2a_bandwidth_stats_r,
handle, handle,
) = mock_bparticipant(); ) = mock_bparticipant();
let _remote = runtime.block_on(mock_mpsc(0, &runtime, &mut s2b_create_channel_s)); let _remote = runtime.block_on(mock_mpsc(0, &runtime, &s2b_create_channel_s));
std::thread::sleep(Duration::from_millis(50)); std::thread::sleep(Duration::from_millis(50));
let (s, r) = oneshot::channel(); let (s, r) = oneshot::channel();
@ -933,14 +933,14 @@ mod tests {
a2b_open_stream_s, a2b_open_stream_s,
b2a_stream_opened_r, b2a_stream_opened_r,
mut b2a_event_r, mut b2a_event_r,
mut s2b_create_channel_s, s2b_create_channel_s,
s2b_shutdown_bparticipant_s, s2b_shutdown_bparticipant_s,
b2s_prio_statistic_r, b2s_prio_statistic_r,
_b2a_bandwidth_stats_r, _b2a_bandwidth_stats_r,
handle, handle,
) = mock_bparticipant(); ) = mock_bparticipant();
let remote = runtime.block_on(mock_mpsc(0, &runtime, &mut s2b_create_channel_s)); let remote = runtime.block_on(mock_mpsc(0, &runtime, &s2b_create_channel_s));
std::thread::sleep(Duration::from_millis(50)); std::thread::sleep(Duration::from_millis(50));
let (s, r) = oneshot::channel(); let (s, r) = oneshot::channel();
@ -980,14 +980,14 @@ mod tests {
a2b_open_stream_s, a2b_open_stream_s,
b2a_stream_opened_r, b2a_stream_opened_r,
_b2a_event_r, _b2a_event_r,
mut s2b_create_channel_s, s2b_create_channel_s,
s2b_shutdown_bparticipant_s, s2b_shutdown_bparticipant_s,
b2s_prio_statistic_r, b2s_prio_statistic_r,
_b2a_bandwidth_stats_r, _b2a_bandwidth_stats_r,
handle, handle,
) = mock_bparticipant(); ) = mock_bparticipant();
let remote = runtime.block_on(mock_mpsc(0, &runtime, &mut s2b_create_channel_s)); let remote = runtime.block_on(mock_mpsc(0, &runtime, &s2b_create_channel_s));
std::thread::sleep(Duration::from_millis(50)); std::thread::sleep(Duration::from_millis(50));
// created stream // created stream
@ -1036,14 +1036,14 @@ mod tests {
a2b_open_stream_s, a2b_open_stream_s,
mut b2a_stream_opened_r, mut b2a_stream_opened_r,
_b2a_event_r, _b2a_event_r,
mut s2b_create_channel_s, s2b_create_channel_s,
s2b_shutdown_bparticipant_s, s2b_shutdown_bparticipant_s,
b2s_prio_statistic_r, b2s_prio_statistic_r,
_b2a_bandwidth_stats_r, _b2a_bandwidth_stats_r,
handle, handle,
) = mock_bparticipant(); ) = mock_bparticipant();
let remote = runtime.block_on(mock_mpsc(0, &runtime, &mut s2b_create_channel_s)); let remote = runtime.block_on(mock_mpsc(0, &runtime, &s2b_create_channel_s));
std::thread::sleep(Duration::from_millis(50)); std::thread::sleep(Duration::from_millis(50));
// create stream // create stream

View File

@ -129,7 +129,7 @@ pub struct ArgvApp {
pub command: Option<ArgvCommand>, pub command: Option<ArgvCommand>,
} }
pub fn parse_command(input: &str, msg_s: &mut Sender<Message>) { pub fn parse_command(input: &str, msg_s: &Sender<Message>) {
match TuiApp::try_parse_from(shell_words::split(input).unwrap_or_default()) { match TuiApp::try_parse_from(shell_words::split(input).unwrap_or_default()) {
Ok(message) => { Ok(message) => {
msg_s msg_s

View File

@ -29,7 +29,7 @@ pub struct Tui {
} }
impl Tui { impl Tui {
fn handle_events(input: &mut String, msg_s: &mut mpsc::Sender<Message>) { fn handle_events(input: &mut String, msg_s: &mpsc::Sender<Message>) {
use crossterm::event::*; use crossterm::event::*;
if let Event::Key(event) = read().unwrap() { if let Event::Key(event) = read().unwrap() {
match event.code { match event.code {
@ -81,7 +81,7 @@ impl Tui {
} }
/// In a seperate Thread /// In a seperate Thread
fn work_b(running: Arc<AtomicBool>, mut msg_s: mpsc::Sender<Message>) { fn work_b(running: Arc<AtomicBool>, msg_s: mpsc::Sender<Message>) {
while running.load(Ordering::Relaxed) { while running.load(Ordering::Relaxed) {
let mut line = String::new(); let mut line = String::new();
@ -100,14 +100,14 @@ impl Tui {
}, },
Ok(_) => { Ok(_) => {
debug!(?line, "basic mode: command entered"); debug!(?line, "basic mode: command entered");
cli::parse_command(line.trim(), &mut msg_s); cli::parse_command(line.trim(), &msg_s);
}, },
} }
} }
} }
/// In a seperate Thread /// In a seperate Thread
fn work_e(running: Arc<AtomicBool>, mut msg_s: mpsc::Sender<Message>) { fn work_e(running: Arc<AtomicBool>, msg_s: mpsc::Sender<Message>) {
// Start the tui // Start the tui
let mut stdout = io::stdout(); let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen, EnableMouseCapture).unwrap(); execute!(stdout, EnterAlternateScreen, EnableMouseCapture).unwrap();
@ -169,7 +169,7 @@ impl Tui {
warn!(?e, "couldn't draw frame"); warn!(?e, "couldn't draw frame");
}; };
if crossterm::event::poll(Duration::from_millis(100)).unwrap() { if crossterm::event::poll(Duration::from_millis(100)).unwrap() {
Self::handle_events(&mut input, &mut msg_s); Self::handle_events(&mut input, &msg_s);
}; };
} }
} }

View File

@ -1939,7 +1939,7 @@ impl<'a> AgentData<'a> {
pub fn menacing( pub fn menacing(
&self, &self,
agent: &mut Agent, agent: &Agent,
controller: &mut Controller, controller: &mut Controller,
target: EcsEntity, target: EcsEntity,
read_data: &ReadData, read_data: &ReadData,

View File

@ -2924,11 +2924,7 @@ impl<'a> AgentData<'a> {
{ {
agent.action_state.counters[FCounters::SummonThreshold as usize] -= agent.action_state.counters[FCounters::SummonThreshold as usize] -=
SUMMON_THRESHOLD; SUMMON_THRESHOLD;
if !agent.action_state.conditions[Conditions::AttackToggle as usize] { agent.action_state.conditions[Conditions::AttackToggle as usize] = !agent.action_state.conditions[Conditions::AttackToggle as usize];
agent.action_state.conditions[Conditions::AttackToggle as usize] = true;
} else {
agent.action_state.conditions[Conditions::AttackToggle as usize] = false;
}
} }
} else { } else {
// If target is in melee range use flamecrush // If target is in melee range use flamecrush

View File

@ -316,7 +316,7 @@ fn no_sudo(client: EcsEntity, target: EcsEntity) -> CmdResult<()> {
/// with a higher role than their permanent role allowing it, and only permanent /// with a higher role than their permanent role allowing it, and only permanent
/// roles should be recorded in the settings files. /// roles should be recorded in the settings files.
fn verify_above_role( fn verify_above_role(
server: &mut Server, server: &Server,
(client, client_uuid): (EcsEntity, Uuid), (client, client_uuid): (EcsEntity, Uuid),
(player, player_uuid): (EcsEntity, Uuid), (player, player_uuid): (EcsEntity, Uuid),
reason: &str, reason: &str,
@ -379,7 +379,7 @@ fn find_username(server: &mut Server, username: &str) -> CmdResult<Uuid> {
/// NOTE: Intended to be run only on logged-in clients. /// NOTE: Intended to be run only on logged-in clients.
fn uuid_to_username( fn uuid_to_username(
server: &mut Server, server: &Server,
fallback_entity: EcsEntity, fallback_entity: EcsEntity,
uuid: Uuid, uuid: Uuid,
) -> CmdResult<String> { ) -> CmdResult<String> {
@ -405,7 +405,7 @@ fn uuid_to_username(
} }
fn edit_setting_feedback<S: EditableSetting>( fn edit_setting_feedback<S: EditableSetting>(
server: &mut Server, server: &Server,
client: EcsEntity, client: EcsEntity,
result: Option<(String, Result<(), SettingError<S>>)>, result: Option<(String, Result<(), SettingError<S>>)>,
failure: impl FnOnce() -> String, failure: impl FnOnce() -> String,
@ -2426,7 +2426,7 @@ fn handle_kit(
} }
} }
fn push_kit<I>(kit: I, count: usize, server: &mut Server, target: EcsEntity) -> CmdResult<()> fn push_kit<I>(kit: I, count: usize, server: &Server, target: EcsEntity) -> CmdResult<()>
where where
I: Iterator<Item = (KitSpec, u32)>, I: Iterator<Item = (KitSpec, u32)>,
{ {
@ -4040,7 +4040,7 @@ fn handle_buff(
} }
} }
fn cast_buff(kind: &str, data: BuffData, server: &mut Server, target: EcsEntity) -> CmdResult<()> { fn cast_buff(kind: &str, data: BuffData, server: &Server, target: EcsEntity) -> CmdResult<()> {
if let Some(buffkind) = parse_buffkind(kind) { if let Some(buffkind) = parse_buffkind(kind) {
let ecs = &server.state.ecs(); let ecs = &server.state.ecs();
let mut buffs_all = ecs.write_storage::<comp::Buffs>(); let mut buffs_all = ecs.write_storage::<comp::Buffs>();

View File

@ -300,7 +300,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt
let alignments = state.ecs().read_storage::<Alignment>(); let alignments = state.ecs().read_storage::<Alignment>();
let uids = state.ecs().read_storage::<Uid>(); let uids = state.ecs().read_storage::<Uid>();
let mut outcomes = state.ecs().write_resource::<EventBus<Outcome>>(); let outcomes = state.ecs().write_resource::<EventBus<Outcome>>();
let inventories = state.ecs().read_storage::<Inventory>(); let inventories = state.ecs().read_storage::<Inventory>();
let destroyed_group = groups.get(entity); let destroyed_group = groups.get(entity);
@ -384,7 +384,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, last_change: Healt
attacker_inventory, attacker_inventory,
&mut attacker_skill_set, &mut attacker_skill_set,
attacker_uid, attacker_uid,
&mut outcomes, &outcomes,
); );
} }
}); });
@ -1186,8 +1186,8 @@ pub fn handle_bonk(server: &mut Server, pos: Vec3<f32>, owner: Option<Uid>, targ
} }
} }
pub fn handle_aura(server: &mut Server, entity: EcsEntity, aura_change: aura::AuraChange) { pub fn handle_aura(server: &Server, entity: EcsEntity, aura_change: aura::AuraChange) {
let ecs = &server.state.ecs(); let ecs = server.state.ecs();
let mut auras_all = ecs.write_storage::<Auras>(); let mut auras_all = ecs.write_storage::<Auras>();
if let Some(mut auras) = auras_all.get_mut(entity) { if let Some(mut auras) = auras_all.get_mut(entity) {
use aura::AuraChange; use aura::AuraChange;
@ -1204,7 +1204,7 @@ pub fn handle_aura(server: &mut Server, entity: EcsEntity, aura_change: aura::Au
} }
} }
pub fn handle_buff(server: &mut Server, entity: EcsEntity, buff_change: buff::BuffChange) { pub fn handle_buff(server: &Server, entity: EcsEntity, buff_change: buff::BuffChange) {
let ecs = &server.state.ecs(); let ecs = &server.state.ecs();
let mut buffs_all = ecs.write_storage::<comp::Buffs>(); let mut buffs_all = ecs.write_storage::<comp::Buffs>();
let bodies = ecs.read_storage::<Body>(); let bodies = ecs.read_storage::<Body>();
@ -1301,7 +1301,7 @@ fn handle_exp_gain(
inventory: &Inventory, inventory: &Inventory,
skill_set: &mut SkillSet, skill_set: &mut SkillSet,
uid: &Uid, uid: &Uid,
outcomes: &mut EventBus<Outcome>, outcomes: &EventBus<Outcome>,
) { ) {
use comp::inventory::{item::ItemKind, slot::EquipSlot}; use comp::inventory::{item::ItemKind, slot::EquipSlot};
@ -1671,7 +1671,7 @@ pub fn handle_teleport_to_position(server: &mut Server, entity: EcsEntity, posit
} }
} }
pub fn handle_start_teleporting(server: &mut Server, entity: EcsEntity, portal: EcsEntity) { pub fn handle_start_teleporting(server: &Server, entity: EcsEntity, portal: EcsEntity) {
let ecs = server.state.ecs(); let ecs = server.state.ecs();
let positions = ecs.read_storage::<comp::Pos>(); let positions = ecs.read_storage::<comp::Pos>();
let mut teleportings = ecs.write_storage::<comp::Teleporting>(); let mut teleportings = ecs.write_storage::<comp::Teleporting>();

View File

@ -18,7 +18,7 @@ use specs::{
pub fn can_invite( pub fn can_invite(
state: &State, state: &State,
clients: &ReadStorage<'_, Client>, clients: &ReadStorage<'_, Client>,
pending_invites: &mut WriteStorage<'_, PendingInvites>, pending_invites: &WriteStorage<'_, PendingInvites>,
max_group_size: u32, max_group_size: u32,
inviter: Entity, inviter: Entity,
invitee: Entity, invitee: Entity,

View File

@ -391,8 +391,8 @@ pub fn handle_mine_block(
} }
} }
pub fn handle_sound(server: &mut Server, sound: &Sound) { pub fn handle_sound(server: &Server, sound: &Sound) {
let ecs = &server.state.ecs(); let ecs = server.state.ecs();
let positions = &ecs.read_storage::<Pos>(); let positions = &ecs.read_storage::<Pos>();
let agents = &mut ecs.write_storage::<comp::Agent>(); let agents = &mut ecs.write_storage::<comp::Agent>();
@ -459,7 +459,7 @@ pub fn handle_create_sprite(
} }
} }
pub fn handle_tame_pet(server: &mut Server, pet_entity: EcsEntity, owner_entity: EcsEntity) { pub fn handle_tame_pet(server: &Server, pet_entity: EcsEntity, owner_entity: EcsEntity) {
// TODO: Raise outcome to send to clients to play sound/render an indicator // TODO: Raise outcome to send to clients to play sound/render an indicator
// showing taming success? // showing taming success?
tame_pet(server.state.ecs(), pet_entity, owner_entity); tame_pet(server.state.ecs(), pet_entity, owner_entity);

View File

@ -71,7 +71,7 @@ pub fn handle_invite(server: &mut Server, inviter: Entity, invitee_uid: Uid, kin
if !group_manip::can_invite( if !group_manip::can_invite(
state, state,
&clients, &clients,
&mut pending_invites, &pending_invites,
max_group_size, max_group_size,
inviter, inviter,
invitee, invitee,
@ -275,7 +275,7 @@ pub fn handle_invite_accept(server: &mut Server, entity: Entity) {
} }
} }
fn get_inviter_and_kind(entity: Entity, state: &mut State) -> Option<(Entity, InviteKind)> { fn get_inviter_and_kind(entity: Entity, state: &State) -> Option<(Entity, InviteKind)> {
let mut invites = state.ecs().write_storage::<Invite>(); let mut invites = state.ecs().write_storage::<Invite>();
invites.remove(entity).and_then(|invite| { invites.remove(entity).and_then(|invite| {
let Invite { inviter, kind } = invite; let Invite { inviter, kind } = invite;
@ -294,7 +294,7 @@ fn get_inviter_and_kind(entity: Entity, state: &mut State) -> Option<(Entity, In
} }
fn handle_invite_answer( fn handle_invite_answer(
state: &mut State, state: &State,
inviter: Entity, inviter: Entity,
entity: Entity, entity: Entity,
invite_answer: InviteAnswer, invite_answer: InviteAnswer,

View File

@ -253,7 +253,7 @@ pub fn handle_client_disconnect(
// temporarily unable to log in during this period to avoid // temporarily unable to log in during this period to avoid
// the race condition of their login fetching their old data // the race condition of their login fetching their old data
// and overwriting the data saved here. // and overwriting the data saved here.
fn persist_entity(state: &mut State, entity: EcsEntity) -> EcsEntity { fn persist_entity(state: &State, entity: EcsEntity) -> EcsEntity {
if let ( if let (
Some(presence), Some(presence),
Some(skill_set), Some(skill_set),

View File

@ -54,7 +54,7 @@ fn notify_agent_prices(
/// Invoked when the trade UI is up, handling item changes, accepts, etc /// Invoked when the trade UI is up, handling item changes, accepts, etc
pub(super) fn handle_process_trade_action( pub(super) fn handle_process_trade_action(
server: &mut Server, server: &Server,
entity: EcsEntity, entity: EcsEntity,
trade_id: TradeId, trade_id: TradeId,
action: TradeAction, action: TradeAction,
@ -169,7 +169,7 @@ pub(super) fn handle_process_trade_action(
/// longer exists or is awareof this cancellation through other means (e.g. /// longer exists or is awareof this cancellation through other means (e.g.
/// client getting ExitInGameSuccess message knows that it should clear any /// client getting ExitInGameSuccess message knows that it should clear any
/// trades). /// trades).
pub(crate) fn cancel_trades_for(state: &mut common_state::State, entity: EcsEntity) { pub(crate) fn cancel_trades_for(state: &common_state::State, entity: EcsEntity) {
let ecs = state.ecs(); let ecs = state.ecs();
if let Some(uid) = ecs.uid_from_entity(entity) { if let Some(uid) = ecs.uid_from_entity(entity) {
let mut trades = ecs.write_resource::<Trades>(); let mut trades = ecs.write_resource::<Trades>();

View File

@ -1173,9 +1173,9 @@ impl Server {
/// due to a persistence transaction failure and returns the processed /// due to a persistence transaction failure and returns the processed
/// DisconnectionType /// DisconnectionType
fn disconnect_all_clients_if_requested(&mut self) -> Option<DisconnectType> { fn disconnect_all_clients_if_requested(&mut self) -> Option<DisconnectType> {
let mut character_updater = self.state.ecs().fetch_mut::<CharacterUpdater>(); let character_updater = self.state.ecs().fetch_mut::<CharacterUpdater>();
let disconnect_type = self.get_disconnect_all_clients_requested(&mut character_updater); let disconnect_type = self.get_disconnect_all_clients_requested(&character_updater);
if let Some(disconnect_type) = disconnect_type { if let Some(disconnect_type) = disconnect_type {
let with_persistence = disconnect_type == DisconnectType::WithPersistence; let with_persistence = disconnect_type == DisconnectType::WithPersistence;
let clients = self.state.ecs().read_storage::<Client>(); let clients = self.state.ecs().read_storage::<Client>();
@ -1206,7 +1206,7 @@ impl Server {
fn get_disconnect_all_clients_requested( fn get_disconnect_all_clients_requested(
&self, &self,
character_updater: &mut CharacterUpdater, character_updater: &CharacterUpdater,
) -> Option<DisconnectType> { ) -> Option<DisconnectType> {
let without_persistence_requested = character_updater.disconnect_all_clients_requested(); let without_persistence_requested = character_updater.disconnect_all_clients_requested();
let with_persistence_requested = self.disconnect_all_clients_requested; let with_persistence_requested = self.disconnect_all_clients_requested;

View File

@ -1062,7 +1062,7 @@ pub fn update(
// The `defer_foreign_keys` pragma treats the foreign key // The `defer_foreign_keys` pragma treats the foreign key
// constraints as deferred for the next transaction (it turns itself // constraints as deferred for the next transaction (it turns itself
// off at the commit boundary). https://sqlite.org/foreignkeys.html#fk_deferred // off at the commit boundary). https://sqlite.org/foreignkeys.html#fk_deferred
transaction.pragma_update(None, "defer_foreign_keys", &"ON".to_string())?; transaction.pragma_update(None, "defer_foreign_keys", "ON".to_string())?;
let mut stmt = transaction.prepare_cached( let mut stmt = transaction.prepare_cached(
" "

View File

@ -44,7 +44,7 @@ pub fn add_server_systems(dispatch_builder: &mut DispatcherBuilder) {
dispatch::<chunk_send::Sys>(dispatch_builder, &[]); dispatch::<chunk_send::Sys>(dispatch_builder, &[]);
} }
pub fn run_sync_systems(ecs: &mut specs::World) { pub fn run_sync_systems(ecs: &specs::World) {
// Setup for entity sync // Setup for entity sync
// If I'm not mistaken, these two could be ran in parallel // If I'm not mistaken, these two could be ran in parallel
run_now::<sentinel::Sys>(ecs); run_now::<sentinel::Sys>(ecs);

View File

@ -517,7 +517,7 @@ pub fn maintain_egui_inner(
} }
fn selected_entity_window( fn selected_entity_window(
platform: &mut Platform, platform: &Platform,
ecs: &World, ecs: &World,
selected_entity_info: &mut SelectedEntityInfo, selected_entity_info: &mut SelectedEntityInfo,
egui_actions: &mut EguiActions, egui_actions: &mut EguiActions,

View File

@ -196,7 +196,7 @@ fn invalid_command_message(client: &Client, user_entered_invalid_command: String
} }
fn run_client_command( fn run_client_command(
client: &mut Client, client: &Client,
global_state: &mut GlobalState, global_state: &mut GlobalState,
command: ClientChatCommand, command: ClientChatCommand,
args: Vec<String>, args: Vec<String>,
@ -407,7 +407,7 @@ impl TabComplete for ArgumentSpec {
.filter(|string| string.starts_with(part)) .filter(|string| string.starts_with(part))
.map(|c| c.to_string()) .map(|c| c.to_string())
.collect(), .collect(),
ArgumentSpec::Boolean(_, part, _) => vec!["true", "false"] ArgumentSpec::Boolean(_, part, _) => ["true", "false"]
.iter() .iter()
.filter(|string| string.starts_with(part)) .filter(|string| string.starts_with(part))
.map(|c| c.to_string()) .map(|c| c.to_string())

View File

@ -196,7 +196,7 @@ impl<'a> InventoryScroller<'a> {
.set(self.bg_ids.bg_frame, ui); .set(self.bg_ids.bg_frame, ui);
} }
fn title(&mut self, state: &mut ConrodState<'_, InventoryScrollerState>, ui: &mut UiCell<'_>) { fn title(&mut self, state: &ConrodState<'_, InventoryScrollerState>, ui: &mut UiCell<'_>) {
Text::new( Text::new(
&self &self
.localized_strings .localized_strings
@ -371,7 +371,7 @@ impl<'a> InventoryScroller<'a> {
}); });
} }
for (pos, item) in items.into_iter() { for (pos, item) in items.into_iter() {
if self.details_mode && !self.is_us && matches!(item, None) { if self.details_mode && !self.is_us && item.is_none() {
continue; continue;
} }
let (x, y) = if self.details_mode { let (x, y) = if self.details_mode {
@ -488,7 +488,7 @@ impl<'a> InventoryScroller<'a> {
fn footer_metrics( fn footer_metrics(
&mut self, &mut self,
state: &mut ConrodState<'_, InventoryScrollerState>, state: &ConrodState<'_, InventoryScrollerState>,
ui: &mut UiCell<'_>, ui: &mut UiCell<'_>,
) { ) {
let space_used = self.inventory.populated_slots(); let space_used = self.inventory.populated_slots();

View File

@ -874,13 +874,13 @@ mod tests {
#[test] #[test]
fn parse_cmds() { fn parse_cmds() {
let expected: Result<(String, Vec<String>), String> = Ok(("help".to_string(), vec![])); let expected: Result<(String, Vec<String>), String> = Ok(("help".to_string(), vec![]));
assert_eq!(parse_cmd(r#"help"#), expected); assert_eq!(parse_cmd(r"help"), expected);
let expected: Result<(String, Vec<String>), String> = Ok(("say".to_string(), vec![ let expected: Result<(String, Vec<String>), String> = Ok(("say".to_string(), vec![
"foo".to_string(), "foo".to_string(),
"bar".to_string(), "bar".to_string(),
])); ]));
assert_eq!(parse_cmd(r#"say foo bar"#), expected); assert_eq!(parse_cmd(r"say foo bar"), expected);
assert_eq!(parse_cmd(r#"say "foo" "bar""#), expected); assert_eq!(parse_cmd(r#"say "foo" "bar""#), expected);
let expected: Result<(String, Vec<String>), String> = let expected: Result<(String, Vec<String>), String> =

View File

@ -1479,7 +1479,7 @@ impl<'a> Widget for Crafting<'a> {
}); });
self.inventory self.inventory
.slots_with_id() .slots_with_id()
.filter(|(_, item)| item.as_ref().map_or(false, |i| can_repair(i))) .filter(|(_, item)| item.as_ref().map_or(false, can_repair))
.for_each(|(slot, _)| { .for_each(|(slot, _)| {
events.push(Event::RepairItem { events.push(Event::RepairItem {
slot: Slot::Inventory(slot), slot: Slot::Inventory(slot),
@ -1489,7 +1489,7 @@ impl<'a> Widget for Crafting<'a> {
let can_perform = repair_slot let can_perform = repair_slot
.item(self.inventory) .item(self.inventory)
.map_or(false, |item| can_repair(item)); .map_or(false, can_repair);
(repair_slot.slot, None, can_perform) (repair_slot.slot, None, can_perform)
}, },

View File

@ -2572,7 +2572,7 @@ impl<'a> Diary<'a> {
ui: &mut UiCell, ui: &mut UiCell,
events: &mut Vec<Event>, events: &mut Vec<Event>,
diary_tooltip: &Tooltip, diary_tooltip: &Tooltip,
state: &mut State<DiaryState>, state: &State<DiaryState>,
) { ) {
for (i, icon) in icons.iter().enumerate() { for (i, icon) in icons.iter().enumerate() {
match icon { match icon {
@ -2824,7 +2824,7 @@ impl<'a> Diary<'a> {
ui: &mut UiCell, ui: &mut UiCell,
events: &mut Vec<Event>, events: &mut Vec<Event>,
diary_tooltip: &Tooltip, diary_tooltip: &Tooltip,
state: &mut State<DiaryState>, state: &State<DiaryState>,
) { ) {
let locked = !self.skill_set.prerequisites_met(skill); let locked = !self.skill_set.prerequisites_met(skill);
let owned = self.skill_set.has_skill(skill); let owned = self.skill_set.has_skill(skill);

View File

@ -516,19 +516,7 @@ impl BuffIconKind {
impl PartialOrd for BuffIconKind { impl PartialOrd for BuffIconKind {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
match (self, other) { Some(self.cmp(other))
(
BuffIconKind::Buff { kind, .. },
BuffIconKind::Buff {
kind: other_kind, ..
},
) => Some(kind.cmp(other_kind)),
(BuffIconKind::Buff { .. }, BuffIconKind::Stance(_)) => Some(Ordering::Greater),
(BuffIconKind::Stance(_), BuffIconKind::Buff { .. }) => Some(Ordering::Less),
(BuffIconKind::Stance(stance), BuffIconKind::Stance(stance_other)) => {
Some(stance.cmp(stance_other))
},
}
} }
} }
@ -586,7 +574,7 @@ impl BuffIcon {
buffs buffs
.iter_active() .iter_active()
.filter_map(BuffIcon::from_buffs) .filter_map(BuffIcon::from_buffs)
.chain(stance.and_then(BuffIcon::from_stance).into_iter()) .chain(stance.and_then(BuffIcon::from_stance))
.collect::<Vec<_>>() .collect::<Vec<_>>()
} }
@ -1089,7 +1077,7 @@ impl Show {
|| !matches!(self.open_windows, Windows::None) || !matches!(self.open_windows, Windows::None)
} }
fn toggle_windows(&mut self, global_state: &mut GlobalState) { fn toggle_windows(&mut self, global_state: &GlobalState) {
if self.any_window_requires_cursor() { if self.any_window_requires_cursor() {
self.bag = false; self.bag = false;
self.trade = false; self.trade = false;
@ -1146,7 +1134,7 @@ impl Show {
/// If all of the menus are closed, adjusts coordinates of cursor to center /// If all of the menus are closed, adjusts coordinates of cursor to center
/// of screen /// of screen
fn toggle_cursor_on_menu_close(&self, global_state: &mut GlobalState, ui: &mut Ui) { fn toggle_cursor_on_menu_close(&self, global_state: &GlobalState, ui: &mut Ui) {
if !self.bag if !self.bag
&& !self.trade && !self.trade
&& !self.esc_menu && !self.esc_menu

View File

@ -223,7 +223,7 @@ impl<'a> Widget for Quest<'a> {
// [amount, item_desc] // [amount, item_desc]
//("common.items.weapons.sword.caladbolg"); //("common.items.weapons.sword.caladbolg");
let rewards = vec![ let rewards = [
(1, "common.items.weapons.dagger.starter_dagger", "Dagger"), (1, "common.items.weapons.dagger.starter_dagger", "Dagger"),
(4, "common.items.crafting_ing.seashells", "Seashell"), (4, "common.items.crafting_ing.seashells", "Seashell"),
( (

View File

@ -143,7 +143,7 @@ impl<'a> Trade<'a> {
const MAX_TRADE_SLOTS: usize = 16; const MAX_TRADE_SLOTS: usize = 16;
impl<'a> Trade<'a> { impl<'a> Trade<'a> {
fn background(&mut self, state: &mut ConrodState<'_, State>, ui: &mut UiCell<'_>) { fn background(&mut self, state: &ConrodState<'_, State>, ui: &mut UiCell<'_>) {
Image::new(self.imgs.inv_middle_bg_bag) Image::new(self.imgs.inv_middle_bg_bag)
.w_h(424.0, 482.0) .w_h(424.0, 482.0)
.color(Some(UI_MAIN)) .color(Some(UI_MAIN))
@ -156,7 +156,7 @@ impl<'a> Trade<'a> {
.set(state.ids.bg_frame, ui); .set(state.ids.bg_frame, ui);
} }
fn title(&mut self, state: &mut ConrodState<'_, State>, ui: &mut UiCell<'_>) { fn title(&mut self, state: &ConrodState<'_, State>, ui: &mut UiCell<'_>) {
Text::new(&self.localized_strings.get_msg("hud-trade-trade_window")) Text::new(&self.localized_strings.get_msg("hud-trade-trade_window"))
.mid_top_with_margin_on(state.ids.bg_frame, 9.0) .mid_top_with_margin_on(state.ids.bg_frame, 9.0)
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
@ -173,7 +173,7 @@ impl<'a> Trade<'a> {
fn phase_indicator( fn phase_indicator(
&mut self, &mut self,
state: &mut ConrodState<'_, State>, state: &ConrodState<'_, State>,
ui: &mut UiCell<'_>, ui: &mut UiCell<'_>,
trade: &'a PendingTrade, trade: &'a PendingTrade,
) { ) {
@ -566,7 +566,7 @@ impl<'a> Trade<'a> {
fn accept_decline_buttons( fn accept_decline_buttons(
&mut self, &mut self,
state: &mut ConrodState<'_, State>, state: &ConrodState<'_, State>,
ui: &mut UiCell<'_>, ui: &mut UiCell<'_>,
trade: &'a PendingTrade, trade: &'a PendingTrade,
) -> Option<TradeEvent> { ) -> Option<TradeEvent> {
@ -632,7 +632,7 @@ impl<'a> Trade<'a> {
fn input_item_amount( fn input_item_amount(
&mut self, &mut self,
state: &mut ConrodState<'_, State>, state: &ConrodState<'_, State>,
ui: &mut UiCell<'_>, ui: &mut UiCell<'_>,
trade: &'a PendingTrade, trade: &'a PendingTrade,
) -> Option<TradeEvent> { ) -> Option<TradeEvent> {
@ -760,7 +760,7 @@ impl<'a> Trade<'a> {
fn close_button( fn close_button(
&mut self, &mut self,
state: &mut ConrodState<'_, State>, state: &ConrodState<'_, State>,
ui: &mut UiCell<'_>, ui: &mut UiCell<'_>,
) -> Option<TradeEvent> { ) -> Option<TradeEvent> {
if Button::image(self.imgs.close_btn) if Button::image(self.imgs.close_btn)

View File

@ -529,8 +529,8 @@ pub fn generate_mesh<'a>(
( (
opaque_deep opaque_deep
.into_iter() .into_iter()
.chain(opaque_shallow.into_iter()) .chain(opaque_shallow)
.chain(opaque_surface.into_iter()) .chain(opaque_surface)
.collect(), .collect(),
fluid_mesh, fluid_mesh,
Mesh::new(), Mesh::new(),

View File

@ -275,7 +275,7 @@ impl ShaderModules {
}) })
.unwrap(); .unwrap();
let mut compiler = Compiler::new().ok_or(RenderError::ErrorInitializingCompiler)?; let compiler = Compiler::new().ok_or(RenderError::ErrorInitializingCompiler)?;
let mut options = CompileOptions::new().ok_or(RenderError::ErrorInitializingCompiler)?; let mut options = CompileOptions::new().ok_or(RenderError::ErrorInitializingCompiler)?;
options.set_optimization_level(OptimizationLevel::Performance); options.set_optimization_level(OptimizationLevel::Performance);
options.set_forced_version_profile(430, shaderc::GlslProfile::Core); options.set_forced_version_profile(430, shaderc::GlslProfile::Core);
@ -306,13 +306,13 @@ impl ShaderModules {
}) })
}); });
let mut create_shader = |name, kind| { let create_shader = |name, kind| {
let glsl = &shaders let glsl = &shaders
.get(name) .get(name)
.unwrap_or_else(|| panic!("Can't retrieve shader: {}", name)) .unwrap_or_else(|| panic!("Can't retrieve shader: {}", name))
.0; .0;
let file_name = format!("{}.glsl", name); let file_name = format!("{}.glsl", name);
create_shader_module(device, &mut compiler, glsl, kind, &file_name, &options) create_shader_module(device, &compiler, glsl, kind, &file_name, &options)
}; };
let selected_fluid_shader = ["fluid-frag.", match pipeline_modes.fluid { let selected_fluid_shader = ["fluid-frag.", match pipeline_modes.fluid {
@ -388,7 +388,7 @@ impl ShaderModules {
fn create_shader_module( fn create_shader_module(
device: &wgpu::Device, device: &wgpu::Device,
compiler: &mut shaderc::Compiler, compiler: &shaderc::Compiler,
source: &str, source: &str,
kind: shaderc::ShaderKind, kind: shaderc::ShaderKind,
file_name: &str, file_name: &str,

View File

@ -1069,7 +1069,7 @@ fn mesh_hold() -> BoneMeshes {
) )
} }
///////// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct QuadrupedSmallCentralSpec(HashMap<(QSSpecies, QSBodyType), SidedQSCentralVoxSpec>); struct QuadrupedSmallCentralSpec(HashMap<(QSSpecies, QSBodyType), SidedQSCentralVoxSpec>);
@ -1660,7 +1660,7 @@ impl QuadrupedMediumLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BirdMediumCentralSpec(HashMap<(BMSpecies, BMBodyType), SidedBMCentralVoxSpec>); struct BirdMediumCentralSpec(HashMap<(BMSpecies, BMBodyType), SidedBMCentralVoxSpec>);
@ -1914,7 +1914,7 @@ impl BirdMediumLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct TheropodCentralSpec(HashMap<(TSpecies, TBodyType), SidedTCentralVoxSpec>); struct TheropodCentralSpec(HashMap<(TSpecies, TBodyType), SidedTCentralVoxSpec>);
@ -2244,7 +2244,7 @@ impl TheropodLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct ArthropodCentralSpec(HashMap<(ASpecies, ABodyType), SidedACentralVoxSpec>); struct ArthropodCentralSpec(HashMap<(ASpecies, ABodyType), SidedACentralVoxSpec>);
@ -2644,7 +2644,7 @@ impl ArthropodLateralSpec {
(lateral, Vec3::from(spec.leg_br.offset)) (lateral, Vec3::from(spec.leg_br.offset))
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct FishMediumCentralSpec(HashMap<(FMSpecies, FMBodyType), SidedFMCentralVoxSpec>); struct FishMediumCentralSpec(HashMap<(FMSpecies, FMBodyType), SidedFMCentralVoxSpec>);
@ -2850,7 +2850,7 @@ impl FishMediumLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct FishSmallCentralSpec(HashMap<(FSSpecies, FSBodyType), SidedFSCentralVoxSpec>); struct FishSmallCentralSpec(HashMap<(FSSpecies, FSBodyType), SidedFSCentralVoxSpec>);
@ -2994,7 +2994,7 @@ impl FishSmallLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BipedSmallWeaponSpec(HashMap<ToolKey, ArmorVoxSpec>); struct BipedSmallWeaponSpec(HashMap<ToolKey, ArmorVoxSpec>);
@ -3269,8 +3269,8 @@ impl BipedSmallWeaponSpec {
(tool_kind_segment, offset) (tool_kind_segment, offset)
} }
} }
////
//////
#[derive(Deserialize)] #[derive(Deserialize)]
struct DragonCentralSpec(HashMap<(DSpecies, DBodyType), SidedDCentralVoxSpec>); struct DragonCentralSpec(HashMap<(DSpecies, DBodyType), SidedDCentralVoxSpec>);
@ -3641,7 +3641,7 @@ impl DragonLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BirdLargeCentralSpec(HashMap<(BLASpecies, BLABodyType), SidedBLACentralVoxSpec>); struct BirdLargeCentralSpec(HashMap<(BLASpecies, BLABodyType), SidedBLACentralVoxSpec>);
@ -4044,7 +4044,7 @@ impl BirdLargeLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct BipedLargeCentralSpec(HashMap<(BLSpecies, BLBodyType), SidedBLCentralVoxSpec>); struct BipedLargeCentralSpec(HashMap<(BLSpecies, BLBodyType), SidedBLCentralVoxSpec>);
@ -4462,7 +4462,8 @@ impl BipedLargeSecondSpec {
(tool_kind_segment, offset) (tool_kind_segment, offset)
} }
} }
////
//////
#[derive(Deserialize)] #[derive(Deserialize)]
struct GolemCentralSpec(HashMap<(GSpecies, GBodyType), SidedGCentralVoxSpec>); struct GolemCentralSpec(HashMap<(GSpecies, GBodyType), SidedGCentralVoxSpec>);
@ -4772,8 +4773,7 @@ impl GolemLateralSpec {
} }
} }
///// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct QuadrupedLowCentralSpec(HashMap<(QLSpecies, QLBodyType), SidedQLCentralVoxSpec>); struct QuadrupedLowCentralSpec(HashMap<(QLSpecies, QLBodyType), SidedQLCentralVoxSpec>);
@ -5050,8 +5050,7 @@ impl QuadrupedLowLateralSpec {
} }
} }
//// //////
#[derive(Deserialize)] #[derive(Deserialize)]
struct ObjectCentralSpec(HashMap<object::Body, SidedObjectCentralVoxSpec>); struct ObjectCentralSpec(HashMap<object::Body, SidedObjectCentralVoxSpec>);

View File

@ -527,7 +527,7 @@ pub struct FigureMgr {
} }
impl FigureMgr { impl FigureMgr {
pub fn new(renderer: &mut Renderer) -> Self { pub fn new(renderer: &Renderer) -> Self {
Self { Self {
atlas: FigureAtlas::new(renderer), atlas: FigureAtlas::new(renderer),
model_cache: FigureModelCache::new(), model_cache: FigureModelCache::new(),
@ -1101,8 +1101,8 @@ impl FigureMgr {
let holding_lantern = inventory let holding_lantern = inventory
.map_or(false, |i| i.equipped(EquipSlot::Lantern).is_some()) .map_or(false, |i| i.equipped(EquipSlot::Lantern).is_some())
&& light_emitter.is_some() && light_emitter.is_some()
&& !((matches!(second_tool_hand, Some(_)) && !(second_tool_hand.is_some()
|| matches!(active_tool_hand, Some(Hands::Two))) || matches!(active_tool_hand, Some(Hands::Two))
&& character.map_or(false, |c| c.is_wield())) && character.map_or(false, |c| c.is_wield()))
&& !character.map_or(false, |c| c.is_using_hands()) && !character.map_or(false, |c| c.is_using_hands())
&& physics.in_liquid().is_none(); && physics.in_liquid().is_none();
@ -7373,7 +7373,7 @@ pub struct FigureAtlas {
} }
impl FigureAtlas { impl FigureAtlas {
pub fn new(renderer: &mut Renderer) -> Self { pub fn new(renderer: &Renderer) -> Self {
let allocator = let allocator =
Self::make_allocator(renderer).expect("Failed to create texture atlas for figures"); Self::make_allocator(renderer).expect("Failed to create texture atlas for figures");
Self { Self {
@ -7499,7 +7499,7 @@ impl FigureAtlas {
} }
} }
fn make_allocator(renderer: &mut Renderer) -> Result<AtlasAllocator, RenderError> { fn make_allocator(renderer: &Renderer) -> Result<AtlasAllocator, RenderError> {
let max_texture_size = renderer.max_texture_size(); let max_texture_size = renderer.max_texture_size();
let atlas_size = guillotiere::Size::new(max_texture_size as i32, max_texture_size as i32); let atlas_size = guillotiere::Size::new(max_texture_size as i32, max_texture_size as i32);
let allocator = AtlasAllocator::with_options(atlas_size, &guillotiere::AllocatorOptions { let allocator = AtlasAllocator::with_options(atlas_size, &guillotiere::AllocatorOptions {

View File

@ -137,7 +137,7 @@ impl Scene {
figure_state: None, figure_state: None,
backdrop: backdrop.map(|specifier| { backdrop: backdrop.map(|specifier| {
let mut state = FigureState::new(renderer, FixtureSkeleton::default(), ()); let mut state = FigureState::new(renderer, FixtureSkeleton, ());
let mut greedy = FigureModel::make_greedy(); let mut greedy = FigureModel::make_greedy();
let mut opaque_mesh = Mesh::new(); let mut opaque_mesh = Mesh::new();
let (segment, offset) = load_mesh(specifier, Vec3::new(-55.0, -49.5, -2.0)); let (segment, offset) = load_mesh(specifier, Vec3::new(-55.0, -49.5, -2.0));

View File

@ -437,8 +437,8 @@ fn mesh_worker(
( (
deep_level deep_level
.into_iter() .into_iter()
.chain(shallow_level.into_iter()) .chain(shallow_level)
.chain(surface_level.into_iter()) .chain(surface_level)
.collect(), .collect(),
alt_indices, alt_indices,
) )
@ -535,7 +535,7 @@ pub struct SpriteRenderContext {
pub type SpriteRenderContextLazy = Box<dyn FnMut(&mut Renderer) -> SpriteRenderContext>; pub type SpriteRenderContextLazy = Box<dyn FnMut(&mut Renderer) -> SpriteRenderContext>;
impl SpriteRenderContext { impl SpriteRenderContext {
pub fn new(renderer: &mut Renderer) -> SpriteRenderContextLazy { pub fn new(renderer: &Renderer) -> SpriteRenderContextLazy {
let max_texture_size = renderer.max_texture_size(); let max_texture_size = renderer.max_texture_size();
struct SpriteWorkerResponse { struct SpriteWorkerResponse {

View File

@ -59,7 +59,7 @@ impl Interactable {
volume_pos: VolumePos, volume_pos: VolumePos,
interaction: Interaction, interaction: Interaction,
) -> Option<Self> { ) -> Option<Self> {
let Some(block) = volume_pos.get_block(terrain, id_maps, colliders) else { return None }; let block= volume_pos.get_block(terrain, id_maps, colliders)?;
let block_interaction = match interaction { let block_interaction = match interaction {
Interaction::Collect => { Interaction::Collect => {
// Check if this is an unlockable sprite // Check if this is an unlockable sprite

View File

@ -793,7 +793,7 @@ pub fn change_render_mode(
fn adjust_terrain_view_distance( fn adjust_terrain_view_distance(
terrain_vd: u32, terrain_vd: u32,
settings: &mut Settings, settings: &mut Settings,
session_state: &mut SessionState, session_state: &SessionState,
) { ) {
settings.graphics.terrain_view_distance = terrain_vd; settings.graphics.terrain_view_distance = terrain_vd;
client_set_view_distance(settings, session_state); client_set_view_distance(settings, session_state);
@ -802,13 +802,13 @@ fn adjust_terrain_view_distance(
fn adjust_entity_view_distance( fn adjust_entity_view_distance(
entity_vd: u32, entity_vd: u32,
settings: &mut Settings, settings: &mut Settings,
session_state: &mut SessionState, session_state: &SessionState,
) { ) {
settings.graphics.entity_view_distance = entity_vd; settings.graphics.entity_view_distance = entity_vd;
client_set_view_distance(settings, session_state); client_set_view_distance(settings, session_state);
} }
fn client_set_view_distance(settings: &Settings, session_state: &mut SessionState) { fn client_set_view_distance(settings: &Settings, session_state: &SessionState) {
let view_distances = common::ViewDistances { let view_distances = common::ViewDistances {
terrain: settings.graphics.terrain_view_distance, terrain: settings.graphics.terrain_view_distance,
entity: settings.graphics.entity_view_distance, entity: settings.graphics.entity_view_distance,

View File

@ -5,7 +5,7 @@ mod widget;
pub use defaults::Defaults; pub use defaults::Defaults;
pub(self) use primitive::Primitive; use primitive::Primitive;
use super::{ use super::{
super::graphic::{self, Graphic, TexId}, super::graphic::{self, Graphic, TexId},

View File

@ -675,6 +675,7 @@ impl Window {
.game_analog_button_map .game_analog_button_map
.get(&AnalogButton::from((button, code))) .get(&AnalogButton::from((button, code)))
{ {
#[allow(clippy::never_loop)]
for action in actions { for action in actions {
match *action {} match *action {}
} }
@ -684,6 +685,7 @@ impl Window {
.menu_analog_button_map .menu_analog_button_map
.get(&AnalogButton::from((button, code))) .get(&AnalogButton::from((button, code)))
{ {
#[allow(clippy::never_loop)]
for action in actions { for action in actions {
match *action {} match *action {}
} }

View File

@ -691,7 +691,7 @@ fn main() {
let k = 32; let k = 32;
let sz = world.sim().get_size(); let sz = world.sim().get_size();
let sites = vec![ let sites = [
("center", sz / 2), ("center", sz / 2),
( (
"dungeon", "dungeon",

View File

@ -11,7 +11,7 @@ fn main() {
]); ]);
let mut middle = cons.clone(); let mut middle = cons.clone();
middle.extend(vec!["tt"]); middle.extend(vec!["tt"]);
let vowel = vec!["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"]; let vowel = ["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"];
let end = vec![ let end = vec![
"et", "ige", "age", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ist", "et", "ige", "age", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ist",
"ed", "est", "eed", "ast", "olt", "ey", "ean", "ead", "onk", "ink", "eon", "er", "ow", "ed", "est", "eed", "ast", "olt", "ey", "ean", "ead", "onk", "ink", "eon", "er", "ow",

View File

@ -198,7 +198,7 @@ fn palette(conn: Connection) -> Result<(), Box<dyn Error>> {
let count: i64 = row.get(4)?; let count: i64 = row.get(4)?;
block_colors block_colors
.entry(kind) .entry(kind)
.or_insert_with(Vec::new) .or_default()
.push((rgb, count)); .push((rgb, count));
} }
for (_, v) in block_colors.iter_mut() { for (_, v) in block_colors.iter_mut() {
@ -207,7 +207,7 @@ fn palette(conn: Connection) -> Result<(), Box<dyn Error>> {
let mut palettes: HashMap<BlockKind, Vec<Rgb<u8>>> = HashMap::new(); let mut palettes: HashMap<BlockKind, Vec<Rgb<u8>>> = HashMap::new();
for (kind, colors) in block_colors.iter() { for (kind, colors) in block_colors.iter() {
let palette = palettes.entry(*kind).or_insert_with(Vec::new); let palette = palettes.entry(*kind).or_default();
if colors.len() <= 256 { if colors.len() <= 256 {
for (color, _) in colors { for (color, _) in colors {
palette.push(*color); palette.push(*color);

View File

@ -1514,7 +1514,7 @@ impl Civs {
/// Attempt to find a path between two locations /// Attempt to find a path between two locations
fn find_path( fn find_path(
ctx: &mut GenCtx<impl Rng>, ctx: &GenCtx<impl Rng>,
get_bridge: impl Fn(Vec2<i32>) -> Option<Vec2<i32>>, get_bridge: impl Fn(Vec2<i32>) -> Option<Vec2<i32>>,
a: Vec2<i32>, a: Vec2<i32>,
b: Vec2<i32>, b: Vec2<i32>,

View File

@ -1036,7 +1036,6 @@ pub fn apply_caverns_to<R: Rng>(canvas: &mut Canvas, dynamic_rng: &mut R) {
} }
}; };
let cavern_top = cavern_top;
let mut last_kind = BlockKind::Rock; let mut last_kind = BlockKind::Rock;
for z in cavern_bottom - 1..cavern_top { for z in cavern_bottom - 1..cavern_top {
use SpriteKind::*; use SpriteKind::*;

View File

@ -31,7 +31,7 @@ impl<'a, R: Rng> NameGen<'a, R> {
]); ]);
let mut middle = cons.clone(); let mut middle = cons.clone();
middle.extend(vec!["tt"]); middle.extend(vec!["tt"]);
let vowel = vec!["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"]; let vowel = ["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"];
let end = vec![ let end = vec![
"et", "ige", "age", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ist", "et", "ige", "age", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ist",
"ed", "est", "eed", "ast", "olt", "ey", "ean", "ead", "onk", "ink", "eon", "er", "ow", "ed", "est", "eed", "ast", "olt", "ey", "ean", "ead", "onk", "ink", "eon", "er", "ow",

View File

@ -641,7 +641,7 @@ impl Archetype for House {
% 6 % 6
{ {
0 => SpriteKind::HangingSign, 0 => SpriteKind::HangingSign,
1 | 2 | 3 => SpriteKind::HangingBasket, 1..=3 => SpriteKind::HangingBasket,
4 => SpriteKind::WallSconce, 4 => SpriteKind::WallSconce,
5 => SpriteKind::WallLampSmall, 5 => SpriteKind::WallLampSmall,
_ => SpriteKind::DungeonWallDecor, _ => SpriteKind::DungeonWallDecor,

View File

@ -1414,7 +1414,7 @@ impl Land {
} }
} }
closed.into_iter().chain(open.into_iter()).collect() closed.into_iter().chain(open).collect()
} }
fn write_path( fn write_path(

View File

@ -298,7 +298,7 @@ impl GnarlingFortification {
wall_connections wall_connections
.iter() .iter()
.copied() .copied()
.zip(inner_tower_locs.into_iter()), .zip(inner_tower_locs),
) )
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -454,7 +454,6 @@ impl Structure for GnarlingFortification {
}) })
.for_each(|(point, next_point)| { .for_each(|(point, next_point)| {
// 2d world positions of each point in wall segment // 2d world positions of each point in wall segment
let point = point;
let start_wpos = point + self.origin; let start_wpos = point + self.origin;
let end_wpos = next_point + self.origin; let end_wpos = next_point + self.origin;
@ -1829,7 +1828,7 @@ impl Structure for GnarlingFortification {
} }
tunnels tunnels
.into_iter() .into_iter()
.chain(rooms.into_iter()) .chain(rooms)
.chain(core::iter::once(boss_room)) .chain(core::iter::once(boss_room))
.chain(core::iter::once(stump)) .chain(core::iter::once(stump))
.for_each(|prim| prim.fill(wood.clone())); .for_each(|prim| prim.fill(wood.clone()));
@ -1839,7 +1838,7 @@ impl Structure for GnarlingFortification {
let mut sprite_clear = Vec::new(); let mut sprite_clear = Vec::new();
tunnels_clear tunnels_clear
.into_iter() .into_iter()
.chain(rooms_clear.into_iter()) .chain(rooms_clear)
.chain(core::iter::once(boss_room_clear)) .chain(core::iter::once(boss_room_clear))
.for_each(|prim| { .for_each(|prim| {
sprite_clear.push(prim.translate(Vec3::new(0, 0, 1)).intersect(prim)); sprite_clear.push(prim.translate(Vec3::new(0, 0, 1)).intersect(prim));