diff options
Diffstat (limited to 'shared/src/packets.rs')
-rw-r--r-- | shared/src/packets.rs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/shared/src/packets.rs b/shared/src/packets.rs index dad09ce..b979460 100644 --- a/shared/src/packets.rs +++ b/shared/src/packets.rs @@ -82,7 +82,7 @@ impl Packet { match self { Packet::Connect(id) => { w.write_all(&[0x00])?; - w.write_all(&id.to_be_bytes())?; + w.write_all(&id.to_le_bytes())?; } Packet::Disconnect => { w.write_all(&[0xff])?; @@ -98,7 +98,7 @@ impl Packet { } Packet::Add(object, resource) => { w.write_all(&[0x03])?; - w.write_all(&object.0.to_be_bytes())?; + w.write_all(&object.0.to_le_bytes())?; w.write_all(&resource.0)?; } Packet::Remove(object) => { @@ -107,23 +107,23 @@ impl Packet { } Packet::Position(object, pos, rot) => { w.write_all(&[0x05])?; - w.write_all(&object.0.to_be_bytes())?; + w.write_all(&object.0.to_le_bytes())?; pos.write(w)?; rot.write(w)?; } Packet::Pose(object, vec) => { w.write_all(&[0x06])?; - w.write_all(&object.0.to_be_bytes())?; - w.write_all(&(vec.len() as u16).to_be_bytes())?; + w.write_all(&object.0.to_le_bytes())?; + w.write_all(&(vec.len() as u16).to_le_bytes())?; } Packet::Parent(parent, child) => { w.write_all(&[0x07])?; - w.write_all(&parent.0.to_be_bytes())?; - w.write_all(&child.0.to_be_bytes())?; + w.write_all(&parent.0.to_le_bytes())?; + w.write_all(&child.0.to_le_bytes())?; } Packet::Sound(object, data) => { w.write_all(&[0x08])?; - w.write_all(&object.0.to_be_bytes())?; + w.write_all(&object.0.to_le_bytes())?; data.write(w)?; } Packet::PrefabIndex(resource) => { @@ -147,7 +147,7 @@ impl ReadWrite for Packet { fn write(&self, w: &mut dyn Write) -> Result<()> { let mut buf = Vec::new(); self.serialize_inner(&mut buf)?; - w.write_all(&(buf.len() as u32).to_be_bytes())?; + w.write_all(&(buf.len() as u32).to_le_bytes())?; w.write_all(&buf)?; Ok(()) } @@ -183,13 +183,13 @@ impl ReadWrite for Packet { fn read_u128(r: &mut dyn Read) -> Result<u128> { let mut buf = [0; 16]; r.read_exact(&mut buf)?; - Ok(u128::from_be_bytes(buf)) + Ok(u128::from_le_bytes(buf)) } fn read_params(r: &mut dyn Read) -> Result<Vec<f32>> { let mut size = [0; 2]; r.read_exact(&mut size)?; - let size = u16::from_be_bytes(size); + let size = u16::from_le_bytes(size); let mut v = Vec::with_capacity(size as usize); for _ in 0..size { v.push(f32::read(r)?); @@ -202,10 +202,10 @@ impl<T> Display for Resource<T> { write!( f, "Res{{{:016x}{:016x}{:016x}{:016x}}}", - u64::from_be_bytes(self.0[0..8].try_into().unwrap()), - u64::from_be_bytes(self.0[8..16].try_into().unwrap()), - u64::from_be_bytes(self.0[16..24].try_into().unwrap()), - u64::from_be_bytes(self.0[24..32].try_into().unwrap()), + u64::from_le_bytes(self.0[0..8].try_into().unwrap()), + u64::from_le_bytes(self.0[8..16].try_into().unwrap()), + u64::from_le_bytes(self.0[16..24].try_into().unwrap()), + u64::from_le_bytes(self.0[24..32].try_into().unwrap()), ) } } |