1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Fix CPU number calculation and display in lots of places

This commit is contained in:
NG (Graham)
2025-07-20 21:24:43 -04:00
parent 37cbc8d85f
commit 4e9bcc36d6
11 changed files with 139 additions and 43 deletions

View File

@@ -21,10 +21,11 @@ pub struct QueueHandler {
hostname: String,
hostport: u16,
network_conf: crate::data::network::NetworkConfigData,
cpu_counter: std::sync::Arc<oj_rc_core::cubes::CpuListParser>,
}
impl QueueHandler {
pub fn new(conf: &oj_rc_core::ConfigImpl, game_host: &str) -> Self {
pub fn new(conf: &oj_rc_core::ConfigImpl, game_host: &str, cpu_counter: std::sync::Arc<oj_rc_core::cubes::CpuListParser>,) -> Self {
let (domain, port_str) = game_host.split_once(':').expect("Invalid redirect address (must be domain:port)");
Self {
users_in_queue: tokio::sync::Mutex::new(HashMap::new()),
@@ -33,6 +34,7 @@ impl QueueHandler {
hostname: domain.to_owned(),
hostport: port_str.parse().expect("Invalid redirect port"),
network_conf: crate::data::network::NetworkConfigData::from_conf(oj_rc_core::ConfigProvider::<()>::network_config(conf)),
cpu_counter,
}
}
@@ -109,7 +111,7 @@ impl QueueHandler {
let key = QueueKey {
map, mode, visibility, auto_heal,
};
match user.player_data().await {
match user.player_data(&self.cpu_counter).await {
Ok(player_data) => {
let mut new_player = QueueUser {
emitter: event_emitter,

View File

@@ -30,8 +30,8 @@ async fn main() -> std::io::Result<()> {
let config = oj_rc_core::persist::config::ConfigImpl::load(&args.assets).expect("Bad config data");
let users = std::sync::Arc::new(oj_rc_core::persist::user::UserImpl::load(&args.data, &config).await.expect("Bad user data"));
let queue = std::sync::Arc::new(QueueHandler::new(&config, &args.redirect));
let parsers = oj_rc_core::cubes::CubeParsers::new(&config);
let queue = std::sync::Arc::new(QueueHandler::new(&config, &args.redirect, parsers.cpu_counter()));
let init_ctx = InitConfig {
config,