|
@ -19,23 +19,25 @@ pub struct PlayerWalking { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub enum Message {
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
|
|
|
|
pub enum GameMessage {
|
|
|
PlayerWalking(PlayerWalking),
|
|
|
PlayerWalking(PlayerWalking),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl PSOPacketData for Message {
|
|
|
|
|
|
|
|
|
impl PSOPacketData for GameMessage {
|
|
|
fn from_bytes<R: std::io::Read + std::io::Seek>(mut cur: &mut R) -> Result<Self, PacketParseError> {
|
|
|
fn from_bytes<R: std::io::Read + std::io::Seek>(mut cur: &mut R) -> Result<Self, PacketParseError> {
|
|
|
let mut byte = [0u8; 1];
|
|
|
let mut byte = [0u8; 1];
|
|
|
cur.read(&mut byte);
|
|
|
cur.read(&mut byte);
|
|
|
cur.seek(SeekFrom::Current(-1)); // Cursor doesn't implement Peek?
|
|
|
cur.seek(SeekFrom::Current(-1)); // Cursor doesn't implement Peek?
|
|
|
match byte[0] {
|
|
|
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),
|
|
|
_ => Err(PacketParseError::WrongPacketCommand),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
fn as_bytes(&self) -> Vec<u8> {
|
|
|
fn as_bytes(&self) -> Vec<u8> {
|
|
|
Vec::new()
|
|
|
|
|
|
|
|
|
match self {
|
|
|
|
|
|
GameMessage::PlayerWalking(data) => data.as_bytes(),
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|