From a442a34a2ce7bdb7108bec00278f9d6b2afefc20 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 16 Nov 2019 23:13:36 -0800 Subject: [PATCH] start of gamemessage --- src/packet/messages.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/packet/messages.rs b/src/packet/messages.rs index e8d4903..1dc12de 100644 --- a/src/packet/messages.rs +++ b/src/packet/messages.rs @@ -19,23 +19,25 @@ pub struct PlayerWalking { } - -pub enum Message { +#[derive(Debug, Clone, PartialEq)] +pub enum GameMessage { PlayerWalking(PlayerWalking), } -impl PSOPacketData for Message { +impl PSOPacketData for GameMessage { fn from_bytes(mut cur: &mut R) -> Result { let mut byte = [0u8; 1]; cur.read(&mut byte); cur.seek(SeekFrom::Current(-1)); // Cursor doesn't implement Peek? match byte[0] { - PlayerWalking::CMD => Ok(Message::PlayerWalking(PlayerWalking::from_bytes(&mut cur)?)), + PlayerWalking::CMD => Ok(GameMessage::PlayerWalking(PlayerWalking::from_bytes(&mut cur)?)), _ => Err(PacketParseError::WrongPacketCommand), } } fn as_bytes(&self) -> Vec { - Vec::new() + match self { + GameMessage::PlayerWalking(data) => data.as_bytes(), + } } }