allow writing idle instructions

This commit is contained in:
Quaternions 2025-01-18 00:17:21 -08:00
parent e90f53a111
commit b45b92c627

View File

@ -88,6 +88,8 @@ pub enum Instruction{
PracticeFly, PracticeFly,
#[brw(magic=14u8)] #[brw(magic=14u8)]
SetSensitivity(super::integer::Ratio64Vec2), SetSensitivity(super::integer::Ratio64Vec2),
#[brw(magic=255u8)]
Idle,
} }
#[derive(Debug)] #[derive(Debug)]
pub enum InstructionConvert{ pub enum InstructionConvert{
@ -122,6 +124,7 @@ impl TryInto<strafesnet_common::physics::Instruction> for Instruction{
)), )),
Instruction::PracticeFly=>strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::PracticeFly), Instruction::PracticeFly=>strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::PracticeFly),
Instruction::SetSensitivity(sensitivity)=>strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::SetSensitivity(sensitivity.try_into()?)), Instruction::SetSensitivity(sensitivity)=>strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::SetSensitivity(sensitivity.try_into()?)),
Instruction::Idle=>strafesnet_common::physics::Instruction::Idle,
}) })
} }
} }
@ -147,7 +150,7 @@ impl TryFrom<strafesnet_common::physics::Instruction> for Instruction{
)), )),
strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::PracticeFly)=>Ok(Instruction::PracticeFly), strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::PracticeFly)=>Ok(Instruction::PracticeFly),
strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::SetSensitivity(sensitivity))=>Ok(Instruction::SetSensitivity(sensitivity.into())), strafesnet_common::physics::Instruction::Misc(strafesnet_common::physics::MiscInstruction::SetSensitivity(sensitivity))=>Ok(Instruction::SetSensitivity(sensitivity.into())),
strafesnet_common::physics::Instruction::Idle=>Err(InstructionConvert::DropInstruction), strafesnet_common::physics::Instruction::Idle=>Ok(Instruction::Idle),
} }
} }
} }