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

Make factory upload limit configurable and increase default to mitigate #105

This commit is contained in:
NG (Graham)
2026-04-08 21:06:06 -04:00
parent 766604078f
commit c82c11fc1c
7 changed files with 28 additions and 8 deletions

View File

@@ -14537,6 +14537,8 @@
},
"shop": {},
"settings": {
"server": {
},
"banners": [
{
"message": "No jam was harmed in the reverse-engineering of this game",

View File

@@ -318,6 +318,12 @@ impl <C: Clone + Send> super::ConfigProvider<C> for CubeConfig {
crate::factory::Factory::from_config(&self.factory, &<Self as super::ConfigProvider<()>>::server_config(self), builtin_factory_provider).await
}
fn factory_config(&self) -> super::FactoryConfig {
super::FactoryConfig {
upload_limit: self.factory.upload_limit,
}
}
fn cubes(&self) -> &'_ indexmap::IndexMap<String, crate::persist::Cube> {
&self.cubes
}

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, MultiplayerSettings, BattleArenaCrystalParams, VehicleValidators, TeamChoosers};
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, BattleArenaCrystalParams, VehicleValidators, TeamChoosers, FactoryConfig};
mod validation;
pub use validation::{SelfValidator, ValidationInfo, ValidationMessage};

View File

@@ -21,6 +21,7 @@ pub trait ConfigProvider<C: Clone> {
fn server_config(&self) -> ServerConfig;
fn garage_upgrades(&self) -> GarageUpgrades;
async fn factory(&self, builtin_factory_provider: &(dyn (Fn() -> oj_rc_database::FactoryDatabase) + Sync)) -> Result<crate::factory::Factory, Box<dyn std::error::Error + 'static>>;
fn factory_config(&self) -> FactoryConfig;
fn cubes(&self) -> &'_ indexmap::IndexMap<String, crate::persist::Cube>;
fn chat_system_config(&self) -> ChatSystemConfig;
fn gamemode_events(&self) -> GameEventSequence;
@@ -143,6 +144,10 @@ impl GarageUpgrades {
}
}
pub struct FactoryConfig {
pub upload_limit: i32,
}
#[derive(Clone, Debug)]
pub struct ChatSystemConfig {
pub command_channel: String,

View File

@@ -4,6 +4,8 @@ use serde::{Serialize, Deserialize};
pub struct FactoryConfig {
#[serde(default = "default_variant")]
pub adapter: AdapterSettings,
#[serde(default = "default_upload_limit")]
pub upload_limit: i32,
}
impl super::config::SelfValidator for FactoryConfig {
@@ -18,6 +20,10 @@ fn default_variant() -> AdapterSettings {
AdapterSettings::BuiltIn
}
fn default_upload_limit() -> i32 {
4096
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(tag = "variant")]
pub enum AdapterSettings {

View File

@@ -1,15 +1,16 @@
use polariton_server::operations::SimpleFunc;
use polariton_server::operations::Immediate;
use polariton::operation::{ParameterTable, Typed};
const PARAM_KEY: u8 = 100;
pub(super) fn robot_shop_submission_infos_provider() -> SimpleFunc<95, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
pub(super) fn robot_shop_submission_infos_provider(config: &oj_rc_core::ConfigImpl) -> Immediate<95, crate::UserTy> {
let max_subs = <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::factory_config(config).upload_limit;
Immediate::new(|| {
let mut params = ParameterTable::with_capacity(2);
params.insert(PARAM_KEY, Typed::HashMap(vec![
(Typed::Str("submissionCount".into()), Typed::Int(0)),
(Typed::Str("maxSubmissions".into()), Typed::Int(10)),
(Typed::Str("maxSubmissions".into()), Typed::Int(max_subs)),
].into()));
Ok(params.into())
params
})
}

View File

@@ -179,7 +179,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
.add(player_rank::rank_static_provider())
.add(ab_test_group::test_group_provider())
.add(league_limits::league_battle_parameters_provider())
.add(crf_limits::robot_shop_submission_infos_provider())
.add(crf_limits::robot_shop_submission_infos_provider(&init_ctx.cubes))
.add(robot_mastery_settings::robot_mastery_settings_provider())
.add(player_started_purchase::started_purchase_provider())
.add(custom_games_team::team_setup_provider())