diff --git a/src/login/character.rs b/src/login/character.rs index 82a9e28..a268d1c 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -86,14 +86,14 @@ impl RecvServerPacket for RecvCharacterPacket { pub enum SendCharacterPacket { LoginResponse(LoginResponse), LoginWelcome(LoginWelcome), - SendKeyAndTeamSettings(SendKeyAndTeamSettings), + SendKeyAndTeamSettings(Box), CharAck(CharAck), ChecksumAck(ChecksumAck), CharacterPreview(CharacterPreview), GuildcardDataHeader(GuildcardDataHeader), GuildcardDataChunk(Box), ParamDataHeader(ParamDataHeader), - ParamDataChunk(ParamDataChunk), + ParamDataChunk(Box), Timestamp(Timestamp), ShipList(ShipList), RedirectClient(RedirectClient), @@ -285,10 +285,12 @@ async fn new_character(entity_gateway: &mut EG, user: &UserAc }; entity_gateway.set_character_inventory(&character.id, &inventory).await?; entity_gateway.set_character_bank(&character.id, &BankEntity::default(), BankName("".into())).await?; - let mut equipped = EquippedEntity::default(); - equipped.weapon = Some(weapon.id); - equipped.armor = Some(armor.id); - equipped.mag = Some(mag.id); + let equipped = EquippedEntity { + weapon: Some(weapon.id), + armor: Some(armor.id), + mag: Some(mag.id), + ..Default::default() + }; entity_gateway.set_character_equips(&character.id, &equipped).await?; Ok(()) } @@ -336,7 +338,7 @@ impl CharacterServerState { let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?; - self.connected_clients.insert(user.id.clone(), ConnectedClient { + self.connected_clients.insert(user.id, ConnectedClient { ship_id: None, expires: None, //Some(chrono::Utc::now() + chrono::Duration::minutes(1)), }); @@ -368,7 +370,7 @@ impl CharacterServerState { let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?; let user = client.user.as_ref().unwrap(); - let settings = match self.entity_gateway.get_user_settings_by_user(&user).await { + let settings = match self.entity_gateway.get_user_settings_by_user(user).await { Ok(settings) => settings, Err(_) => { let user_settings = NewUserSettingsEntity::new(user.id); @@ -378,7 +380,7 @@ impl CharacterServerState { let pkt = SendKeyAndTeamSettings::new(settings.settings.key_config, settings.settings.joystick_config, 0, 0); - let pkt = SendCharacterPacket::SendKeyAndTeamSettings(pkt); + let pkt = SendCharacterPacket::SendKeyAndTeamSettings(Box::new(pkt)); Ok(vec![pkt]) } @@ -396,7 +398,7 @@ impl CharacterServerState { vec![SendCharacterPacket::CharacterPreview(CharacterPreview { slot: select.slot, character: SelectScreenCharacterBuilder::new() - .character(&char) + .character(char) .level(level) .build() })] @@ -461,7 +463,7 @@ impl CharacterServerState { let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?; let mut user = client.user.as_mut().unwrap(); user.flags = setflag.flags; - self.entity_gateway.save_user(&user).await.unwrap(); + self.entity_gateway.save_user(user).await.unwrap(); Ok(None.into_iter()) } @@ -477,10 +479,10 @@ impl CharacterServerState { data[..end-start].copy_from_slice(&self.param_data[start..end]); Ok(vec![SendCharacterPacket::ParamDataChunk( - ParamDataChunk { + Box::new(ParamDataChunk { chunk: chunk as u32, data: data, - } + }) )]) } @@ -490,7 +492,7 @@ impl CharacterServerState { let client = self.clients.get_mut(&id).ok_or(CharacterError::ClientNotFound(id))?; let mut user = client.user.as_mut().unwrap(); if user.flags == USERFLAG_NEWCHAR { - new_character(&mut self.entity_gateway, &user, preview).await? + new_character(&mut self.entity_gateway, user, preview).await? } if user.flags == USERFLAG_DRESSINGROOM { // TODO: dressing room stuff @@ -499,7 +501,7 @@ impl CharacterServerState { client.session.action = SessionAction::SelectCharacter; client.session.character_slot = preview.slot as u8; user.flags = 0; - self.entity_gateway.save_user(&user).await.unwrap(); + self.entity_gateway.save_user(user).await.unwrap(); Ok(vec![SendCharacterPacket::LoginResponse(LoginResponse::by_char_select(user.guildcard, user.team_id.unwrap_or(1), client.session)), @@ -512,7 +514,7 @@ impl CharacterServerState { fn select_ship(&mut self, id: ClientId, menuselect: &MenuSelect) -> Result, anyhow::Error> { if menuselect.menu != SHIP_MENU_ID { - Err(CharacterError::InvalidMenuSelection(menuselect.menu, menuselect.item))?; + return Err(CharacterError::InvalidMenuSelection(menuselect.menu, menuselect.item).into()); } if let Some(client) = self.clients.get(&id) { diff --git a/src/login/login.rs b/src/login/login.rs index 6c0277b..f6ef7c4 100644 --- a/src/login/login.rs +++ b/src/login/login.rs @@ -102,7 +102,7 @@ impl LoginServerState { pub fn new(entity_gateway: EG, character_server_ip: net::Ipv4Addr) -> LoginServerState { LoginServerState { entity_gateway: entity_gateway, - character_server_ip: character_server_ip.into(), + character_server_ip: character_server_ip, clients: HashMap::new(), } } diff --git a/src/login/mod.rs b/src/login/mod.rs index 090d544..a5b3370 100644 --- a/src/login/mod.rs +++ b/src/login/mod.rs @@ -1,2 +1,3 @@ +#[allow(clippy::module_inception)] pub mod login; -pub mod character; \ No newline at end of file +pub mod character;