From eaecbc5b735d9d060858d360bcc0b9c866d4c3ea Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 20 Jan 2025 10:36:28 -0800 Subject: [PATCH] physics versioning plan --- lib/snf/src/bot.rs | 10 +++++++-- strafe-client/src/physics.rs | 39 ++++++++++++++++++++++++++++++++++++ strafe-client/src/session.rs | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/lib/snf/src/bot.rs b/lib/snf/src/bot.rs index 3712341..77936aa 100644 --- a/lib/snf/src/bot.rs +++ b/lib/snf/src/bot.rs @@ -28,12 +28,16 @@ pub enum Error{ /* block types BLOCK_BOT_HEADER: -// Tegments are laid out in chronological order, +// Segments are laid out in chronological order, // but block_id is not necessarily in ascending order. // // This is to place the final segment close to the start of the file, // which allows the duration of the bot to be conveniently calculated // from the first and last instruction timestamps. +// +// Use exact physics version for replay playback +// Use highest compatible physics version for verification +u32 physics_version u32 num_segments for _ in 0..num_segments{ i64 time @@ -61,6 +65,7 @@ struct SegmentHeader{ #[binrw] #[brw(little)] struct Header{ + physics_version:u32, num_segments:u32, #[br(count=num_segments)] segments:Vec, @@ -151,7 +156,7 @@ impl StreamableBot{ } const MAX_BLOCK_SIZE:usize=64*1024;//64 kB -pub fn write_bot(mut writer:W,instructions:impl IntoIterator)->Result<(),Error>{ +pub fn write_bot(mut writer:W,physics_version:u32,instructions:impl IntoIterator)->Result<(),Error>{ // decide which instructions to put in which segment // write segment 1 to block 1 // write segment N to block 2 @@ -251,6 +256,7 @@ pub fn write_bot(mut writer:W,instructions:impl IntoIteratorResult{ + if (version as usize); type MouseState=strafesnet_common::mouse::MouseState; diff --git a/strafe-client/src/session.rs b/strafe-client/src/session.rs index d6518e6..1fa0d89 100644 --- a/strafe-client/src/session.rs +++ b/strafe-client/src/session.rs @@ -299,7 +299,7 @@ impl InstructionConsumer> for Session{ 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),crate::physics::VERSION.get(),replay.recording.instructions).unwrap(); }); }, }