create replays folder + write replay using spawned thread :)

This commit is contained in:
Quaternions 2025-01-20 05:40:11 -08:00
parent adcd7db4f1
commit 9ba3484e25
2 changed files with 7 additions and 2 deletions

View File

@ -292,11 +292,15 @@ impl InstructionConsumer<Instruction<'_>> for Session{
Instruction::Control(SessionControlInstruction::SaveReplay)=>{
// Bind: N
let view_state=core::mem::replace(&mut self.view_state,ViewState::Play);
let file=std::fs::File::create(format!("{}.snfb",ins.time)).unwrap();
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);
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),replay.recording.instructions).unwrap();
});
},
}
_=self.simulation.timer.set_paused(ins.time,false);

1
tools/replays Symbolic link
View File

@ -0,0 +1 @@
/run/media/quat/Files/Documents/map-files/verify-scripts/replays