Browse Source

send keyconfig to user on connection

pbs
jake 5 years ago
parent
commit
daad33ed1e
  1. 12
      src/ship/ship.rs

12
src/ship/ship.rs

@ -13,7 +13,7 @@ use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
use crate::entity::gateway::EntityGateway;
use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use crate::entity::account::{UserAccount, UserSettings, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use crate::entity::character::Character;
use crate::login::login::get_login_status;
use crate::ship::location::ClientLocation;
@ -71,6 +71,7 @@ impl SendServerPacket for SendShipPacket {
struct ClientState {
user: Option<UserAccount>,
settings: Option<UserSettings>,
character: Character,
session: Session,
block: u32,
@ -81,6 +82,7 @@ impl ClientState {
fn new() -> ClientState {
ClientState {
user: None,
settings: None,
character: Character::default(),
session: Session::new(),
block: 0,
@ -117,6 +119,8 @@ impl<EG: EntityGateway> ShipServerState<EG> {
.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);
client.settings = Some(self.entity_gateway.get_user_settings_by_user(&client.user.as_ref().unwrap())
.ok_or(ShipError::ClientNotFound(id))?);
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(3))]
},
Err(err) => {
@ -127,10 +131,13 @@ impl<EG: EntityGateway> ShipServerState<EG> {
fn block_selected(&mut self, id: ClientId, pkt: &MenuSelect) -> Result<Vec<SendShipPacket>, ShipError> {
let client = self.clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
let settings = client.settings.as_ref().ok_or(ShipError::ClientNotFound(id))?.settings;
client.block = pkt.item as u32;
let mut fc = character::FullCharacter::default();
fc.character = client.character.character;
fc.key_team_config.key_config = settings.key_config;
fc.key_team_config.joystick_config = settings.joystick_config;
Ok(vec![
SendShipPacket::FullCharacter(FullCharacter {
@ -142,9 +149,6 @@ impl<EG: EntityGateway> ShipServerState<EG> {
fn send_player_to_lobby(&mut self, id: ClientId, pkt: &CharData) -> Result<Vec<SendShipPacket>, ShipError> {
let mut c = character::Character::default();
c.hp = 1000;
c.atp = 1100;
c.lck = 1200;
let joinlobby = JoinLobby {
client: 0,
leader: 0,

Loading…
Cancel
Save