diff --git a/client/src/lib.rs b/client/src/lib.rs index 5f5e9bd93c..a69107cf2f 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1804,6 +1804,7 @@ impl Client { }, true, None, + &self.connected_server_constants ); // TODO: avoid emitting these in the first place let _ = self diff --git a/common/src/shared_server_config.rs b/common/src/shared_server_config.rs index 39ad2a4184..c5d6d03e69 100644 --- a/common/src/shared_server_config.rs +++ b/common/src/shared_server_config.rs @@ -4,4 +4,12 @@ use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ServerConstants { pub day_cycle_coefficient: f64, +} +impl Default for ServerConstants { + fn default() -> Self { + ServerConstants { + // == 30.0 via server settings (the default) + 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 7d44ad4323..538333edfc 100644 --- a/common/state/src/state.rs +++ b/common/state/src/state.rs @@ -22,6 +22,7 @@ use common::{ trade::Trades, vol::{ReadVol, WriteVol}, weather::{Weather, WeatherGrid}, + shared_server_config::ServerConstants, }; use common_base::span; use common_ecs::{PhysicsMetrics, SysMetrics}; @@ -39,9 +40,6 @@ use std::{sync::Arc, time::Instant}; use timer_queue::TimerQueue; use vek::*; -/// How much faster should an in-game day be compared to a real day? -// TODO: Don't hard-code this. -const DAY_CYCLE_FACTOR: f64 = 24.0 * 2.0; /// At what point should we stop speeding up physics to compensate for lag? If /// we speed physics up too fast, we'd skip important physics events like /// collisions. This constant determines the upper limit. If delta time exceeds @@ -597,6 +595,7 @@ impl State { add_systems: impl Fn(&mut DispatcherBuilder), update_terrain_and_regions: bool, mut metrics: Option<&mut StateTickMetrics>, + server_constants: &ServerConstants ) { span!(_guard, "tick", "State::tick"); @@ -610,8 +609,7 @@ impl State { } // Change the time accordingly. - self.ecs.write_resource::().0 += dt.as_secs_f64() * DAY_CYCLE_FACTOR; - self.ecs.write_resource::