diff --git a/lib/examples/simple_atba.rs b/lib/examples/simple_atba.rs index ba5f1bf..813349a 100644 --- a/lib/examples/simple_atba.rs +++ b/lib/examples/simple_atba.rs @@ -1,7 +1,6 @@ use std::env; use rlbot_lib::{ - self, rlbot::{ControllerState, PlayerInput, ReadyMessage}, Packet, RLBotConnection, }; diff --git a/lib/examples/start_match.rs b/lib/examples/start_match.rs index c7f816e..0a9298e 100644 --- a/lib/examples/start_match.rs +++ b/lib/examples/start_match.rs @@ -1,5 +1,4 @@ use rlbot_lib::{ - self, rlbot::{ ExistingMatchBehavior, GameMap, GameMode, MatchLength, MatchSettings, MutatorSettings, PlayerClass, PlayerConfiguration, PlayerLoadout, RLBotPlayer, diff --git a/lib/src/flat_wrapper/mod.rs b/lib/src/flat_wrapper/mod.rs index 798dd3b..9632c96 100644 --- a/lib/src/flat_wrapper/mod.rs +++ b/lib/src/flat_wrapper/mod.rs @@ -34,7 +34,7 @@ pub use rlbot_generated::rlbot::flat::{ RotatorObject as Rotator, RotatorPartialObject as RotatorPartial, ScoreInfoObject as ScoreInfo, SphereShapeObject as SphereShape, TeamInfoObject as TeamInfo, TinyBallObject as TinyBall, TinyPacketObject as TinyPacket, TinyPlayerObject as TinyPlayer, TouchObject as Touch, - Vector3Object as Vector3, + Vector3Object as Vector3, Vector3PartialObject as Vector3Partial, }; #[cfg(feature = "glam")] diff --git a/lib/src/lib.rs b/lib/src/lib.rs index a6503ea..43a1fed 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -121,13 +121,14 @@ pub struct RLBotConnection { impl RLBotConnection { pub fn send_packet(&mut self, packet: Packet) -> Result<(), RLBotError> { - let data_type_bin = packet.data_type().to_be_bytes(); + let data_type_bin = packet.data_type().to_be_bytes().to_vec(); let payload = packet.build(); - let data_len_bin = (payload.len() as u16).to_be_bytes(); + let data_len_bin = (payload.len() as u16).to_be_bytes().to_vec(); - self.stream.write_all(&data_type_bin)?; - self.stream.write_all(&data_len_bin)?; - self.stream.write_all(&payload)?; + // Join so we make sure everything gets written in the right order + let joined = [data_type_bin, data_len_bin, payload].concat(); + + self.stream.write_all(&joined)?; Ok(()) }