|
@ -15,21 +15,25 @@ pub async fn validate_login<EG: EntityGateway>(id: ClientId, |
|
|
-> Result<Vec<SendShipPacket>, ShipError> {
|
|
|
-> Result<Vec<SendShipPacket>, ShipError> {
|
|
|
Ok(match get_login_status(entity_gateway, pkt).await {
|
|
|
Ok(match get_login_status(entity_gateway, pkt).await {
|
|
|
Ok(user) => {
|
|
|
Ok(user) => {
|
|
|
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
|
|
|
|
|
response.guildcard = user.id.0 as u32;
|
|
|
|
|
|
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
|
|
|
|
|
let characters = entity_gateway.get_characters_by_user(&user).await;
|
|
|
|
|
|
let character = characters
|
|
|
|
|
|
.get(pkt.session.character_slot as usize)
|
|
|
|
|
|
.ok_or(ShipError::InvalidSlot(id, pkt.session.character_slot as u32))?.as_ref()
|
|
|
|
|
|
.ok_or(ShipError::NoCharacterInSlot(id, pkt.session.character_slot as u32))?
|
|
|
|
|
|
.clone();
|
|
|
|
|
|
let settings = entity_gateway.get_user_settings_by_user(&user).await
|
|
|
|
|
|
.ok_or(ShipError::ClientNotFound(id))?;
|
|
|
|
|
|
|
|
|
if user.activated {
|
|
|
|
|
|
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
|
|
|
|
|
response.guildcard = user.id.0 as u32;
|
|
|
|
|
|
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
|
|
|
|
|
let characters = entity_gateway.get_characters_by_user(&user).await?;
|
|
|
|
|
|
let character = characters
|
|
|
|
|
|
.get(pkt.session.character_slot as usize)
|
|
|
|
|
|
.ok_or(ShipError::InvalidSlot(id, pkt.session.character_slot as u32))?.as_ref()
|
|
|
|
|
|
.ok_or(ShipError::NoCharacterInSlot(id, pkt.session.character_slot as u32))?
|
|
|
|
|
|
.clone();
|
|
|
|
|
|
let settings = entity_gateway.get_user_settings_by_user(&user).await?;
|
|
|
|
|
|
|
|
|
item_manager.load_character(entity_gateway, &character).await;
|
|
|
|
|
|
clients.insert(id, ClientState::new(user, settings, character, pkt.session));
|
|
|
|
|
|
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(&&ship_name, 3))]
|
|
|
|
|
|
|
|
|
item_manager.load_character(entity_gateway, &character).await;
|
|
|
|
|
|
clients.insert(id, ClientState::new(user, settings, character, pkt.session));
|
|
|
|
|
|
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(&&ship_name, 3))]
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
vec![SendShipPacket::LoginResponse(LoginResponse::by_status(AccountStatus::Locked, Session::new()))]
|
|
|
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
Err(err) => {
|
|
|
Err(err) => {
|
|
|
vec![SendShipPacket::LoginResponse(LoginResponse::by_status(err, Session::new()))]
|
|
|
vec![SendShipPacket::LoginResponse(LoginResponse::by_status(err, Session::new()))]
|
|
|