jake
5 years ago
4 changed files with 211 additions and 1 deletions
@ -0,0 +1,45 @@ |
|||
use std::io::{Seek, SeekFrom};
|
|||
|
|||
use psopacket::pso_message;
|
|||
use crate::{PSOPacketData, PacketParseError};
|
|||
|
|||
|
|||
pub trait PSOMessage {
|
|||
const CMD: u8;
|
|||
fn from_bytes<R: std::io::Read + std::io::Seek>(cur: &mut R) -> Result<Self, PacketParseError> where Self: Sized;
|
|||
fn as_bytes(&self) -> Vec<u8>;
|
|||
}
|
|||
|
|||
|
|||
#[pso_message(0x40)]
|
|||
pub struct PlayerWalking {
|
|||
x: f32,
|
|||
y: f32,
|
|||
z: f32,
|
|||
}
|
|||
|
|||
|
|||
|
|||
pub enum Message {
|
|||
PlayerWalking(PlayerWalking),
|
|||
}
|
|||
|
|||
impl PSOPacketData for Message {
|
|||
fn from_bytes<R: std::io::Read + std::io::Seek>(mut cur: &mut R) -> Result<Self, PacketParseError> {
|
|||
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)?)),
|
|||
_ => Err(PacketParseError::WrongPacketCommand),
|
|||
}
|
|||
}
|
|||
fn as_bytes(&self) -> Vec<u8> {
|
|||
Vec::new()
|
|||
}
|
|||
}
|
|||
|
|||
|
|||
|
|||
|
|||
|
@ -1,3 +1,4 @@ |
|||
pub mod login;
|
|||
pub mod patch;
|
|||
pub mod ship;
|
|||
pub mod messages;
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue