diff --git a/strafe-client/src/mouse_interpolator.rs b/strafe-client/src/mouse_interpolator.rs index 97cb0b2..3baa4a6 100644 --- a/strafe-client/src/mouse_interpolator.rs +++ b/strafe-client/src/mouse_interpolator.rs @@ -62,7 +62,7 @@ impl MouseInterpolator{ output:std::collections::VecDeque::new(), } } - fn push_mouse(&mut self,ins:TimedInstruction){ + fn push_mouse_and_flush_buffer(&mut self,ins:TimedInstruction){ self.buffer.push_front(TimedInstruction{ time:ins.time, instruction:PhysicsInputInstruction::Mouse(ins.instruction), @@ -76,7 +76,7 @@ impl MouseInterpolator{ self.output.append(&mut self.buffer); } } - fn get_timedout_at(&self,time_limit:SessionTime)->Option{ + fn get_mouse_timedout_at(&self,time_limit:SessionTime)->Option{ match &self.buffer_state{ BufferState::Unbuffered=>None, BufferState::Initializing(time,_mouse_state) @@ -86,7 +86,7 @@ impl MouseInterpolator{ } } } - fn timeout(&mut self,time:PhysicsTime){ + fn timeout_mouse(&mut self,time:PhysicsTime){ let buffer_state=core::mem::replace(&mut self.buffer_state,BufferState::Unbuffered); match buffer_state{ BufferState::Unbuffered=>(), @@ -96,7 +96,7 @@ impl MouseInterpolator{ // use the first instruction which should be a mouse instruction // to push a ReplaceMouse instruction // duplicate the current mouse - self.push_mouse(TimedInstruction{ + self.push_mouse_and_flush_buffer(TimedInstruction{ // This should be simulation_timer.time(timeout) // but the timer is not accessible from this scope // and it's just here to say that the mouse isn't moving anyways. @@ -120,8 +120,8 @@ impl MouseInterpolator{ // a mouse event is buffered, but no mouse events have transpired within 10ms // push buffered mouse instruction and flush buffer to output - if self.get_timedout_at(ins.time).is_some(){ - self.timeout(ins.instruction.time); + if self.get_mouse_timedout_at(ins.time).is_some(){ + self.timeout_mouse(ins.instruction.time); } // replace_with allows the enum variant to safely be replaced from behind a mutable reference let (ins_mouse,ins_other)=replace_with::replace_with_or_abort_and_return(&mut self.buffer_state,|buffer_state|{ @@ -158,7 +158,7 @@ impl MouseInterpolator{ } }); if let Some(ins)=ins_mouse{ - self.push_mouse(ins); + self.push_mouse_and_flush_buffer(ins); } if let Some(ins)=ins_other{ let instruction=TimedInstruction{ @@ -176,7 +176,7 @@ impl MouseInterpolator{ self.output.len()!=0 } pub fn buffered_instruction_with_timeout(&self,time_limit:SessionTime)->Option>{ - match self.get_timedout_at(time_limit){ + match self.get_mouse_timedout_at(time_limit){ Some(timeout)=>Some(TimedInstruction{ time:timeout, instruction:StepInstruction::Timeout, @@ -191,7 +191,7 @@ impl MouseInterpolator{ pub fn pop_buffered_instruction(&mut self,ins:TimedInstruction)->Option>{ match ins.instruction{ StepInstruction::Pop=>(), - StepInstruction::Timeout=>self.timeout(ins.time), + StepInstruction::Timeout=>self.timeout_mouse(ins.time), } self.output.pop_front() }