From 57fe89e5c8e331fee6d5fb97233f4d0b581b6e2d Mon Sep 17 00:00:00 2001 From: Louis Pearson Date: Fri, 6 Sep 2019 04:25:17 -0600 Subject: [PATCH] Fix warnings --- voxygen/src/audio/channel.rs | 8 ++++---- voxygen/src/audio/mod.rs | 10 +++++----- voxygen/src/menu/main/mod.rs | 2 +- voxygen/src/scene/sound.rs | 31 ++++++++++++++----------------- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/voxygen/src/audio/channel.rs b/voxygen/src/audio/channel.rs index 5adaff6e7d..d9a341324c 100644 --- a/voxygen/src/audio/channel.rs +++ b/voxygen/src/audio/channel.rs @@ -13,9 +13,9 @@ pub enum AudioType { #[derive(PartialEq, Clone, Copy)] enum ChannelState { - Init, - ToPlay, - Loading, + // Init, + // ToPlay, + // Loading, Playing, Stopping, Stopped, @@ -121,7 +121,7 @@ impl Channel { pub fn update(&mut self, dt: f32) { match self.state { - ChannelState::Init | ChannelState::ToPlay | ChannelState::Loading => {} + // ChannelState::Init | ChannelState::ToPlay | ChannelState::Loading => {} ChannelState::Playing => {} ChannelState::Stopping => { self.fader.update(dt); diff --git a/voxygen/src/audio/mod.rs b/voxygen/src/audio/mod.rs index ba63da5250..7745398a87 100644 --- a/voxygen/src/audio/mod.rs +++ b/voxygen/src/audio/mod.rs @@ -6,7 +6,7 @@ use fader::Fader; use soundcache::SoundCache; use common::assets; -use rodio::{Decoder, Device, SpatialSink}; +use rodio::{Decoder, Device}; use vek::*; const FALLOFF: f32 = 0.13; @@ -36,7 +36,7 @@ impl AudioFrontend { let mut channels = Vec::with_capacity(channel_num); let audio_device = get_device_raw(&device); if let Some(audio_device) = &audio_device { - for i in (0..channel_num) { + for _i in 0..channel_num { channels.push(Channel::new(&audio_device)); } } @@ -76,7 +76,7 @@ impl AudioFrontend { /// Maintain audio pub fn maintain(&mut self, dt: f32) { - for (i, channel) in self.channels.iter_mut().enumerate() { + for channel in self.channels.iter_mut() { channel.update(dt); } } @@ -93,7 +93,7 @@ impl AudioFrontend { let id = self.next_channel_id; self.next_channel_id += 1; - if let Some(device) = &self.audio_device { + if let Some(_) = &self.audio_device { let calc_pos = [ (pos.x - self.listener_pos.x) * FALLOFF, (pos.y - self.listener_pos.y) * FALLOFF, @@ -148,7 +148,7 @@ impl AudioFrontend { let id = self.next_channel_id; self.next_channel_id += 1; - if let Some(device) = &self.audio_device { + if let Some(_) = &self.audio_device { let file = assets::load_file(&sound, &["ogg"]).unwrap(); let sound = Decoder::new(file).unwrap(); diff --git a/voxygen/src/menu/main/mod.rs b/voxygen/src/menu/main/mod.rs index 884f136de1..6b8bbca182 100644 --- a/voxygen/src/menu/main/mod.rs +++ b/voxygen/src/menu/main/mod.rs @@ -3,7 +3,7 @@ mod start_singleplayer; mod ui; use super::char_selection::CharSelectionState; -use crate::{audio::fader::Fader, window::Event, Direction, GlobalState, PlayState, PlayStateResult}; +use crate::{window::Event, Direction, GlobalState, PlayState, PlayStateResult}; use client_init::{ClientInit, Error as InitError}; use common::{clock::Clock, comp}; use log::warn; diff --git a/voxygen/src/scene/sound.rs b/voxygen/src/scene/sound.rs index bfc1193c65..26f7ab04e4 100644 --- a/voxygen/src/scene/sound.rs +++ b/voxygen/src/scene/sound.rs @@ -1,31 +1,23 @@ -use crate::{ - audio::AudioFrontend, -}; -use common::comp::{ - Pos, - Ori, - Body, - CharacterState, - MovementState::*, -}; +use crate::audio::AudioFrontend; use client::Client; -use vek::*; -use specs::{Entity as EcsEntity, Join}; +use common::comp::{Body, CharacterState, MovementState::*, Ori, Pos}; use hashbrown::HashMap; -use std::{f32, time::Instant}; +use specs::{Entity as EcsEntity, Join}; +use std::time::Instant; +use vek::*; pub struct AnimState { last_step_sound: Instant, } pub struct SoundMgr { - character_states: HashMap + character_states: HashMap, } impl SoundMgr { pub fn new() -> Self { Self { - character_states: HashMap::new(), + character_states: HashMap::new(), } } @@ -60,12 +52,17 @@ impl SoundMgr { let state = self .character_states .entry(entity) - .or_insert_with(|| AnimState {last_step_sound: Instant::now()}); + .or_insert_with(|| AnimState { + last_step_sound: Instant::now(), + }); if let Run = &character.movement { if state.last_step_sound.elapsed().as_secs_f64() > 0.25 { let rand_step = (rand::random::() % 7) + 1; - audio.play_sound(format!("voxygen.audio.footsteps.stepdirt_{}", rand_step), pos.0); + audio.play_sound( + format!("voxygen.audio.footsteps.stepdirt_{}", rand_step), + pos.0, + ); state.last_step_sound = Instant::now(); } }