From 4fae76928def3b0467add2d21f525913fa3988ef Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Sun, 19 Apr 2020 23:16:44 -0300 Subject: [PATCH 1/5] add default palette and symbol chats --- src/entity/character.rs | 3 ++- src/ship/character.rs | 11 +++++++++++ src/ship/ship.rs | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/entity/character.rs b/src/entity/character.rs index fe0072e..45b8624 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -2,6 +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 crate::entity::item::tech::Technique; use crate::entity::account::UserAccountId; @@ -189,7 +190,7 @@ pub struct CharacterConfig { impl CharacterConfig { fn new() -> CharacterConfig { CharacterConfig { - raw_data: [0; 0xE8], + raw_data: Character::default().config, } } diff --git a/src/ship/character.rs b/src/ship/character.rs index 8be687c..8df27a8 100644 --- a/src/ship/character.rs +++ b/src/ship/character.rs @@ -82,6 +82,7 @@ pub struct FullCharacterBytesBuilder<'a> { inventory: Option<&'a ActiveInventory>, key_config: Option<&'a [u8; 0x16C]>, joystick_config: Option<&'a [u8; 0x38]>, + symbol_chat: Option<&'a [u8; 1248]>, } @@ -94,6 +95,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { inventory: None, key_config: None, joystick_config: None, + symbol_chat: None, } } @@ -139,6 +141,13 @@ impl<'a> FullCharacterBytesBuilder<'a> { } } + pub fn symbol_chat(self, symbol_chat: &'a [u8; 1248]) -> FullCharacterBytesBuilder<'a> { + FullCharacterBytesBuilder { + symbol_chat: Some(symbol_chat), + ..self + } + } + pub fn build(self) -> character::FullCharacter { let character = self.character.unwrap(); @@ -147,6 +156,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { let inventory = self.inventory.unwrap(); let key_config = self.key_config.unwrap(); let joystick_config = self.joystick_config.unwrap(); + let symbol_chat = self.symbol_chat.unwrap(); character::FullCharacter { character: CharacterBytesBuilder::new() @@ -165,6 +175,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { ..character::KeyTeamConfig::default() }, info_board: character.info_board.as_bytes(), + symbol_chats: *symbol_chat, ..character::FullCharacter::default() } } diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 3ed4285..e611d02 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -220,6 +220,7 @@ impl ShipServerState { .inventory(&client.inventory) .key_config(&client.settings.settings.key_config) .joystick_config(&client.settings.settings.joystick_config) + .symbol_chat(&client.settings.settings.symbol_chats) .build(); Ok(vec![ From ff2ae85299f909c5d23b746aede72625caba6440 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Sun, 19 Apr 2020 23:37:48 -0300 Subject: [PATCH 2/5] add mag colors --- src/entity/item/mag.rs | 8 ++++---- src/login/character.rs | 1 + src/ship/drops/rare_drop_table.rs | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/entity/item/mag.rs b/src/entity/item/mag.rs index fc9fc5e..1c01392 100644 --- a/src/entity/item/mag.rs +++ b/src/entity/item/mag.rs @@ -184,7 +184,7 @@ pub struct Mag { pub synchro: u8, pub iq: u8, pub photon_blast: [Option; 3], - // color + pub color: u8, } @@ -197,10 +197,10 @@ impl Mag { result[6..8].copy_from_slice(&self.pow.to_le_bytes()); result[8..10].copy_from_slice(&self.dex.to_le_bytes()); result[10..12].copy_from_slice(&self.mnd.to_le_bytes()); - //result[12] = color - result[14] = self.photon_blast_count(); - result[13] = self.iq; result[12] = self.synchro; + result[13] = self.iq; + result[14] = self.photon_blast_count(); + result[15] = self.color; result } diff --git a/src/login/character.rs b/src/login/character.rs index 74a462e..4da83b4 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -250,6 +250,7 @@ fn new_character(entity_gateway: &mut EG, user: &UserAccountE synchro: 20, iq: 0, photon_blast: [None; 3], + color: character.appearance.costume as u8, }), location: ItemLocation::Inventory { character_id: character.id, diff --git a/src/ship/drops/rare_drop_table.rs b/src/ship/drops/rare_drop_table.rs index 04fa477..56d564c 100644 --- a/src/ship/drops/rare_drop_table.rs +++ b/src/ship/drops/rare_drop_table.rs @@ -143,6 +143,7 @@ impl RareDropTable { iq: 0, synchro: 20, photon_blast: [None; 3], + color: rng.gen_range(0, 18), }) } } From 37b19ef3ade99f1c2bb96b02258a476a1529a605 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Mon, 20 Apr 2020 00:29:23 -0300 Subject: [PATCH 3/5] 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![ From d978d671a29b3dce62632bb33b458e51140ec5a0 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Mon, 20 Apr 2020 00:42:29 -0300 Subject: [PATCH 4/5] dont build huge things we aren't bob the builder --- src/entity/character.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/entity/character.rs b/src/entity/character.rs index f4c51af..5d898b0 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, FullCharacter}; +use libpso::character::character::{DEFAULT_PALETTE_CONFIG, DEFAULT_TECH_MENU}; use crate::entity::item::tech::Technique; use crate::entity::account::UserAccountId; @@ -190,7 +190,7 @@ pub struct CharacterConfig { impl CharacterConfig { fn new() -> CharacterConfig { CharacterConfig { - raw_data: Character::default().config, + raw_data: DEFAULT_PALETTE_CONFIG, } } @@ -237,7 +237,7 @@ pub struct CharacterTechMenu { impl CharacterTechMenu { fn new() -> CharacterTechMenu { CharacterTechMenu { - tech_menu: FullCharacter::default().tech_menu, + tech_menu: DEFAULT_TECH_MENU, } } From ffd782ccce441f92fbafd3d0214152b628e19bba Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Mon, 20 Apr 2020 01:22:07 -0300 Subject: [PATCH 5/5] use skin, not costume, for mag colors --- src/login/character.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/login/character.rs b/src/login/character.rs index 4da83b4..ea291fe 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -250,7 +250,7 @@ fn new_character(entity_gateway: &mut EG, user: &UserAccountE synchro: 20, iq: 0, photon_blast: [None; 3], - color: character.appearance.costume as u8, + color: (character.appearance.skin % 18) as u8, }), location: ItemLocation::Inventory { character_id: character.id,