diff --git a/client/src/lib.rs b/client/src/lib.rs index a69107cf2f..d03743629f 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -40,6 +40,7 @@ use common::{ outcome::Outcome, recipe::{ComponentRecipeBook, RecipeBook}, resources::{GameMode, PlayerEntity, Time, TimeOfDay}, + shared_server_config::ServerConstants, spiral::Spiral2d, terrain::{ block::Block, map::MapConfig, neighbors, site::DungeonKindMeta, BiomeKind, @@ -50,7 +51,6 @@ use common::{ uid::{Uid, UidAllocator}, vol::RectVolSize, weather::{Weather, WeatherGrid}, - shared_server_config::ServerConstants, }; #[cfg(feature = "tracy")] use common_base::plot; use common_base::{prof_span, span}; @@ -266,7 +266,7 @@ pub struct Client { pending_chunks: HashMap, Instant>, target_time_of_day: Option, - connected_server_constants: ServerConstants + connected_server_constants: ServerConstants, } /// Holds data related to the current players characters, as well as some @@ -749,7 +749,7 @@ impl Client { pending_chunks: HashMap::new(), target_time_of_day: None, - connected_server_constants: server_constants + connected_server_constants: server_constants, }) } @@ -1804,7 +1804,7 @@ impl Client { }, true, None, - &self.connected_server_constants + &self.connected_server_constants, ); // TODO: avoid emitting these in the first place let _ = self diff --git a/common/net/src/msg/server.rs b/common/net/src/msg/server.rs index 79e6cb3b2f..db6c3655b5 100644 --- a/common/net/src/msg/server.rs +++ b/common/net/src/msg/server.rs @@ -12,12 +12,12 @@ use common::{ outcome::Outcome, recipe::{ComponentRecipeBook, RecipeBook}, resources::{Time, TimeOfDay}, + shared_server_config::ServerConstants, terrain::{Block, TerrainChunk, TerrainChunkMeta, TerrainChunkSize}, trade::{PendingTrade, SitePrices, TradeId, TradeResult}, uid::Uid, uuid::Uuid, weather::WeatherGrid, - shared_server_config::ServerConstants, }; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; @@ -67,7 +67,7 @@ pub enum ServerInit { component_recipe_book: ComponentRecipeBook, material_stats: MaterialStatManifest, ability_map: comp::item::tool::AbilityMap, - server_constants: ServerConstants + server_constants: ServerConstants, }, } diff --git a/common/src/lib.rs b/common/src/lib.rs index e41f2dc491..a2f7dc1c10 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -31,8 +31,8 @@ pub mod combat; pub mod comp; pub mod consts; pub mod resources; -pub mod uid; pub mod shared_server_config; +pub mod uid; // NOTE: Comment out macro to get rustfmt to re-order these as needed. cfg_if! { if #[cfg(not(target_arch = "wasm32"))] { diff --git a/common/src/shared_server_config.rs b/common/src/shared_server_config.rs index c5d6d03e69..8080d66cc4 100644 --- a/common/src/shared_server_config.rs +++ b/common/src/shared_server_config.rs @@ -1,6 +1,7 @@ -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; -/// Per-server constant data (configs) that stays the same for the server's life. +/// Per-server constant data (configs) that stays the same for the server's +/// life. #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ServerConstants { pub day_cycle_coefficient: f64, @@ -12,4 +13,4 @@ impl Default for ServerConstants { day_cycle_coefficient: 24.0 * 2.0, } } -} \ No newline at end of file +} diff --git a/common/state/src/state.rs b/common/state/src/state.rs index 538333edfc..04cc4c9039 100644 --- a/common/state/src/state.rs +++ b/common/state/src/state.rs @@ -16,13 +16,13 @@ use common::{ DeltaTime, EntitiesDiedLastTick, GameMode, PlayerEntity, PlayerPhysicsSettings, Time, TimeOfDay, }, + shared_server_config::ServerConstants, slowjob::SlowJobPool, terrain::{Block, MapSizeLg, TerrainChunk, TerrainGrid}, time::DayPeriod, trade::Trades, vol::{ReadVol, WriteVol}, weather::{Weather, WeatherGrid}, - shared_server_config::ServerConstants, }; use common_base::span; use common_ecs::{PhysicsMetrics, SysMetrics}; @@ -595,7 +595,7 @@ impl State { add_systems: impl Fn(&mut DispatcherBuilder), update_terrain_and_regions: bool, mut metrics: Option<&mut StateTickMetrics>, - server_constants: &ServerConstants + server_constants: &ServerConstants, ) { span!(_guard, "tick", "State::tick"); @@ -609,7 +609,8 @@ impl State { } // Change the time accordingly. - self.ecs.write_resource::().0 += dt.as_secs_f64() * server_constants.day_cycle_coefficient; + self.ecs.write_resource::().0 += + dt.as_secs_f64() * server_constants.day_cycle_coefficient; // Update delta time. // Beyond a delta time of MAX_DELTA_TIME, start lagging to avoid skipping diff --git a/common/systems/tests/character_state.rs b/common/systems/tests/character_state.rs index 08f57336dc..c19651f1d9 100644 --- a/common/systems/tests/character_state.rs +++ b/common/systems/tests/character_state.rs @@ -6,10 +6,11 @@ mod tests { Controller, Energy, Ori, PhysicsState, Poise, Pos, Skill, Stats, Vel, }, resources::{DeltaTime, GameMode, Time}, + shared_server_config::ServerConstants, terrain::{MapSizeLg, TerrainChunk}, uid::Uid, util::Dir, - SkillSetBuilder, shared_server_config::ServerConstants, + SkillSetBuilder, }; use common_ecs::dispatch; use common_state::State; diff --git a/common/systems/tests/phys/basic.rs b/common/systems/tests/phys/basic.rs index 1ade91df36..e7eabcbfd0 100644 --- a/common/systems/tests/phys/basic.rs +++ b/common/systems/tests/phys/basic.rs @@ -1,10 +1,6 @@ use crate::utils; use approx::assert_relative_eq; -use common::{ - comp::Controller, - resources::Time, - shared_server_config::ServerConstants, -}; +use common::{comp::Controller, resources::Time, shared_server_config::ServerConstants}; use specs::WorldExt; use std::error::Error; use utils::{DT, DT_F64, EPSILON}; diff --git a/common/systems/tests/phys/utils.rs b/common/systems/tests/phys/utils.rs index 6fe7eaa838..f292e34841 100644 --- a/common/systems/tests/phys/utils.rs +++ b/common/systems/tests/phys/utils.rs @@ -7,11 +7,11 @@ use common::{ Vel, }, resources::{DeltaTime, GameMode, Time}, + shared_server_config::ServerConstants, skillset_builder::SkillSetBuilder, terrain::{ Block, BlockKind, MapSizeLg, SpriteKind, TerrainChunk, TerrainChunkMeta, TerrainGrid, }, - shared_server_config::ServerConstants, }; use common_ecs::{dispatch, System}; use common_net::sync::WorldSyncExt; diff --git a/server/src/lib.rs b/server/src/lib.rs index 4f5e3690f7..aa4d931a36 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -79,10 +79,10 @@ use common::{ event::{EventBus, ServerEvent}, resources::{BattleMode, GameMode, Time, TimeOfDay}, rtsim::RtSimEntity, + shared_server_config::ServerConstants, slowjob::SlowJobPool, terrain::{TerrainChunk, TerrainChunkSize}, vol::RectRasterableVol, - shared_server_config::ServerConstants, }; use common_ecs::run_now; use common_net::{ @@ -565,7 +565,7 @@ impl Server { rtsim::init(&mut state); let server_constants = ServerConstants { - day_cycle_coefficient: 1400.0 / settings.day_length + day_cycle_coefficient: 1400.0 / settings.day_length, }; let this = Self { @@ -710,7 +710,7 @@ impl Server { }, false, Some(&mut state_tick_metrics), - &self.server_constants + &self.server_constants, ); let before_handle_events = Instant::now(); diff --git a/server/src/sys/msg/register.rs b/server/src/sys/msg/register.rs index bd73f0e6fd..bd6daf3654 100644 --- a/server/src/sys/msg/register.rs +++ b/server/src/sys/msg/register.rs @@ -10,8 +10,8 @@ use common::{ event::{EventBus, ServerEvent}, recipe::{default_component_recipe_book, default_recipe_book}, resources::TimeOfDay, - uid::{Uid, UidAllocator}, shared_server_config::ServerConstants, + uid::{Uid, UidAllocator}, }; use common_base::prof_span; use common_ecs::{Job, Origin, Phase, System};