|
@ -30,6 +30,7 @@ pub enum CharacterError { |
|
|
pub enum RecvCharacterPacket {
|
|
|
pub enum RecvCharacterPacket {
|
|
|
Login(Login),
|
|
|
Login(Login),
|
|
|
RequestSettings(RequestSettings),
|
|
|
RequestSettings(RequestSettings),
|
|
|
|
|
|
CharSelect(CharSelect)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl RecvServerPacket for RecvCharacterPacket {
|
|
|
impl RecvServerPacket for RecvCharacterPacket {
|
|
@ -37,6 +38,7 @@ impl RecvServerPacket for RecvCharacterPacket { |
|
|
match data[2] {
|
|
|
match data[2] {
|
|
|
0x93 => Ok(RecvCharacterPacket::Login(Login::from_bytes(data)?)),
|
|
|
0x93 => Ok(RecvCharacterPacket::Login(Login::from_bytes(data)?)),
|
|
|
0xE0 => Ok(RecvCharacterPacket::RequestSettings(RequestSettings::from_bytes(data)?)),
|
|
|
0xE0 => Ok(RecvCharacterPacket::RequestSettings(RequestSettings::from_bytes(data)?)),
|
|
|
|
|
|
0xE3 => Ok(RecvCharacterPacket::CharSelect(CharSelect::from_bytes(data)?)),
|
|
|
_ => Err(PacketParseError::WrongPacketForServerType)
|
|
|
_ => Err(PacketParseError::WrongPacketForServerType)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -102,6 +104,10 @@ impl<DA: DataAccess> CharacterServerState<DA> { |
|
|
|
|
|
|
|
|
vec![pkt]
|
|
|
vec![pkt]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn char_select(&mut self) -> Vec<SendCharacterPacket> {
|
|
|
|
|
|
Vec::new()
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<DA: DataAccess> ServerState for CharacterServerState<DA> {
|
|
|
impl<DA: DataAccess> ServerState for CharacterServerState<DA> {
|
|
@ -130,15 +136,14 @@ impl<DA: DataAccess> ServerState for CharacterServerState<DA> { |
|
|
},
|
|
|
},
|
|
|
RecvCharacterPacket::RequestSettings(_req) => {
|
|
|
RecvCharacterPacket::RequestSettings(_req) => {
|
|
|
Box::new(self.get_settings().into_iter())
|
|
|
Box::new(self.get_settings().into_iter())
|
|
|
|
|
|
},
|
|
|
|
|
|
RecvCharacterPacket::CharSelect(sel) => {
|
|
|
|
|
|
Box::new(self.char_select().into_iter())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn new_client<DA: DataAccess + 'static>(socket: mio::tcp::TcpStream, shared_state: SharedLoginState<DA>) {
|
|
|
pub fn new_client<DA: DataAccess + 'static>(socket: mio::tcp::TcpStream, shared_state: SharedLoginState<DA>) {
|
|
|
let state = CharacterServerState::new(shared_state);
|
|
|
let state = CharacterServerState::new(shared_state);
|
|
|
let client = Client::new(socket, Box::new(state));
|
|
|
let client = Client::new(socket, Box::new(state));
|
|
@ -153,10 +158,6 @@ mod test { |
|
|
use libpso::character::settings;
|
|
|
use libpso::character::settings;
|
|
|
use std::time::SystemTime;
|
|
|
use std::time::SystemTime;
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn test_login() {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn test_option_send() {
|
|
|
fn test_option_send() {
|
|
|
struct TestData {
|
|
|
struct TestData {
|
|
@ -192,5 +193,4 @@ mod test { |
|
|
assert!(bytes[2] == 0xE2);
|
|
|
assert!(bytes[2] == 0xE2);
|
|
|
assert!(bytes.len() == 0xAFC);
|
|
|
assert!(bytes.len() == 0xAFC);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|