diff --git a/engine/session/src/session.rs b/engine/session/src/session.rs index 7749f2b..c5f6329 100644 --- a/engine/session/src/session.rs +++ b/engine/session/src/session.rs @@ -12,6 +12,7 @@ use strafesnet_common::physics::{ }; use strafesnet_common::timer::{Scaled,Timer}; use strafesnet_common::session::{TimeInner as SessionTimeInner,Time as SessionTime}; +use strafesnet_settings::directories::Directories; use crate::mouse_interpolator::{MouseInterpolator,StepInstruction,Instruction as MouseInterpolatorInstruction}; use strafesnet_physics::physics::{self,PhysicsContext,PhysicsData}; @@ -149,6 +150,7 @@ enum ViewState{ } pub struct Session{ + directories:Directories, user_settings:UserSettings, mouse_interpolator:crate::mouse_interpolator::MouseInterpolator, view_state:ViewState, @@ -163,10 +165,12 @@ pub struct Session{ impl Session{ pub fn new( user_settings:UserSettings, + directories:Directories, simulation:Simulation, )->Self{ Self{ user_settings, + directories, mouse_interpolator:MouseInterpolator::new(), geometry_shared:Default::default(), simulation, @@ -295,11 +299,17 @@ impl InstructionConsumer> for Session{ match view_state{ ViewState::Play=>(), ViewState::Replay(bot_id)=>if let Some(replay)=self.replays.remove(&bot_id){ - let file_name=format!("replays/{}.snfb",ins.time); + let mut replays_path=self.directories.replays.clone(); + let file_name=format!("{}.snfb",ins.time); std::thread::spawn(move ||{ - std::fs::create_dir_all("replays").unwrap(); - let file=std::fs::File::create(file_name).unwrap(); - strafesnet_snf::bot::write_bot(std::io::BufWriter::new(file),strafesnet_physics::VERSION.get(),replay.recording.instructions).unwrap(); + std::fs::create_dir_all(replays_path.as_path()).unwrap(); + replays_path.push(file_name); + let file=std::fs::File::create(replays_path).unwrap(); + strafesnet_snf::bot::write_bot( + std::io::BufWriter::new(file), + strafesnet_physics::VERSION.get(), + replay.recording.instructions + ).unwrap(); println!("Finished writing bot file!"); }); }, diff --git a/strafe-client/src/physics_worker.rs b/strafe-client/src/physics_worker.rs index a597c03..4b18740 100644 --- a/strafe-client/src/physics_worker.rs +++ b/strafe-client/src/physics_worker.rs @@ -1,5 +1,5 @@ use crate::graphics_worker::Instruction as GraphicsInstruction; -use strafesnet_settings::settings; +use strafesnet_settings::{directories::Directories,settings}; use strafesnet_session::session::{ Session,Simulation,SessionInputInstruction,SessionControlInstruction,SessionPlaybackInstruction,ImplicitModeInstruction, Instruction as SessionInstruction, @@ -21,6 +21,7 @@ pub enum Instruction{ pub fn new<'a>( mut graphics_worker:crate::compat_worker::INWorker<'a,crate::graphics_worker::Instruction>, + directories:Directories, user_settings:settings::UserSettings, )->crate::compat_worker::QNWorker<'a,TimedInstruction>{ let physics=strafesnet_physics::physics::PhysicsState::default(); @@ -28,6 +29,7 @@ pub fn new<'a>( let simulation=Simulation::new(timer,physics); let mut session=Session::new( user_settings, + directories, simulation, ); crate::compat_worker::QNWorker::new(move |ins:TimedInstruction|{ diff --git a/strafe-client/src/window.rs b/strafe-client/src/window.rs index 985291c..b2139cd 100644 --- a/strafe-client/src/window.rs +++ b/strafe-client/src/window.rs @@ -232,6 +232,7 @@ pub fn worker<'a>( window, physics_thread:crate::physics_worker::new( graphics_thread, + directories, user_settings, ), };