From daad33ed1e796b67a25d8eadf5ec68de0308f868 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 23 Nov 2019 21:05:10 -0800 Subject: [PATCH] send keyconfig to user on connection --- src/ship/ship.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 57e35d3..a02cb83 100644 --- a/src/ship/ship.rs +++ b/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, + settings: Option, 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 ShipServerState { .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 ShipServerState { fn block_selected(&mut self, id: ClientId, pkt: &MenuSelect) -> Result, 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 ShipServerState { fn send_player_to_lobby(&mut self, id: ClientId, pkt: &CharData) -> Result, ShipError> { let mut c = character::Character::default(); - c.hp = 1000; - c.atp = 1100; - c.lck = 1200; let joinlobby = JoinLobby { client: 0, leader: 0,