From 37b19ef3ade99f1c2bb96b02258a476a1529a605 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Mon, 20 Apr 2020 00:29:23 -0300 Subject: [PATCH] make quick tech menu not all foie --- src/entity/character.rs | 24 +++++++++++++++++++++++- src/entity/gateway/inmemory.rs | 1 + src/ship/character.rs | 11 +++++++++++ src/ship/ship.rs | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/entity/character.rs b/src/entity/character.rs index 45b8624..f4c51af 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -2,7 +2,7 @@ use std::convert::{From, Into, TryFrom, TryInto}; use std::collections::HashMap; use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; -use libpso::character::character::{Character}; +use libpso::character::character::{Character, FullCharacter}; use crate::entity::item::tech::Technique; use crate::entity::account::UserAccountId; @@ -229,6 +229,23 @@ pub struct CharacterGuildCard { pub description: String, } +#[derive(Clone)] +pub struct CharacterTechMenu { + pub tech_menu: [u8; 40], +} + +impl CharacterTechMenu { + fn new() -> CharacterTechMenu { + CharacterTechMenu { + tech_menu: FullCharacter::default().tech_menu, + } + } + + pub fn as_bytes(&self) -> [u8; 40] { + self.tech_menu + } +} + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct CharacterEntityId(pub u32); @@ -249,6 +266,8 @@ pub struct NewCharacterEntity { pub config: CharacterConfig, pub info_board: CharacterInfoboard, pub guildcard: CharacterGuildCard, + + pub tech_menu: CharacterTechMenu, } impl NewCharacterEntity { @@ -265,6 +284,7 @@ impl NewCharacterEntity { config: CharacterConfig::new(), info_board: CharacterInfoboard::new(), guildcard: CharacterGuildCard::default(), + tech_menu: CharacterTechMenu::new(), } } } @@ -286,4 +306,6 @@ pub struct CharacterEntity { pub config: CharacterConfig, pub info_board: CharacterInfoboard, pub guildcard: CharacterGuildCard, + + pub tech_menu: CharacterTechMenu, } diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index 627433a..bbec553 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -123,6 +123,7 @@ impl EntityGateway for InMemoryGateway { config: character.config, info_board: character.info_board, guildcard: character.guildcard, + tech_menu: character.tech_menu, }; characters.insert(new_character.id, new_character.clone()); Some(new_character) diff --git a/src/ship/character.rs b/src/ship/character.rs index 8df27a8..f0771c2 100644 --- a/src/ship/character.rs +++ b/src/ship/character.rs @@ -83,6 +83,7 @@ pub struct FullCharacterBytesBuilder<'a> { key_config: Option<&'a [u8; 0x16C]>, joystick_config: Option<&'a [u8; 0x38]>, symbol_chat: Option<&'a [u8; 1248]>, + tech_menu: Option<&'a [u8; 40]>, } @@ -96,6 +97,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { key_config: None, joystick_config: None, symbol_chat: None, + tech_menu: None, } } @@ -148,6 +150,13 @@ impl<'a> FullCharacterBytesBuilder<'a> { } } + pub fn tech_menu(self, tech_menu: &'a [u8; 40]) -> FullCharacterBytesBuilder<'a> { + FullCharacterBytesBuilder { + tech_menu: Some(tech_menu), + ..self + } + } + pub fn build(self) -> character::FullCharacter { let character = self.character.unwrap(); @@ -157,6 +166,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { let key_config = self.key_config.unwrap(); let joystick_config = self.joystick_config.unwrap(); let symbol_chat = self.symbol_chat.unwrap(); + let tech_menu = self.tech_menu.unwrap(); character::FullCharacter { character: CharacterBytesBuilder::new() @@ -176,6 +186,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { }, info_board: character.info_board.as_bytes(), symbol_chats: *symbol_chat, + tech_menu: *tech_menu, ..character::FullCharacter::default() } } diff --git a/src/ship/ship.rs b/src/ship/ship.rs index e611d02..483e61c 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -221,6 +221,7 @@ impl ShipServerState { .key_config(&client.settings.settings.key_config) .joystick_config(&client.settings.settings.joystick_config) .symbol_chat(&client.settings.settings.symbol_chats) + .tech_menu(&client.character.tech_menu.as_bytes()) .build(); Ok(vec![