Fix clippy warnings

This commit is contained in:
Imbris 2020-10-05 04:56:28 -04:00
parent 522880a0ab
commit fb2cf1a292
8 changed files with 37 additions and 33 deletions

View File

@ -44,7 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Overhauled representation of blocks to permit fluid and sprite coexistence - Overhauled representation of blocks to permit fluid and sprite coexistence
- Overhauled sword - Overhauled sword
- Reworked healing sceptre - Reworked healing sceptre
- Split out the sections of the server settings that can be edtited and saved by the server. - Split out the sections of the server settings that can be edited and saved by the server.
- Revamped structure of where settings, logs, and game saves are stored so that almost everything is in one place. - Revamped structure of where settings, logs, and game saves are stored so that almost everything is in one place.
### Removed ### Removed

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
comp::{ comp::{
projectile, Damage, DamageSource, Energy, EnergySource, HealthChange, HealthSource, Group, projectile, Damage, DamageSource, Energy, EnergySource, Group, HealthChange, HealthSource,
Loadout, Ori, PhysicsState, Pos, Projectile, Vel, Loadout, Ori, PhysicsState, Pos, Projectile, Vel,
}, },
event::{EventBus, LocalEvent, ServerEvent}, event::{EventBus, LocalEvent, ServerEvent},
@ -82,7 +82,7 @@ impl<'a> System<'a> for Sys {
// if there is at least one touching entity // if there is at least one touching entity
.and_then(|uid| uid_allocator.retrieve_entity_internal(uid.into())) .and_then(|uid| uid_allocator.retrieve_entity_internal(uid.into()))
.and_then(|e| groups.get(e)) .and_then(|e| groups.get(e))
.map_or(false, |owner_group| .map_or(false, |owner_group|
Some(owner_group) == uid_allocator Some(owner_group) == uid_allocator
.retrieve_entity_internal(other.into()) .retrieve_entity_internal(other.into())
.and_then(|e| groups.get(e)) .and_then(|e| groups.get(e))

View File

@ -1,9 +1,9 @@
use std::path::PathBuf; use std::path::PathBuf;
const VELOREN_USERDATA_ENV: &'static str = "VELOREN_USERDATA"; const VELOREN_USERDATA_ENV: &str = "VELOREN_USERDATA";
// TODO: consider expanding this to a general install strategy variable that is also used for // TODO: consider expanding this to a general install strategy variable that is
// finding assets // also used for finding assets
/// # `VELOREN_USERDATA_STRATEGY` environment variable /// # `VELOREN_USERDATA_STRATEGY` environment variable
/// Read during compilation /// Read during compilation
/// Useful to set when compiling for distribution /// Useful to set when compiling for distribution
@ -15,8 +15,8 @@ const VELOREN_USERDATA_ENV: &'static str = "VELOREN_USERDATA";
/// The first specified in this list is used /// The first specified in this list is used
/// 1. The VELOREN_USERDATA environment variable /// 1. The VELOREN_USERDATA environment variable
/// 2. The VELOREN_USERDATA_STRATEGY environment variable /// 2. The VELOREN_USERDATA_STRATEGY environment variable
/// 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata depending on if a /// 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata
/// workspace if being used /// depending on if a workspace if being used
pub fn userdata_dir(workspace: bool, strategy: Option<&str>, manifest_dir: &str) -> PathBuf { pub fn userdata_dir(workspace: bool, strategy: Option<&str>, manifest_dir: &str) -> PathBuf {
// 1. The VELOREN_USERDATA environment variable // 1. The VELOREN_USERDATA environment variable
std::env::var_os(VELOREN_USERDATA_ENV) std::env::var_os(VELOREN_USERDATA_ENV)
@ -39,11 +39,10 @@ pub fn userdata_dir(workspace: bool, strategy: Option<&str>, manifest_dir: &str)
}, },
Some(_) => None, // TODO: panic? catch during compilation? Some(_) => None, // TODO: panic? catch during compilation?
_ => None, _ => None,
}) })
// 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata depending on if a // 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata depending on if a
// workspace if being used // workspace if being used
.unwrap_or_else(|| { .unwrap_or_else(|| {
let mut path = PathBuf::from(manifest_dir); let mut path = PathBuf::from(manifest_dir);
if workspace { if workspace {
path.pop(); path.pop();
@ -58,7 +57,8 @@ macro_rules! userdata_dir_workspace {
() => { () => {
$crate::util::userdata_dir::userdata_dir( $crate::util::userdata_dir::userdata_dir(
true, true,
option_env!("VELOREN_USERDATA_STRATEGY"), env!("CARGO_MANIFEST_DIR") option_env!("VELOREN_USERDATA_STRATEGY"),
env!("CARGO_MANIFEST_DIR"),
) )
}; };
} }
@ -68,9 +68,8 @@ macro_rules! userdata_dir_no_workspace {
() => { () => {
$crate::util::userdata_dir::userdata_dir( $crate::util::userdata_dir::userdata_dir(
false, false,
option_env!("VELOREN_USERDATA_STRATEGY"), env!("CARGO_MANIFEST_DIR") option_env!("VELOREN_USERDATA_STRATEGY"),
env!("CARGO_MANIFEST_DIR"),
) )
}; };
} }

View File

@ -122,7 +122,7 @@ impl Tui {
pub fn run(basic: bool) -> Self { pub fn run(basic: bool) -> Self {
let (mut msg_s, msg_r) = mpsc::channel(); let (mut msg_s, msg_r) = mpsc::channel();
let running = Arc::new(AtomicBool::new(true)); let running = Arc::new(AtomicBool::new(true));
let running2 = running.clone(); let running2 = Arc::clone(&running);
let background = if basic { let background = if basic {
std::thread::spawn(move || { std::thread::spawn(move || {

View File

@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
/// Used so that different server frontends can share the same server saves, /// Used so that different server frontends can share the same server saves,
/// etc. /// etc.
pub const DEFAULT_DATA_DIR_NAME: &'static str = "server"; pub const DEFAULT_DATA_DIR_NAME: &str = "server";
/// Indicates where maps, saves, and server_config folders are to be stored /// Indicates where maps, saves, and server_config folders are to be stored
pub struct DataDir { pub struct DataDir {

View File

@ -6,10 +6,10 @@
pub mod alias_validator; pub mod alias_validator;
mod character_creator; mod character_creator;
mod data_dir;
pub mod chunk_generator; pub mod chunk_generator;
pub mod client; pub mod client;
pub mod cmd; pub mod cmd;
mod data_dir;
pub mod error; pub mod error;
pub mod events; pub mod events;
pub mod input; pub mod input;
@ -22,7 +22,13 @@ pub mod sys;
#[cfg(not(feature = "worldgen"))] mod test_world; #[cfg(not(feature = "worldgen"))] mod test_world;
// Reexports // Reexports
pub use crate::{error::Error, events::Event, input::Input, settings::ServerSettings, data_dir::{DataDir, DEFAULT_DATA_DIR_NAME}}; pub use crate::{
data_dir::{DataDir, DEFAULT_DATA_DIR_NAME},
error::Error,
events::Event,
input::Input,
settings::ServerSettings,
};
use crate::{ use crate::{
alias_validator::AliasValidator, alias_validator::AliasValidator,
@ -106,7 +112,7 @@ impl Server {
#[allow(clippy::needless_update)] // TODO: Pending review in #587 #[allow(clippy::needless_update)] // TODO: Pending review in #587
pub fn new(settings: ServerSettings, data_dir: DataDir) -> Result<Self, Error> { pub fn new(settings: ServerSettings, data_dir: DataDir) -> Result<Self, Error> {
info!("Server is data dir is: {}", data_dir.path.display()); info!("Server is data dir is: {}", data_dir.path.display());
// persistence_db_dir is relative to data_dir // persistence_db_dir is relative to data_dir
let persistence_db_dir = data_dir.path.join(&settings.persistence_db_dir); let persistence_db_dir = data_dir.path.join(&settings.persistence_db_dir);
@ -125,7 +131,9 @@ impl Server {
state.ecs_mut().insert(settings.clone()); state.ecs_mut().insert(settings.clone());
state.ecs_mut().insert(Whitelist::load(&data_dir.path)); state.ecs_mut().insert(Whitelist::load(&data_dir.path));
state.ecs_mut().insert(Banlist::load(&data_dir.path)); state.ecs_mut().insert(Banlist::load(&data_dir.path));
state.ecs_mut().insert(ServerDescription::load(&data_dir.path)); state
.ecs_mut()
.insert(ServerDescription::load(&data_dir.path));
state.ecs_mut().insert(data_dir); state.ecs_mut().insert(data_dir);
state.ecs_mut().insert(EventBus::<ServerEvent>::default()); state.ecs_mut().insert(EventBus::<ServerEvent>::default());
state state

View File

@ -18,11 +18,11 @@ use world::sim::FileOpts;
const DEFAULT_WORLD_SEED: u32 = 59686; const DEFAULT_WORLD_SEED: u32 = 59686;
//const CONFIG_DIR_ENV: &'static str = "VELOREN_SERVER_CONFIG"; //const CONFIG_DIR_ENV: &'static str = "VELOREN_SERVER_CONFIG";
const /*DEFAULT_*/CONFIG_DIR: &'static str = "server_config"; const /*DEFAULT_*/CONFIG_DIR: &str = "server_config";
const SETTINGS_FILENAME: &'static str = "settings.ron"; const SETTINGS_FILENAME: &str = "settings.ron";
const WHITELIST_FILENAME: &'static str = "whitelist.ron"; const WHITELIST_FILENAME: &str = "whitelist.ron";
const BANLIST_FILENAME: &'static str = "banlist.ron"; const BANLIST_FILENAME: &str = "banlist.ron";
const SERVER_DESCRIPTION_FILENAME: &'static str = "description.ron"; const SERVER_DESCRIPTION_FILENAME: &str = "description.ron";
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)] #[serde(default)]

View File

@ -209,7 +209,8 @@ impl Sys {
// Give the player a welcome message // Give the player a welcome message
if !server_description.is_empty() { if !server_description.is_empty() {
client.notify( client.notify(
ChatType::CommandInfo.server_msg(String::from(&**server_description)), ChatType::CommandInfo
.server_msg(String::from(&**server_description)),
); );
} }
@ -453,7 +454,7 @@ impl<'a> System<'a> for Sys {
( (
ReadExpect<'a, Whitelist>, ReadExpect<'a, Whitelist>,
ReadExpect<'a, Banlist>, ReadExpect<'a, Banlist>,
ReadExpect<'a, ServerDescription> ReadExpect<'a, ServerDescription>,
), ),
); );
@ -488,11 +489,7 @@ impl<'a> System<'a> for Sys {
mut controllers, mut controllers,
settings, settings,
alias_validator, alias_validator,
( (whitelist, banlist, server_description),
whitelist,
banlist,
server_description,
),
): Self::SystemData, ): Self::SystemData,
) { ) {
span!(_guard, "run", "message::Sys::run"); span!(_guard, "run", "message::Sys::run");