mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add a ServerConstants to Client and Server structs and sync on register.
This commit is contained in:
parent
b649774316
commit
7e4ea483e0
@ -50,6 +50,7 @@ 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};
|
||||
@ -264,6 +265,8 @@ pub struct Client {
|
||||
|
||||
pending_chunks: HashMap<Vec2<i32>, Instant>,
|
||||
target_time_of_day: Option<TimeOfDay>,
|
||||
|
||||
connected_server_constants: ServerConstants
|
||||
}
|
||||
|
||||
/// Holds data related to the current players characters, as well as some
|
||||
@ -355,6 +358,7 @@ impl Client {
|
||||
component_recipe_book,
|
||||
material_stats,
|
||||
ability_map,
|
||||
server_constants,
|
||||
} = loop {
|
||||
tokio::select! {
|
||||
// Spawn in a blocking thread (leaving the network thread free). This is mostly
|
||||
@ -744,6 +748,8 @@ impl Client {
|
||||
|
||||
pending_chunks: HashMap::new(),
|
||||
target_time_of_day: None,
|
||||
|
||||
connected_server_constants: server_constants
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ use common::{
|
||||
uid::Uid,
|
||||
uuid::Uuid,
|
||||
weather::WeatherGrid,
|
||||
shared_server_config::ServerConstants,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -66,6 +67,7 @@ pub enum ServerInit {
|
||||
component_recipe_book: ComponentRecipeBook,
|
||||
material_stats: MaterialStatManifest,
|
||||
ability_map: comp::item::tool::AbilityMap,
|
||||
server_constants: ServerConstants
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
/// Per-server constant data (configs) that stays the same for the server's life.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct ServerConstants {
|
||||
day_cycle_coefficient: f64,
|
||||
pub day_cycle_coefficient: f64,
|
||||
}
|
@ -82,6 +82,7 @@ use common::{
|
||||
slowjob::SlowJobPool,
|
||||
terrain::{TerrainChunk, TerrainChunkSize},
|
||||
vol::RectRasterableVol,
|
||||
shared_server_config::ServerConstants,
|
||||
};
|
||||
use common_ecs::run_now;
|
||||
use common_net::{
|
||||
@ -205,6 +206,8 @@ pub struct Server {
|
||||
metrics_shutdown: Arc<Notify>,
|
||||
database_settings: Arc<RwLock<DatabaseSettings>>,
|
||||
disconnect_all_clients_requested: bool,
|
||||
|
||||
server_constants: ServerConstants,
|
||||
}
|
||||
|
||||
impl Server {
|
||||
@ -561,6 +564,10 @@ impl Server {
|
||||
#[cfg(not(feature = "worldgen"))]
|
||||
rtsim::init(&mut state);
|
||||
|
||||
let server_constants = ServerConstants {
|
||||
day_cycle_coefficient: 1400.0 / settings.day_length
|
||||
};
|
||||
|
||||
let this = Self {
|
||||
state,
|
||||
world,
|
||||
@ -571,6 +578,8 @@ impl Server {
|
||||
metrics_shutdown,
|
||||
database_settings,
|
||||
disconnect_all_clients_requested: false,
|
||||
|
||||
server_constants,
|
||||
};
|
||||
|
||||
debug!(?settings, "created veloren server with");
|
||||
|
@ -11,6 +11,7 @@ use common::{
|
||||
recipe::{default_component_recipe_book, default_recipe_book},
|
||||
resources::TimeOfDay,
|
||||
uid::{Uid, UidAllocator},
|
||||
shared_server_config::ServerConstants,
|
||||
};
|
||||
use common_base::prof_span;
|
||||
use common_ecs::{Job, Origin, Phase, System};
|
||||
@ -349,6 +350,9 @@ impl<'a> System<'a> for Sys {
|
||||
component_recipe_book: default_component_recipe_book().cloned(),
|
||||
material_stats: (*read_data.material_stats).clone(),
|
||||
ability_map: (*read_data.ability_map).clone(),
|
||||
server_constants: ServerConstants {
|
||||
day_cycle_coefficient: 1400.0 / read_data.settings.day_length
|
||||
},
|
||||
})?;
|
||||
debug!("Done initial sync with client.");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user