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

Make match loading forcefully advanced after a time

This commit is contained in:
NG (Graham)
2026-01-25 18:17:34 -05:00
parent a5ebe4284b
commit a346299de8
17 changed files with 391 additions and 52 deletions

View File

@@ -619,7 +619,8 @@ fn default_multiplayer() -> super::MultiplayerConfig {
super::MultiplayerConfig {
players_per_game: 2,
enabled: true,
autostart_after_s: 180,
autostart_after_s: super::multiplayer::default_match_autostart_after_s(),
continue_loading_after_s: super::multiplayer::default_continue_loading_after_s(),
network: super::multiplayer::default_net_conf(),
fakes: super::multiplayer::default_fake_users(),
filler: super::multiplayer::default_filler_users(),

View File

@@ -401,12 +401,20 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
self.battle.multiplayer.players_per_game
}
fn is_multiplayer_enabled(&self) -> bool {
/*fn is_multiplayer_enabled(&self) -> bool {
self.battle.multiplayer.enabled
}
fn multiplayer_autostart_after(&self) -> std::time::Duration {
std::time::Duration::from_secs(self.battle.multiplayer.autostart_after_s)
}*/
fn multiplayer_settings(&self) -> super::MultiplayerSettings {
super::MultiplayerSettings {
is_enabled: self.battle.multiplayer.enabled,
lobby_autostart_after: self.battle.multiplayer.autostart_after_s.map(std::time::Duration::from_secs),
loading_autostart_after: self.battle.multiplayer.continue_loading_after_s.map(std::time::Duration::from_secs),
}
}
fn network_config(&self) -> crate::persist::NetworkConf {

View File

@@ -2,7 +2,7 @@ mod cubes_json;
pub use cubes_json::CubeConfig;
mod traits;
pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain, PromoCode};
pub use traits::{ConfigProvider, DevMessageProvider, ServerConfig, GarageUpgrades, GarageUpgradeIncrement, ChatSystemConfig, GameEventSequence, GameEvents, GameRotationStrategy, GameEvent, GameMap, GameVisibility, GameType, SingleplayerConfig, VehicleInfo, VehicleDescriptor, QueueChangeMode, Point, Sphere, MapConfig, LinksConfig, FakePlayer, ClientEmulator, EnergyConfig, BattleArenaResolver, PitSettings, PitWinCondition, TeamDeathMatchSettings, ShopEntriesResolver, ShopAction, ShopGain, PromoCode, MultiplayerSettings};
mod validation;
pub use validation::{SelfValidator, ValidationInfo, ValidationMessage};

View File

@@ -27,8 +27,7 @@ pub trait ConfigProvider<C: Clone> {
fn gamemodes(&self) -> crate::data::game_mode::GameModeConfigs; // FIXME
fn singleplayer_details(&self) -> SingleplayerConfig;
fn players_per_game(&self) -> usize;
fn is_multiplayer_enabled(&self) -> bool;
fn multiplayer_autostart_after(&self) -> std::time::Duration;
fn multiplayer_settings(&self) -> MultiplayerSettings;
// FIXME don't use serializable types in traits
fn network_config(&self) -> crate::persist::NetworkConf;
fn maps(&self) -> std::collections::HashMap<GameMap, MapConfig>;
@@ -502,3 +501,10 @@ pub struct PromoCode {
pub value: f32,
pub transaction: ShopAction,
}
#[derive(Debug)]
pub struct MultiplayerSettings {
pub is_enabled: bool,
pub lobby_autostart_after: Option<std::time::Duration>,
pub loading_autostart_after: Option<std::time::Duration>,
}

View File

@@ -4,7 +4,10 @@ use serde::{Serialize, Deserialize};
pub struct MultiplayerConfig {
pub players_per_game: usize,
pub enabled: bool,
pub autostart_after_s: u64,
#[serde(default = "default_match_autostart_after_s")]
pub autostart_after_s: Option<u64>,
#[serde(default = "default_continue_loading_after_s")]
pub continue_loading_after_s: Option<u64>,
#[serde(default = "default_net_conf")]
pub network: NetworkConf,
#[serde(default = "default_fake_users")]
@@ -73,6 +76,14 @@ pub struct NetworkConf {
pub max_bulk_resend: u8,
}
pub(super) fn default_match_autostart_after_s() -> Option<u64> {
Some(180)
}
pub(super) fn default_continue_loading_after_s() -> Option<u64> {
Some(30)
}
pub(super) fn default_net_conf() -> NetworkConf {
NetworkConf {
network_channel_ty: "3113".to_owned(),