mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Make minimum game client version configurable
This commit is contained in:
@@ -296,6 +296,7 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
|
||||
cdn_url: self.settings.server.cdn_url.trim_end_matches('/').to_owned(),
|
||||
auth_url: self.settings.server.auth_url.trim_end_matches('/').to_owned(),
|
||||
intercom_url: self.settings.server.intercom_url.trim_end_matches('/').to_owned(),
|
||||
minimum_version: self.settings.server.min_version as i32,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ pub struct ServerConfig {
|
||||
pub cdn_url: String,
|
||||
pub auth_url: String,
|
||||
pub intercom_url: String,
|
||||
pub minimum_version: i32,
|
||||
}
|
||||
|
||||
pub enum QueueChangeMode {
|
||||
|
||||
@@ -96,6 +96,8 @@ pub struct ServerSettings {
|
||||
pub support_url: String,
|
||||
#[serde(default = "default_wiki_url")]
|
||||
pub wiki_url: String,
|
||||
#[serde(default = "default_game_version")]
|
||||
pub min_version: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
|
||||
@@ -121,6 +123,7 @@ fn default_server_conf() -> ServerSettings {
|
||||
feedback_url: default_feedback_url(),
|
||||
support_url: default_support_url(),
|
||||
wiki_url: default_wiki_url(),
|
||||
min_version: default_game_version(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,3 +150,7 @@ fn default_support_url() -> String {
|
||||
fn default_wiki_url() -> String {
|
||||
"https://git.ngram.ca/OpenJam/servers/wiki".to_owned()
|
||||
}
|
||||
|
||||
fn default_game_version() -> u32 {
|
||||
2855
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
|
||||
.modify(oj_rc_core::polariton::RcOpModifier)
|
||||
.add(eac::EacChallengeIgnorer)
|
||||
.add(more_auth::MoreLobbyAuth)
|
||||
.add(versioner::VersionTeller)
|
||||
.add(versioner::version_teller(&init_ctx.cubes))
|
||||
.add(maintenancer::MaintenanceModeTeller)
|
||||
.add(game_quality::QualityConfigTeller)
|
||||
.add(login_flags::UserFlagsTeller)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use polariton_server::operations::{Operation, OperationCode};
|
||||
|
||||
pub struct VersionTeller;
|
||||
pub struct VersionTeller {
|
||||
latest_version: i32,
|
||||
}
|
||||
|
||||
impl VersionTeller {
|
||||
const VERSION_NUMBER_KEY: u8 = 112;
|
||||
const LATEST_VERSION: i32 = 2855;
|
||||
}
|
||||
|
||||
impl <C: Send + 'static> Operation<C> for VersionTeller {
|
||||
@@ -12,7 +13,7 @@ impl <C: Send + 'static> Operation<C> for VersionTeller {
|
||||
|
||||
fn handle(&self, _: polariton::operation::ParameterTable<C>, _: &Self::User) -> polariton::operation::OperationResponse<C> {
|
||||
let mut resp_params = std::collections::HashMap::new();
|
||||
resp_params.insert(Self::VERSION_NUMBER_KEY, polariton::operation::Typed::Int(Self::LATEST_VERSION));
|
||||
resp_params.insert(Self::VERSION_NUMBER_KEY, polariton::operation::Typed::Int(self.latest_version));
|
||||
polariton::operation::OperationResponse {
|
||||
code: 103,
|
||||
return_code: 0,
|
||||
@@ -27,3 +28,9 @@ impl OperationCode for VersionTeller {
|
||||
103
|
||||
}
|
||||
}
|
||||
|
||||
pub fn version_teller(conf: &oj_rc_core::ConfigImpl) -> VersionTeller {
|
||||
VersionTeller {
|
||||
latest_version: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::server_config(conf).minimum_version,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user