-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ timeout_ms = 10000 | |
|
||
[world] | ||
seed = 0xfeb_face_dead_cafe | ||
preheat_radius = 8 | ||
|
||
[query] | ||
name = "Kubi Server" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
use shipyard::{AllStoragesView, Unique}; | ||
use serde::{Serialize, Deserialize}; | ||
use std::{fs, net::SocketAddr}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ConfigTableServer { | ||
pub address: SocketAddr, | ||
pub max_clients: usize, | ||
pub timeout_ms: u64, | ||
pub password: Option<String>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ConfigTableWorld { | ||
pub seed: u64, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ConfigTableQuery { | ||
pub name: Option<String> | ||
} | ||
|
||
#[derive(Unique, Serialize, Deserialize)] | ||
pub struct ConfigTable { | ||
pub server: ConfigTableServer, | ||
pub world: ConfigTableWorld, | ||
pub query: ConfigTableQuery, | ||
} | ||
|
||
pub fn read_config( | ||
storages: AllStoragesView, | ||
) { | ||
log::info!("Reading config..."); | ||
let config_str = fs::read_to_string("Server.toml").expect("No config file found"); | ||
let config: ConfigTable = toml::from_str(&config_str).expect("Invalid configuration file"); | ||
storages.add_unique(config); | ||
} | ||
use shipyard::{AllStoragesView, Unique}; | ||
use serde::{Serialize, Deserialize}; | ||
use std::{fs, net::SocketAddr}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ConfigTableServer { | ||
pub address: SocketAddr, | ||
pub max_clients: usize, | ||
pub timeout_ms: u64, | ||
pub password: Option<String>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ConfigTableWorld { | ||
pub seed: u64, | ||
pub preheat_radius: u32, | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct ConfigTableQuery { | ||
pub name: Option<String> | ||
} | ||
|
||
#[derive(Unique, Serialize, Deserialize)] | ||
pub struct ConfigTable { | ||
pub server: ConfigTableServer, | ||
pub world: ConfigTableWorld, | ||
pub query: ConfigTableQuery, | ||
} | ||
|
||
pub fn read_config( | ||
storages: AllStoragesView, | ||
) { | ||
log::info!("Reading config..."); | ||
let config_str = fs::read_to_string("Server.toml").expect("No config file found"); | ||
let config: ConfigTable = toml::from_str(&config_str).expect("Invalid configuration file"); | ||
storages.add_unique(config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters