wrong instruction

This commit is contained in:
Quaternions 2025-01-14 01:36:50 -08:00
parent 29f9d5298f
commit 90f6437817

View File

@ -1,7 +1,7 @@
use strafesnet_common::instruction::TimedInstruction; use strafesnet_common::instruction::TimedInstruction;
use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner}; use strafesnet_common::session::{Time as SessionTime,TimeInner as SessionTimeInner};
use strafesnet_common::physics::{OtherInstruction,UnbufferedInstruction}; use strafesnet_common::physics::{OtherInstruction,UnbufferedInstruction};
use crate::session::ExternalInstruction as SessionExternalInstruction; use crate::physics_worker::Instruction as PhysicsWorkerInstruction;
pub enum Instruction{ pub enum Instruction{
Resize(winit::dpi::PhysicalSize<u32>), Resize(winit::dpi::PhysicalSize<u32>),
@ -17,7 +17,7 @@ struct WindowContext<'a>{
mouse:strafesnet_common::mouse::MouseState<SessionTimeInner>,//std::sync::Arc<std::sync::Mutex<>> mouse:strafesnet_common::mouse::MouseState<SessionTimeInner>,//std::sync::Arc<std::sync::Mutex<>>
screen_size:glam::UVec2, screen_size:glam::UVec2,
window:&'a winit::window::Window, window:&'a winit::window::Window,
physics_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<SessionExternalInstruction,SessionTimeInner>>, physics_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<PhysicsWorkerInstruction,SessionTimeInner>>,
} }
impl WindowContext<'_>{ impl WindowContext<'_>{
@ -28,7 +28,7 @@ impl WindowContext<'_>{
match event{ match event{
winit::event::WindowEvent::DroppedFile(path)=>{ winit::event::WindowEvent::DroppedFile(path)=>{
match crate::file::load(path.as_path()){ match crate::file::load(path.as_path()){
Ok(map)=>self.physics_thread.send(TimedInstruction{time,instruction:SessionExternalInstruction::ChangeMap(map)}).unwrap(), Ok(map)=>self.physics_thread.send(TimedInstruction{time,instruction:PhysicsWorkerInstruction::ChangeMap(map)}).unwrap(),
Err(e)=>println!("Failed to load map: {e}"), Err(e)=>println!("Failed to load map: {e}"),
} }
}, },
@ -36,7 +36,7 @@ impl WindowContext<'_>{
//pause unpause //pause unpause
self.physics_thread.send(TimedInstruction{ self.physics_thread.send(TimedInstruction{
time, time,
instruction:SessionExternalInstruction::SetPaused(!state), instruction:PhysicsWorkerInstruction::SetPaused(!state),
}).unwrap(); }).unwrap();
//recalculate pressed keys on focus //recalculate pressed keys on focus
}, },
@ -113,7 +113,7 @@ impl WindowContext<'_>{
}{ }{
self.physics_thread.send(TimedInstruction{ self.physics_thread.send(TimedInstruction{
time, time,
instruction:SessionExternalInstruction::Input(UnbufferedInstruction::Other(input_instruction)), instruction:PhysicsWorkerInstruction::Input(UnbufferedInstruction::Other(input_instruction)),
}).unwrap(); }).unwrap();
} }
}, },
@ -141,7 +141,7 @@ impl WindowContext<'_>{
self.mouse.pos+=delta; self.mouse.pos+=delta;
self.physics_thread.send(TimedInstruction{ self.physics_thread.send(TimedInstruction{
time, time,
instruction:SessionExternalInstruction::Input(UnbufferedInstruction::MoveMouse(self.mouse.pos)), instruction:PhysicsWorkerInstruction::Input(UnbufferedInstruction::MoveMouse(self.mouse.pos)),
}).unwrap(); }).unwrap();
}, },
winit::event::DeviceEvent::MouseWheel { winit::event::DeviceEvent::MouseWheel {
@ -151,7 +151,7 @@ impl WindowContext<'_>{
if false{//self.physics.style.use_scroll{ if false{//self.physics.style.use_scroll{
self.physics_thread.send(TimedInstruction{ self.physics_thread.send(TimedInstruction{
time, time,
instruction:SessionExternalInstruction::Input(UnbufferedInstruction::Other(OtherInstruction::SetJump(true))),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump instruction:PhysicsWorkerInstruction::Input(UnbufferedInstruction::Other(OtherInstruction::SetJump(true))),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump
}).unwrap(); }).unwrap();
} }
}, },
@ -200,7 +200,7 @@ pub fn worker<'a>(
window_context.physics_thread.send( window_context.physics_thread.send(
TimedInstruction{ TimedInstruction{
time:ins.time, time:ins.time,
instruction:SessionExternalInstruction::Resize(size) instruction:PhysicsWorkerInstruction::Resize(size)
} }
).unwrap(); ).unwrap();
} }
@ -208,7 +208,7 @@ pub fn worker<'a>(
window_context.physics_thread.send( window_context.physics_thread.send(
TimedInstruction{ TimedInstruction{
time:ins.time, time:ins.time,
instruction:SessionExternalInstruction::Render instruction:PhysicsWorkerInstruction::Render
} }
).unwrap(); ).unwrap();
} }