feat: add saving and reading server setting from config file

This commit is contained in:
2026-08-18 21:55:30 +02:00
parent aebf4f626f
commit 894c4c1cfb
7 changed files with 204 additions and 14 deletions

View File

@@ -23,15 +23,9 @@ use crate::{
},
network_identity::NetworkServerIdentity,
},
settings::{general_settings::SettingsLike, server_settings::ServerSettings},
};
// TODO! More settings!
pub struct ServerSettings {
pub addr: SocketAddr,
pub max_connections: usize,
pub allow_spectators: bool,
}
#[derive(PartialEq)]
enum ServerStage {
Lobby,
@@ -71,11 +65,7 @@ pub struct Server {
impl Server {
pub async fn new() -> Server {
// TODO! Should be read from a file
let settings = ServerSettings {
addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 6767),
max_connections: 2,
allow_spectators: false,
};
let settings = ServerSettings::new();
let (sender, reciever) =
tokio::sync::mpsc::channel::<(SocketAddr, Message<ClientMessage>)>(1024); // random