mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Pass more network config info to multiplayer server impl, address #82
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2108,6 +2108,7 @@ dependencies = [
|
|||||||
"async-recursion",
|
"async-recursion",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"chrono",
|
||||||
"literustlib",
|
"literustlib",
|
||||||
"log",
|
"log",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ impl super::config::SelfValidator for MultiplayerConfig {
|
|||||||
message: "Game match may have broken vehicle flipping functionality due to more than 1 ClientAI per player".to_owned(),
|
message: "Game match may have broken vehicle flipping functionality due to more than 1 ClientAI per player".to_owned(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
is_ok &= self.network.validate_in(info, &(), "network");
|
||||||
// TODO
|
// TODO
|
||||||
is_ok
|
is_ok
|
||||||
}
|
}
|
||||||
@@ -76,6 +77,49 @@ pub struct NetworkConf {
|
|||||||
pub max_bulk_resend: u8,
|
pub max_bulk_resend: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl super::config::SelfValidator for NetworkConf {
|
||||||
|
type Context = ();
|
||||||
|
fn validate(&self, info: &mut super::config::ValidationInfo, _ctx: &Self::Context) -> bool {
|
||||||
|
let mut is_ok = true;
|
||||||
|
if self.max_delay < 0 {
|
||||||
|
info.error(super::config::ValidationMessage {
|
||||||
|
path: vec!["max_delay".to_owned()],
|
||||||
|
message: "Max delay cannot be negative (how do you live in the future!?)".to_owned(),
|
||||||
|
});
|
||||||
|
is_ok = false;
|
||||||
|
}
|
||||||
|
if self.resend_delay_base < 0.0 {
|
||||||
|
info.error(super::config::ValidationMessage {
|
||||||
|
path: vec!["resend_delay_base".to_owned()],
|
||||||
|
message: "Resend delay cannot be negative (how do you live in the future!?)".to_owned(),
|
||||||
|
});
|
||||||
|
is_ok = false;
|
||||||
|
}
|
||||||
|
if self.resend_delay_rtt_mult < 0.0 {
|
||||||
|
info.error(super::config::ValidationMessage {
|
||||||
|
path: vec!["resend_delay_rtt_mult".to_owned()],
|
||||||
|
message: "Resend delay multiplier cannot be negative (how do you live in the future!?)".to_owned(),
|
||||||
|
});
|
||||||
|
is_ok = false;
|
||||||
|
}
|
||||||
|
if self.network_peer_update_interval < 0 {
|
||||||
|
info.error(super::config::ValidationMessage {
|
||||||
|
path: vec!["network_peer_update_interval".to_owned()],
|
||||||
|
message: "Update interval cannot be negative (how do you live in the future!?)".to_owned(),
|
||||||
|
});
|
||||||
|
is_ok = false;
|
||||||
|
}
|
||||||
|
if self.max_delay_for_disconnect_ms < 0 {
|
||||||
|
info.error(super::config::ValidationMessage {
|
||||||
|
path: vec!["max_delay_for_disconnect_ms".to_owned()],
|
||||||
|
message: "Max delay cannot be negative (how do you live in the future!?)".to_owned(),
|
||||||
|
});
|
||||||
|
is_ok = false;
|
||||||
|
}
|
||||||
|
is_ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn default_match_autostart_after_s() -> Option<u64> {
|
pub(super) fn default_match_autostart_after_s() -> Option<u64> {
|
||||||
Some(180)
|
Some(180)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,11 +40,18 @@ async fn main() -> std::io::Result<()> {
|
|||||||
matches_chann,
|
matches_chann,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mtu = oj_rc_core::ConfigProvider::<()>::network_config(&init_ctx.config).max_packet_size;
|
let net_conf = oj_rc_core::ConfigProvider::<()>::network_config(&init_ctx.config);
|
||||||
let dos_protection = oj_rc_core::ConfigProvider::<()>::server_config(&init_ctx.config).dos_protect;
|
let dos_protection = oj_rc_core::ConfigProvider::<()>::server_config(&init_ctx.config).dos_protect;
|
||||||
let max_bulk_resend = oj_rc_core::ConfigProvider::<()>::network_config(&init_ctx.config).max_bulk_resend;
|
|
||||||
let event_handler = events::handler(&init_ctx).await;
|
let event_handler = events::handler(&init_ctx).await;
|
||||||
let server = literustlib_server::Server::new(event_handler, (args.ip, args.port), mtu, dos_protection, max_bulk_resend as usize).await.expect("Bad server");
|
let server_conf = literustlib_server::ServerConfig {
|
||||||
|
max_bulk_resends: net_conf.max_bulk_resend as usize,
|
||||||
|
resend_delay_base: net_conf.resend_delay_base,
|
||||||
|
resend_delay_rtt_mult: net_conf.resend_delay_rtt_mult,
|
||||||
|
timeout: std::time::Duration::from_millis(net_conf.max_delay_for_disconnect_ms as u64),
|
||||||
|
dos_protection,
|
||||||
|
mtu: net_conf.max_packet_size,
|
||||||
|
};
|
||||||
|
let server = literustlib_server::Server::new(event_handler, (args.ip, args.port), server_conf).await.expect("Bad server");
|
||||||
|
|
||||||
let start_time = chrono::Utc::now();
|
let start_time = chrono::Utc::now();
|
||||||
START_TIMESTAMP_S.store(start_time.timestamp(), std::sync::atomic::Ordering::Relaxed);
|
START_TIMESTAMP_S.store(start_time.timestamp(), std::sync::atomic::Ordering::Relaxed);
|
||||||
|
|||||||
Reference in New Issue
Block a user