From 311c78a588302c8c692b2abc54afebb15e2646fe Mon Sep 17 00:00:00 2001 From: Denis Drakhnia Date: Mon, 15 Apr 2024 09:50:02 +0300 Subject: [PATCH] master: fix invalid default config for empty client section --- master/src/config.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/master/src/config.rs b/master/src/config.rs index cf23f65..a6b75cf 100644 --- a/master/src/config.rs +++ b/master/src/config.rs @@ -125,12 +125,12 @@ impl Default for TimeoutConfig { #[derive(Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct ClientConfig { - #[serde(default)] + #[serde(default = "default_client_version")] #[serde(deserialize_with = "deserialize_version")] pub version: Version, - #[serde(default)] + #[serde(default = "default_client_update_map")] pub update_map: Box, - #[serde(default)] + #[serde(default = "default_client_update_title")] pub update_title: Box, #[serde(default)] pub update_addr: Option>, @@ -139,9 +139,9 @@ pub struct ClientConfig { impl Default for ClientConfig { fn default() -> Self { Self { - version: Version::new(0, 19), - update_map: String::from("Update please").into_boxed_str(), - update_title: String::from("https://github.com/FWGS/xash3d-fwgs").into_boxed_str(), + version: default_client_version(), + update_map: default_client_update_map(), + update_title: default_client_update_title(), update_addr: None, } } @@ -200,6 +200,18 @@ fn default_server_ip() -> IpAddr { DEFAULT_MASTER_SERVER_IP } +fn default_client_version() -> Version { + Version::new(0, 19) +} + +fn default_client_update_map() -> Box { + Box::from("Update please") +} + +fn default_client_update_title() -> Box { + Box::from("https://github.com/FWGS/xash3d-fwgs") +} + fn default_hash_key() -> Box { Box::from(admin::HASH_KEY) }