From c2d6af8bda8db24b3a75e122570b4cc5d56e682d Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 15 Jan 2025 03:22:19 -0800 Subject: [PATCH] TimedInstruction::set_time --- lib/common/src/instruction.rs | 8 ++++++++ strafe-client/src/session.rs | 8 ++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/common/src/instruction.rs b/lib/common/src/instruction.rs index d1d6e36..3b71db9 100644 --- a/lib/common/src/instruction.rs +++ b/lib/common/src/instruction.rs @@ -5,6 +5,14 @@ pub struct TimedInstruction{ pub time:Time, pub instruction:I, } +impl TimedInstruction{ + pub fn set_time(self,new_time:Time)->TimedInstruction{ + TimedInstruction{ + time:new_time, + instruction:self.instruction, + } + } +} /// Ensure all emitted instructions are processed before consuming external instructions pub trait InstructionEmitter{ diff --git a/strafe-client/src/session.rs b/strafe-client/src/session.rs index 5764d7c..14d52bc 100644 --- a/strafe-client/src/session.rs +++ b/strafe-client/src/session.rs @@ -181,12 +181,8 @@ impl InstructionConsumer> for Session{ impl InstructionConsumer for Session{ type TimeInner=SessionTimeInner; fn process_instruction(&mut self,ins:TimedInstruction){ - // ins.time ignored??? - let ins_retimed=TimedInstruction{ - time:self.simulation.timer.time(ins.time), - instruction:ins.instruction, - }; - if let Some(instruction)=self.mouse_interpolator.pop_buffered_instruction(ins_retimed){ + let time=self.simulation.timer.time(ins.time); + if let Some(instruction)=self.mouse_interpolator.pop_buffered_instruction(ins.set_time(time)){ self.simulation.physics.run_input_instruction(instruction); } }