|
@ -213,7 +213,6 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
fn send_ship_list(&mut self, _id: ClientId, _pkt: &Login) -> Result<Vec<SendCharacterPacket>, CharacterError> {
|
|
|
fn send_ship_list(&mut self, _id: ClientId, _pkt: &Login) -> Result<Vec<SendCharacterPacket>, CharacterError> {
|
|
|
Ok(vec![SendCharacterPacket::Timestamp(Timestamp::new(chrono::Utc::now())),
|
|
|
Ok(vec![SendCharacterPacket::Timestamp(Timestamp::new(chrono::Utc::now())),
|
|
|
SendCharacterPacket::ShipList(ShipList {
|
|
|
SendCharacterPacket::ShipList(ShipList {
|
|
|
flag: 0,
|
|
|
|
|
|
ships: self.ships.iter().enumerate().map(|(i, s)| {
|
|
|
ships: self.ships.iter().enumerate().map(|(i, s)| {
|
|
|
ShipListEntry {
|
|
|
ShipListEntry {
|
|
|
menu: SHIP_MENU_ID,
|
|
|
menu: SHIP_MENU_ID,
|
|
@ -252,14 +251,12 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
let chars = client.characters.as_ref().unwrap();
|
|
|
let chars = client.characters.as_ref().unwrap();
|
|
|
Ok(if let Some(char) = &chars[select.slot as usize] {
|
|
|
Ok(if let Some(char) = &chars[select.slot as usize] {
|
|
|
vec![SendCharacterPacket::CharacterPreview(CharacterPreview {
|
|
|
vec![SendCharacterPacket::CharacterPreview(CharacterPreview {
|
|
|
flag: 0,
|
|
|
|
|
|
slot: select.slot,
|
|
|
slot: select.slot,
|
|
|
character: char.character.as_select_screen(),
|
|
|
character: char.character.as_select_screen(),
|
|
|
})]
|
|
|
})]
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
else {
|
|
|
vec![SendCharacterPacket::CharAck(CharAck {
|
|
|
vec![SendCharacterPacket::CharAck(CharAck {
|
|
|
flag: 0,
|
|
|
|
|
|
slot: select.slot,
|
|
|
slot: select.slot,
|
|
|
code: 2,
|
|
|
code: 2,
|
|
|
})]
|
|
|
})]
|
|
@ -274,7 +271,6 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
user.team_id.unwrap_or(1),
|
|
|
user.team_id.unwrap_or(1),
|
|
|
client.security_data)),
|
|
|
client.security_data)),
|
|
|
SendCharacterPacket::CharAck(CharAck {
|
|
|
SendCharacterPacket::CharAck(CharAck {
|
|
|
flag: 0,
|
|
|
|
|
|
slot: select.slot,
|
|
|
slot: select.slot,
|
|
|
code: 1,
|
|
|
code: 1,
|
|
|
})
|
|
|
})
|
|
@ -284,7 +280,6 @@ impl<EG: EntityGateway> CharacterServerState<EG> { |
|
|
|
|
|
|
|
|
fn validate_checksum(&mut self) -> Vec<SendCharacterPacket> {
|
|
|
fn validate_checksum(&mut self) -> Vec<SendCharacterPacket> {
|
|
|
vec![SendCharacterPacket::ChecksumAck(ChecksumAck {
|
|
|
vec![SendCharacterPacket::ChecksumAck(ChecksumAck {
|
|
|
flag: 0,
|
|
|
|
|
|
ack: 1,
|
|
|
ack: 1,
|
|
|
})]
|
|
|
})]
|
|
|
}
|
|
|
}
|
|
@ -398,7 +393,6 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> { |
|
|
|
|
|
|
|
|
Box::new(vec![SendCharacterPacket::ParamDataChunk(
|
|
|
Box::new(vec![SendCharacterPacket::ParamDataChunk(
|
|
|
ParamDataChunk {
|
|
|
ParamDataChunk {
|
|
|
flag: 0,
|
|
|
|
|
|
chunk: chunk as u32,
|
|
|
chunk: chunk as u32,
|
|
|
data: data,
|
|
|
data: data,
|
|
|
}
|
|
|
}
|
|
@ -432,7 +426,6 @@ impl<EG: EntityGateway> ServerState for CharacterServerState<EG> { |
|
|
user.team_id.unwrap_or(1),
|
|
|
user.team_id.unwrap_or(1),
|
|
|
client.security_data)),
|
|
|
client.security_data)),
|
|
|
SendCharacterPacket::CharAck(CharAck {
|
|
|
SendCharacterPacket::CharAck(CharAck {
|
|
|
flag: 0,
|
|
|
|
|
|
slot: preview.slot,
|
|
|
slot: preview.slot,
|
|
|
code: 0
|
|
|
code: 0
|
|
|
})
|
|
|
})
|
|
@ -482,7 +475,7 @@ mod test { |
|
|
});
|
|
|
});
|
|
|
server.clients.insert(ClientId(5), clientstate);
|
|
|
server.clients.insert(ClientId(5), clientstate);
|
|
|
|
|
|
|
|
|
let send = server.handle(ClientId(5), &RecvCharacterPacket::RequestSettings(RequestSettings {flag: 0}))
|
|
|
|
|
|
|
|
|
let send = server.handle(ClientId(5), &RecvCharacterPacket::RequestSettings(RequestSettings{}))
|
|
|
.unwrap()
|
|
|
.unwrap()
|
|
|
.collect::<Vec<_>>();
|
|
|
.collect::<Vec<_>>();
|
|
|
assert!(send.len() == 1);
|
|
|
assert!(send.len() == 1);
|
|
@ -498,8 +491,7 @@ mod test { |
|
|
struct TestData;
|
|
|
struct TestData;
|
|
|
impl EntityGateway for TestData {}
|
|
|
impl EntityGateway for TestData {}
|
|
|
let mut server = CharacterServerState::new(TestData {});
|
|
|
let mut server = CharacterServerState::new(TestData {});
|
|
|
let send = server.handle(ClientId(1), &RecvCharacterPacket::Checksum(Checksum {flag: 0,
|
|
|
|
|
|
checksum: 1234,
|
|
|
|
|
|
|
|
|
let send = server.handle(ClientId(1), &RecvCharacterPacket::Checksum(Checksum {checksum: 1234,
|
|
|
padding: 0,
|
|
|
padding: 0,
|
|
|
})).unwrap().collect::<Vec<_>>();
|
|
|
})).unwrap().collect::<Vec<_>>();
|
|
|
assert!(send.len() == 1);
|
|
|
assert!(send.len() == 1);
|
|
|