From bbb024224d649c5f9f457dfaa9c222676bad6a72 Mon Sep 17 00:00:00 2001 From: Songtronix Date: Mon, 1 Jul 2019 11:37:17 +0200 Subject: [PATCH] add configureable server info --- .gitignore | 1 + server-cli/src/main.rs | 2 +- server/src/lib.rs | 7 +++---- server/src/settings.rs | 11 +++++++---- voxygen/src/singleplayer.rs | 3 ++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 7851bea8dc..f926d8500e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,6 @@ # Veloren *.rar *.log +*.ron run.sh screenshots diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 41f4949812..010a0aefe7 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -39,6 +39,6 @@ fn main() { // Wait for the next tick. clock.tick(Duration::from_millis(1000 / TPS)); } - + //settings.save_to_file().expect("failed to save the settings!"); } diff --git a/server/src/lib.rs b/server/src/lib.rs index 3ba39b0c29..7872c887d0 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -100,12 +100,11 @@ impl Server { chunk_rx, pending_chunks: HashSet::new(), - server_settings: settings, server_info: ServerInfo { - // TODO: get from settings - name: "Server name".to_owned(), - description: "This is the best Veloren server.".to_owned(), + name: settings.server_name.clone(), + description: settings.server_description.clone(), }, + server_settings: settings, }; Ok(this) diff --git a/server/src/settings.rs b/server/src/settings.rs index 41f32902b2..7dd157611f 100644 --- a/server/src/settings.rs +++ b/server/src/settings.rs @@ -1,5 +1,5 @@ use serde_derive::{Deserialize, Serialize}; -use std::{fs, io::prelude::*, path::PathBuf, net::SocketAddr}; +use std::{fs, io::prelude::*, net::SocketAddr, path::PathBuf}; /// `ControlSettings` contains keybindings. #[derive(Clone, Debug, Serialize, Deserialize)] @@ -9,7 +9,8 @@ pub struct ServerSettings { //pub max_players: u64, pub world_seed: u32, //pub pvp_enabled: bool, - //pub serverinfo: whatever + pub server_name: String, + pub server_description: String, //pub login_server: whatever } @@ -18,9 +19,11 @@ impl Default for ServerSettings { Self { address: SocketAddr::from(([0; 4], 59003)), world_seed: 1337, + server_name: "Server name".to_owned(), + server_description: "This is the best Veloren server.".to_owned(), } } -} +} impl ServerSettings { pub fn load() -> Self { @@ -49,4 +52,4 @@ impl ServerSettings { fn get_settings_path() -> PathBuf { PathBuf::from(r"settings.ron") } -} \ No newline at end of file +} diff --git a/voxygen/src/singleplayer.rs b/voxygen/src/singleplayer.rs index 18975ad6d9..0b294b02f6 100644 --- a/voxygen/src/singleplayer.rs +++ b/voxygen/src/singleplayer.rs @@ -36,7 +36,8 @@ impl Singleplayer { )); // Create server - let server = Server::bind(sock.clone(), ServerSettings::default()).expect("Failed to create server instance!"); + let server = Server::bind(sock.clone(), ServerSettings::default()) + .expect("Failed to create server instance!"); let server = match client { Some(client) => server.with_thread_pool(client.thread_pool().clone()),