From 144e56d2c46043da7924ffa34705f763982676fc Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:28:35 -0700 Subject: [PATCH] controllable (#16) Update ControllablePhysics and FrameStats documentation (#16) --- .../client/replica/controllable_physics.rs | 29 ++++++++++++++----- .../tests/ControllablePhysicsConstruction.rs | 12 ++++---- .../tests/ControllablePhysicsSerialization.rs | 12 ++++---- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/raknet/client/replica/controllable_physics.rs b/src/raknet/client/replica/controllable_physics.rs index 20123c73..f73192d0 100644 --- a/src/raknet/client/replica/controllable_physics.rs +++ b/src/raknet/client/replica/controllable_physics.rs @@ -34,14 +34,21 @@ pub struct CheatInfo { } #[derive(Debug, PartialEq, ReplicaSerde)] -pub struct Unknown1 { +pub struct MagnetAndFlyingUpdate { pub loot_pickup_radius: f32, - pub unknown_2: bool, + pub is_flying: bool, +} + +#[derive(Debug, PartialEq, ReplicaSerde)] +pub struct BubbleInfo { + pub bubble_type: i32, + pub special_animation: bool, } #[derive(Debug, PartialEq, ReplicaSerde)] -pub struct Unknown2 { - pub unknown_1: Option, +pub struct BubbleUpdateInfo { + /// If option is not set, the bubble is removed. + pub bubble_info: Option, } #[derive(Debug, PartialEq, ReplicaSerde)] @@ -50,6 +57,10 @@ pub struct FrameStats { pub rotation: Quaternion, pub is_on_ground: bool, pub is_on_rail: bool, + + /// Default cases of the below `Option`s result in 0 for all fields in that options' struct. + /// This means that if `linear_velocity` is non-zero, you must write the struct, even if nothing + /// has changed frame over frame. pub linear_velocity: Option, pub angular_velocity: Option, pub local_space_info: Option, @@ -59,6 +70,8 @@ pub struct FrameStats { pub struct LocalSpaceInfo { pub object_id: ObjId, pub position: Vector3, + + /// Defaults to [`Vector3::ZERO`] if not set. Always write if non-zero. pub linear_velocity: Option, } @@ -67,8 +80,8 @@ pub struct ControllablePhysicsConstruction { pub jetpack_info: Option, pub stun_immunity_info: Option, pub cheat_info: Option, - pub unknown_1: Option, - pub unknown_2: Option, + pub magnet_and_flying_update: Option, + pub bubble_update_info: Option, pub frame_stats: Option, } @@ -81,8 +94,8 @@ pub struct FrameStatsTeleportInfo { #[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)] pub struct ControllablePhysicsSerialization { pub cheat_info: Option, - pub unknown_1: Option, - pub unknown_2: Option, + pub magnet_and_flying_update: Option, + pub bubble_update_info: Option, pub frame_stats_teleport_info: Option, } diff --git a/src/raknet/client/replica/tests/ControllablePhysicsConstruction.rs b/src/raknet/client/replica/tests/ControllablePhysicsConstruction.rs index 508ecd31..bb892737 100644 --- a/src/raknet/client/replica/tests/ControllablePhysicsConstruction.rs +++ b/src/raknet/client/replica/tests/ControllablePhysicsConstruction.rs @@ -17,14 +17,14 @@ ControllablePhysicsConstruction { gravity_scale: 8.0, run_multiplier: 9.0, }), - unknown_1: Some(Unknown1 { + magnet_and_flying_update: Some(MagnetAndFlyingUpdate { loot_pickup_radius: 10.0, - unknown_2: true, + is_flying: true, }), - unknown_2: Some(Unknown2 { - unknown_1: Some(Unknown1 { - loot_pickup_radius: 11.0, - unknown_2: true, + bubble_update_info: Some(BubbleUpdateInfo { + bubble_info: Some(BubbleInfo { + bubble_type: 1093664768, + special_animation: true, }), }), frame_stats: Some(FrameStats { diff --git a/src/raknet/client/replica/tests/ControllablePhysicsSerialization.rs b/src/raknet/client/replica/tests/ControllablePhysicsSerialization.rs index 1b8d46be..d9b68d12 100644 --- a/src/raknet/client/replica/tests/ControllablePhysicsSerialization.rs +++ b/src/raknet/client/replica/tests/ControllablePhysicsSerialization.rs @@ -3,14 +3,14 @@ ControllablePhysicsSerialization { gravity_scale: 8.0, run_multiplier: 9.0, }), - unknown_1: Some(Unknown1 { + magnet_and_flying_update: Some(MagnetAndFlyingUpdate { loot_pickup_radius: 10.0, - unknown_2: true, + is_flying: true, }), - unknown_2: Some(Unknown2 { - unknown_1: Some(Unknown1 { - loot_pickup_radius: 11.0, - unknown_2: true, + bubble_update_info: Some(BubbleUpdateInfo { + bubble_info: Some(BubbleInfo { + bubble_type: 1093664768, + special_animation: true, }), }), frame_stats_teleport_info: Some(FrameStatsTeleportInfo {