|
@ -22,6 +22,8 @@ pub const SHIP_PORT: u16 = 23423; |
|
|
#[derive(Debug)]
|
|
|
#[derive(Debug)]
|
|
|
pub enum ShipError {
|
|
|
pub enum ShipError {
|
|
|
ClientNotFound(ClientId),
|
|
|
ClientNotFound(ClientId),
|
|
|
|
|
|
NoCharacterInSlot(ClientId, u32),
|
|
|
|
|
|
InvalidSlot(ClientId, u32),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
#[derive(Debug)]
|
|
@ -68,7 +70,7 @@ impl SendServerPacket for SendShipPacket { |
|
|
|
|
|
|
|
|
struct ClientState {
|
|
|
struct ClientState {
|
|
|
user: Option<UserAccount>,
|
|
|
user: Option<UserAccount>,
|
|
|
characters: Option<[Option<Character>; 4]>,
|
|
|
|
|
|
|
|
|
character: Character,
|
|
|
session: Session,
|
|
|
session: Session,
|
|
|
block: u32,
|
|
|
block: u32,
|
|
|
}
|
|
|
}
|
|
@ -77,7 +79,7 @@ impl ClientState { |
|
|
fn new() -> ClientState {
|
|
|
fn new() -> ClientState {
|
|
|
ClientState {
|
|
|
ClientState {
|
|
|
user: None,
|
|
|
user: None,
|
|
|
characters: None,
|
|
|
|
|
|
|
|
|
character: Character::default(),
|
|
|
session: Session::new(),
|
|
|
session: Session::new(),
|
|
|
block: 0,
|
|
|
block: 0,
|
|
|
}
|
|
|
}
|
|
@ -105,8 +107,14 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
|
|
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
|
|
response.guildcard = user.guildcard.map_or(24, |gc| gc) as u32;
|
|
|
response.guildcard = user.guildcard.map_or(24, |gc| gc) as u32;
|
|
|
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
|
|
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
|
|
client.user = Some(user);
|
|
|
|
|
|
client.session = pkt.session;
|
|
|
client.session = pkt.session;
|
|
|
|
|
|
println!("SESSION {:?}", client.session);
|
|
|
|
|
|
let characters = self.entity_gateway.get_characters_by_user(&user);
|
|
|
|
|
|
client.character = characters
|
|
|
|
|
|
.get(pkt.session.character_slot as usize)
|
|
|
|
|
|
.ok_or(ShipError::InvalidSlot(id, pkt.session.character_slot as u32))?
|
|
|
|
|
|
.ok_or(ShipError::NoCharacterInSlot(id, pkt.session.character_slot as u32))?;
|
|
|
|
|
|
client.user = Some(user);
|
|
|
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(3))]
|
|
|
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(3))]
|
|
|
},
|
|
|
},
|
|
|
Err(err) => {
|
|
|
Err(err) => {
|
|
@ -120,11 +128,8 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
client.block = pkt.item as u32;
|
|
|
client.block = pkt.item as u32;
|
|
|
|
|
|
|
|
|
let mut fc = character::FullCharacter::default();
|
|
|
let mut fc = character::FullCharacter::default();
|
|
|
fc.character.hp = 4000;
|
|
|
|
|
|
fc.character.atp = 1200;
|
|
|
|
|
|
fc.character.lck = 1300;
|
|
|
|
|
|
|
|
|
fc.character = client.character.character;
|
|
|
|
|
|
|
|
|
//Ok(Vec::new())
|
|
|
|
|
|
Ok(vec![
|
|
|
Ok(vec![
|
|
|
SendShipPacket::FullCharacter(FullCharacter {
|
|
|
SendShipPacket::FullCharacter(FullCharacter {
|
|
|
character: fc,
|
|
|
character: fc,
|
|
|