diff --git a/CHANGELOG.md b/CHANGELOG.md index dcaeaea728..4db936c888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 sword - 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. ### Removed diff --git a/common/src/sys/projectile.rs b/common/src/sys/projectile.rs index ba7ece43d1..ffa55c286d 100644 --- a/common/src/sys/projectile.rs +++ b/common/src/sys/projectile.rs @@ -1,6 +1,6 @@ use crate::{ comp::{ - projectile, Damage, DamageSource, Energy, EnergySource, HealthChange, HealthSource, Group, + projectile, Damage, DamageSource, Energy, EnergySource, Group, HealthChange, HealthSource, Loadout, Ori, PhysicsState, Pos, Projectile, Vel, }, event::{EventBus, LocalEvent, ServerEvent}, @@ -82,7 +82,7 @@ impl<'a> System<'a> for Sys { // if there is at least one touching entity .and_then(|uid| uid_allocator.retrieve_entity_internal(uid.into())) .and_then(|e| groups.get(e)) - .map_or(false, |owner_group| + .map_or(false, |owner_group| Some(owner_group) == uid_allocator .retrieve_entity_internal(other.into()) .and_then(|e| groups.get(e)) diff --git a/common/src/util/userdata_dir.rs b/common/src/util/userdata_dir.rs index 24b7b304e4..81a9ae90ca 100644 --- a/common/src/util/userdata_dir.rs +++ b/common/src/util/userdata_dir.rs @@ -1,9 +1,9 @@ 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 -// finding assets +// TODO: consider expanding this to a general install strategy variable that is +// also used for finding assets /// # `VELOREN_USERDATA_STRATEGY` environment variable /// Read during compilation /// 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 /// 1. The VELOREN_USERDATA environment variable /// 2. The VELOREN_USERDATA_STRATEGY environment variable -/// 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata depending on if a -/// workspace if being used +/// 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata +/// depending on if a workspace if being used pub fn userdata_dir(workspace: bool, strategy: Option<&str>, manifest_dir: &str) -> PathBuf { // 1. The VELOREN_USERDATA environment variable 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? _ => None, - }) // 3. The CARGO_MANIFEST_DIR/userdata or CARGO_MANIFEST_DIR/../userdata depending on if a // workspace if being used - .unwrap_or_else(|| { + .unwrap_or_else(|| { let mut path = PathBuf::from(manifest_dir); if workspace { path.pop(); @@ -58,7 +57,8 @@ macro_rules! userdata_dir_workspace { () => { $crate::util::userdata_dir::userdata_dir( 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( false, - option_env!("VELOREN_USERDATA_STRATEGY"), env!("CARGO_MANIFEST_DIR") + option_env!("VELOREN_USERDATA_STRATEGY"), + env!("CARGO_MANIFEST_DIR"), ) }; -} - - +} diff --git a/server-cli/src/tui_runner.rs b/server-cli/src/tui_runner.rs index 1c17788ecd..b3bc502583 100644 --- a/server-cli/src/tui_runner.rs +++ b/server-cli/src/tui_runner.rs @@ -122,7 +122,7 @@ impl Tui { pub fn run(basic: bool) -> Self { let (mut msg_s, msg_r) = mpsc::channel(); let running = Arc::new(AtomicBool::new(true)); - let running2 = running.clone(); + let running2 = Arc::clone(&running); let background = if basic { std::thread::spawn(move || { diff --git a/server/src/data_dir.rs b/server/src/data_dir.rs index c934638d7c..3c134ca870 100644 --- a/server/src/data_dir.rs +++ b/server/src/data_dir.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; /// Used so that different server frontends can share the same server saves, /// 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 pub struct DataDir { diff --git a/server/src/lib.rs b/server/src/lib.rs index 21d16408cc..9bb8ad3acd 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -6,10 +6,10 @@ pub mod alias_validator; mod character_creator; -mod data_dir; pub mod chunk_generator; pub mod client; pub mod cmd; +mod data_dir; pub mod error; pub mod events; pub mod input; @@ -22,7 +22,13 @@ pub mod sys; #[cfg(not(feature = "worldgen"))] mod test_world; // 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::{ alias_validator::AliasValidator, @@ -106,7 +112,7 @@ impl Server { #[allow(clippy::needless_update)] // TODO: Pending review in #587 pub fn new(settings: ServerSettings, data_dir: DataDir) -> Result { info!("Server is data dir is: {}", data_dir.path.display()); - + // persistence_db_dir is relative to data_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(Whitelist::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(EventBus::::default()); state diff --git a/server/src/settings.rs b/server/src/settings.rs index c03bfbd72c..1fcf7cc5b2 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -18,11 +18,11 @@ use world::sim::FileOpts; const DEFAULT_WORLD_SEED: u32 = 59686; //const CONFIG_DIR_ENV: &'static str = "VELOREN_SERVER_CONFIG"; -const /*DEFAULT_*/CONFIG_DIR: &'static str = "server_config"; -const SETTINGS_FILENAME: &'static str = "settings.ron"; -const WHITELIST_FILENAME: &'static str = "whitelist.ron"; -const BANLIST_FILENAME: &'static str = "banlist.ron"; -const SERVER_DESCRIPTION_FILENAME: &'static str = "description.ron"; +const /*DEFAULT_*/CONFIG_DIR: &str = "server_config"; +const SETTINGS_FILENAME: &str = "settings.ron"; +const WHITELIST_FILENAME: &str = "whitelist.ron"; +const BANLIST_FILENAME: &str = "banlist.ron"; +const SERVER_DESCRIPTION_FILENAME: &str = "description.ron"; #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(default)] diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index 557f8b603b..f40a18cfa3 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -209,7 +209,8 @@ impl Sys { // Give the player a welcome message if !server_description.is_empty() { 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, Banlist>, - ReadExpect<'a, ServerDescription> + ReadExpect<'a, ServerDescription>, ), ); @@ -488,11 +489,7 @@ impl<'a> System<'a> for Sys { mut controllers, settings, alias_validator, - ( - whitelist, - banlist, - server_description, - ), + (whitelist, banlist, server_description), ): Self::SystemData, ) { span!(_guard, "run", "message::Sys::run");