diff --git a/src/lib.rs b/src/lib.rs index 20409b2..059c502 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,6 +111,23 @@ impl PSOPacketData for String { } } +#[derive(Debug, Clone, PartialEq)] +pub struct ConsumingBlob { + pub blob: Vec, +} + +impl PSOPacketData for ConsumingBlob { + fn from_bytes(cursor: &mut R) -> Result { + let mut blob: Vec = Vec::new(); + cursor.read_to_end(&mut blob).map_err(|_| PacketParseError::ReadError)?; + Ok(ConsumingBlob { + blob: blob, + }) + } + fn as_bytes(&self) -> Vec { + self.blob.clone() + } +} pub trait PSOPacket: std::fmt::Debug { // const CMD: u16; @@ -545,4 +562,22 @@ mod test { let bytes = test.as_bytes(); assert!(bytes[1] == 101); } + + #[test] + fn test_consuming_blob() { + #[pso_packet(0x6D, manual_flag)] + struct SixDee { + flag: u32, + blob: ConsumingBlob, + } + + let pkt = vec![76, 0, 109, 0, 1, 0, 0, 0, 109, 0, 0, 0, 68, 0, 0, 0, 140, 0, 0, 0, + 51, 0, 0, 0, 84, 220, 255, 254, 253, 1, 254, 240, 33, 254, 240, + 65, 254, 240, 85, 97, 254, 240, 129, 254, 240, 161, 254, 240, 193, + 254, 240, 169, 225, 13, 1, 16, 0, 33, 16, 0, 65, 16, 0, 97, 0, 16, + 1, 64, 15, 82, 15, 100, 15, 118, 0, 0]; + + let data = SixDee::from_bytes(&pkt); + assert!(pkt == data.unwrap().as_bytes()); + } } diff --git a/src/packet/ship.rs b/src/packet/ship.rs index b62e58e..266601f 100644 --- a/src/packet/ship.rs +++ b/src/packet/ship.rs @@ -4,6 +4,7 @@ use crate::utf8_to_utf16_array; use crate::packet::messages::GameMessage; //use character::character::FullCharacter; use crate::character::character as character; +use crate::ConsumingBlob; use std::io::Read; @@ -136,6 +137,11 @@ impl DirectMessage { } } +#[pso_packet(0x6D, manual_flag)] +struct Like62ButCooler { + pub flag: u32, + pub blob: ConsumingBlob, +} #[derive(PSOPacketData, Clone, Copy, Default)]