diff --git a/rc_multiplayer/src/matches/aggregate.rs b/rc_multiplayer/src/matches/aggregate.rs index 32266c4..a9d33ea 100644 --- a/rc_multiplayer/src/matches/aggregate.rs +++ b/rc_multiplayer/src/matches/aggregate.rs @@ -124,12 +124,19 @@ impl GameMatches { let fakes_handler = super::fake::Handler::start(fakes, players.clone()).await; match game_info.mode { oj_rc_core::data::game_mode::GameMode::SuddenDeath => { - let inner = super::modes::EliminationLogic::new(&self.mode_configs.elimination, &map_config, &players); - let engine = super::GenericGamemodeEngine::new( - game_info, - map_config, - &self.mode_configs.elimination, + let super_conf = super::engine::SuperConfig { + descriptor: game_info, + map: map_config, + game_mode: &self.mode_configs.elimination, players, + }; + let inner = super::modes::EliminationLogic::new( + &self.mode_configs.elimination, + &super_conf.map, + &super_conf.players, + ); + let engine = super::GenericGamemodeEngine::new( + super_conf, inner, fakes_handler, self.mp_settings.clone(), @@ -159,12 +166,19 @@ impl GameMatches { } else { self.ba_sorted_crystals.read().await.clone() }; - let inner = super::modes::BattleArenaLogic::new(&self.mode_configs.battle_arena, &map_config, &players, resolved_ba_conf, crystals); - let engine = super::GenericGamemodeEngine::new( - game_info, - map_config, - &self.mode_configs.battle_arena, + let super_conf = super::engine::SuperConfig { + descriptor: game_info, + map: map_config, + game_mode: &self.mode_configs.battle_arena, players, + }; + let inner = super::modes::BattleArenaLogic::new( + &super_conf, + resolved_ba_conf, + crystals, + ); + let engine = super::GenericGamemodeEngine::new( + super_conf, inner, fakes_handler, self.mp_settings.clone(), @@ -172,17 +186,20 @@ impl GameMatches { Ok(engine.spawn()) }, oj_rc_core::data::game_mode::GameMode::Pit => { + let super_conf = super::engine::SuperConfig { + descriptor: game_info, + map: map_config, + game_mode: &self.mode_configs.the_pit, + players, + }; let inner = super::modes::PitLogic::new( &self.mode_configs.the_pit, - &map_config, - &players, + &super_conf.map, + &super_conf.players, self.pit_settings.clone(), ); let engine = super::GenericGamemodeEngine::new( - game_info, - map_config, - &self.mode_configs.the_pit, - players, + super_conf, inner, fakes_handler, self.mp_settings.clone(), @@ -190,17 +207,20 @@ impl GameMatches { Ok(engine.spawn()) }, oj_rc_core::data::game_mode::GameMode::TeamDeathmatch => { + let super_conf = super::engine::SuperConfig { + descriptor: game_info, + map: map_config, + game_mode: &self.mode_configs.team_deathmatch, + players, + }; let inner = super::modes::TeamDeathMatchLogic::new( &self.mode_configs.team_deathmatch, - &map_config, - &players, + &super_conf.map, + &super_conf.players, self.tdm_settings.clone(), ); let engine = super::GenericGamemodeEngine::new( - game_info, - map_config, - &self.mode_configs.team_deathmatch, - players, + super_conf, inner, fakes_handler, self.mp_settings.clone(), diff --git a/rc_multiplayer/src/matches/engine.rs b/rc_multiplayer/src/matches/engine.rs index 5325e18..b24a81f 100644 --- a/rc_multiplayer/src/matches/engine.rs +++ b/rc_multiplayer/src/matches/engine.rs @@ -4,6 +4,13 @@ pub struct RlnlPacket { pub data: Box, } +pub struct SuperConfig<'a> { + pub descriptor: oj_rc_core::persist::user::GameDescriptor, + pub map: oj_rc_core::persist::config::MapConfig, + pub game_mode: &'a oj_rc_core::data::game_mode::GameModeConfig, + pub players: Vec, +} + /// Functions returning a boolean indicate if the generic engine should also perform the default behaviour /// (true = yes, do default behaviour) #[async_trait::async_trait] diff --git a/rc_multiplayer/src/matches/generic.rs b/rc_multiplayer/src/matches/generic.rs index cd60669..657f56b 100644 --- a/rc_multiplayer/src/matches/generic.rs +++ b/rc_multiplayer/src/matches/generic.rs @@ -311,10 +311,7 @@ impl GenericGamemodeEngine { const COUNTDOWN_DURATION: std::time::Duration = std::time::Duration::from_secs(5); pub fn new( - game: oj_rc_core::persist::user::GameDescriptor, - map: oj_rc_core::persist::config::MapConfig, - config: &oj_rc_core::data::game_mode::GameModeConfig, - players: Vec, + super_conf: crate::matches::engine::SuperConfig, custom: L, fakes_handler: super::fake::Handler, mp_config: std::sync::Arc, @@ -325,11 +322,11 @@ impl GenericGamemodeEngine { .map(|player| (player.team as u8, FakeUser::new(player.to_owned()))) .collect();*/ - let descriptors = players.iter() + let descriptors = super_conf.players.iter() .map(|player| (player.player_id, UserDescriptor::new(player.to_owned()))) .collect(); - let user_id_map = players.iter() + let user_id_map = super_conf.players.iter() .filter_map(|player| player.user_id.map(|id| (id, player.player_id))) .collect(); Self { @@ -338,9 +335,9 @@ impl GenericGamemodeEngine { user_id_map, is_complete: std::sync::atomic::AtomicBool::new(false), game_start: std::sync::atomic::AtomicI64::new(i64::MIN), - map_config: std::sync::Arc::new(map), - game_descriptor: game, - game_duration: std::time::Duration::from_secs((config.game_time_minutes as u64) * 60), + map_config: std::sync::Arc::new(super_conf.map), + game_descriptor: super_conf.descriptor, + game_duration: std::time::Duration::from_secs((super_conf.game_mode.game_time_minutes as u64) * 60), custom_logic_handler: custom, fakes_handler, unclaimed: UnclaimedStats::new(), diff --git a/rc_multiplayer/src/matches/modes/battle_arena.rs b/rc_multiplayer/src/matches/modes/battle_arena.rs index 3192d92..66a8a44 100644 --- a/rc_multiplayer/src/matches/modes/battle_arena.rs +++ b/rc_multiplayer/src/matches/modes/battle_arena.rs @@ -765,7 +765,7 @@ impl BaseTracker { let one_tick = (crystals.len() as f32) * ((PointTracker::TICK_MS as f32) / (generic.game_duration.as_millis() as f32)) * ((self.bases.len() as f32) / (capture_points_count as f32)); - let one_tick = 0.1; + //let one_tick = 0.1; let increment = tick_info.delta as f32 * (*owned_points as f32) * one_tick * multiplier; let old_float_index = tracked_base.cube_index.fetch_add(increment, std::sync::atomic::Ordering::SeqCst); let new_float_index = old_float_index + increment; @@ -1055,7 +1055,7 @@ pub struct BattleArenaLogic { } impl BattleArenaLogic { - pub fn new(config: &oj_rc_core::data::game_mode::GameModeConfig, map: &oj_rc_core::persist::config::MapConfig, players: &[oj_rc_core::persist::user::PlayerDescriptor], ba_config: oj_rc_core::data::battle_arena_config::BattleArenaData, crystals: std::sync::Arc>) -> Self { + pub fn new(super_conf: &crate::matches::engine::SuperConfig, ba_config: oj_rc_core::data::battle_arena_config::BattleArenaData, crystals: std::sync::Arc>) -> Self { //let min_y = crystals.iter().min_by_key(|x| x.y).unwrap(); //log::warn!("First crystal is as ({}, {}, {})", min_y.x, min_y.y, min_y.z); let base_graph = oj_rc_core::cubes::CubeGraph::with_data( @@ -1064,19 +1064,21 @@ impl BattleArenaLogic { oj_rc_core::cubes::CLASP_ID, ).expect("Invalid Battle Arena base cube data"); Self { - respawn_full_heal_duration: config.respawn_full_heal_duration, - respawn_heal_duration: config.respawn_heal_duration, + respawn_full_heal_duration: super_conf.game_mode.respawn_full_heal_duration, + respawn_heal_duration: super_conf.game_mode.respawn_heal_duration, timer_task: tokio::sync::Mutex::new(None), - player_tracking: PlayerTracker::new(players), - capture_tracking: PointTracker::new(map.capture_points.iter().map(|(_, speed)| *speed)), + player_tracking: PlayerTracker::new(&super_conf.players), + capture_tracking: PointTracker::new(super_conf.map.capture_points.iter().map(|(_, speed)| *speed)), surrender_tracking: super::trackers::SurrenderGameTracker::new(), - base_tracking: BaseTracker::new(map.bases.keys(), &crystals, &ba_config, &base_graph), + base_tracking: BaseTracker::new(super_conf.map.bases.keys(), &crystals, &ba_config, &base_graph), //cube_parser, //ba_base: teambase, //ba_equalizer: equalizer, crystals, config: ba_config, - can_drop_shields: true, + can_drop_shields: super_conf.descriptor.overrides.as_ref() + .map(|overrides| overrides.base_shields_go_down) + .unwrap_or(true), } }