create replays folder + write replay using spawned thread :)
This commit is contained in:
parent
adcd7db4f1
commit
9ba3484e25
@ -292,11 +292,15 @@ impl InstructionConsumer<Instruction<'_>> for Session{
|
|||||||
Instruction::Control(SessionControlInstruction::SaveReplay)=>{
|
Instruction::Control(SessionControlInstruction::SaveReplay)=>{
|
||||||
// Bind: N
|
// Bind: N
|
||||||
let view_state=core::mem::replace(&mut self.view_state,ViewState::Play);
|
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{
|
match view_state{
|
||||||
ViewState::Play=>(),
|
ViewState::Play=>(),
|
||||||
ViewState::Replay(bot_id)=>if let Some(replay)=self.replays.remove(&bot_id){
|
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();
|
strafesnet_snf::bot::write_bot(std::io::BufWriter::new(file),replay.recording.instructions).unwrap();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_=self.simulation.timer.set_paused(ins.time,false);
|
_=self.simulation.timer.set_paused(ins.time,false);
|
||||||
|
1
tools/replays
Symbolic link
1
tools/replays
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/run/media/quat/Files/Documents/map-files/verify-scripts/replays
|
Loading…
x
Reference in New Issue
Block a user