mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Add config flag to disallow parties joining the lobby
This commit is contained in:
@@ -319,6 +319,7 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
auto_signup: self.settings.server.auto_signup,
|
||||
allow_signup: self.settings.server.allow_signup,
|
||||
queue_mode: super::QueueChangeMode::from_persist(self.settings.server.queue_mode.clone()),
|
||||
allow_parties: self.settings.server.allow_parties,
|
||||
domain: self.settings.server.domain.to_owned(),
|
||||
cdn_url: self.settings.server.cdn_url.trim_end_matches('/').to_owned(),
|
||||
auth_url: self.settings.server.auth_url.trim_end_matches('/').to_owned(),
|
||||
|
||||
@@ -97,6 +97,7 @@ pub struct ServerConfig {
|
||||
pub auto_signup: bool,
|
||||
pub allow_signup: bool,
|
||||
pub queue_mode: QueueChangeMode,
|
||||
pub allow_parties: bool,
|
||||
pub domain: String,
|
||||
pub cdn_url: String,
|
||||
pub auth_url: String,
|
||||
|
||||
@@ -99,6 +99,8 @@ pub struct ServerSettings {
|
||||
pub allow_signup: bool,
|
||||
#[serde(default)]
|
||||
pub queue_mode: QueueMode,
|
||||
#[serde(default = "default_true")]
|
||||
pub allow_parties: bool,
|
||||
#[serde(default = "default_domain_root")]
|
||||
pub domain: String,
|
||||
#[serde(default = "default_cdn_root_url")]
|
||||
@@ -151,6 +153,7 @@ fn default_server_conf() -> ServerSettings {
|
||||
auto_signup: false,
|
||||
allow_signup: true,
|
||||
queue_mode: QueueMode::Notify,
|
||||
allow_parties: true,
|
||||
domain: default_domain_root(),
|
||||
cdn_url: default_cdn_root_url(),
|
||||
auth_url: default_auth_root_url(),
|
||||
|
||||
@@ -117,6 +117,7 @@ pub struct QueueHandler {
|
||||
custom_game_for_user: std::sync::Arc<tokio::sync::RwLock<HashMap<String, String>>>,
|
||||
users_per_game: usize,
|
||||
is_enabled: bool,
|
||||
is_parties_enabled: bool,
|
||||
hostname: String,
|
||||
hostport: u16,
|
||||
network_conf: crate::data::network::NetworkConfigData,
|
||||
@@ -140,19 +141,21 @@ impl QueueHandler {
|
||||
) -> Self {
|
||||
let (domain, port_str) = game_host.split_once(':').expect("Invalid redirect address (must be domain:port)");
|
||||
let mp_settings = oj_rc_core::ConfigProvider::<()>::multiplayer_settings(conf);
|
||||
let server_conf = <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::server_config(conf);
|
||||
Self {
|
||||
users_in_queue: std::sync::Arc::new(tokio::sync::Mutex::new(HashMap::new())),
|
||||
users_in_custom_games_queue: std::sync::Arc::new(tokio::sync::Mutex::new(HashMap::new())),
|
||||
custom_game_for_user: std::sync::Arc::new(tokio::sync::RwLock::new(HashMap::new())),
|
||||
users_per_game: oj_rc_core::ConfigProvider::<()>::players_per_game(conf),
|
||||
is_enabled: mp_settings.is_enabled,
|
||||
is_parties_enabled: server_conf.allow_parties,
|
||||
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)),
|
||||
factory,
|
||||
cpu_counter,
|
||||
weapon_guesser,
|
||||
change_strategy: GamemodeChangeStrategy::from_core(<oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::server_config(conf).queue_mode),
|
||||
change_strategy: GamemodeChangeStrategy::from_core(server_conf.queue_mode),
|
||||
autostart_after: mp_settings.lobby_autostart_after,
|
||||
autostart_task_started: std::sync::atomic::AtomicBool::new(false),
|
||||
team_choosers: std::sync::Arc::new(team_choosers),
|
||||
@@ -623,6 +626,15 @@ impl QueueHandler {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if let Some(platoon_info) = &platoon {
|
||||
if platoon_info.total != 1 && !self.is_parties_enabled {
|
||||
event_emitter.emit(crate::events::enqueue_error::QueueJoinError {
|
||||
code: oj_rc_core::data::error_codes::LobbyReasonCode::PartyNotAllowed as i16,
|
||||
text: "Platoons are not enabled".to_owned(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self.ensure_autostart_task_running();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user