From fcccba9554d159e81a6669e8aa3736775ddb20c3 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 22 Apr 2022 00:31:46 +0000 Subject: [PATCH 1/3] guildcard structs and repr(c) cus the compiler hates me --- src/character/guildcard.rs | 135 +++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/src/character/guildcard.rs b/src/character/guildcard.rs index 054ad0c..31e378c 100644 --- a/src/character/guildcard.rs +++ b/src/character/guildcard.rs @@ -1,53 +1,22 @@ - - -/* -typedef struct bb_guildcard_data { - uint8_t unk1[0x0114]; - struct { - uint32_t guildcard; - uint16_t name[0x18]; - uint16_t team[0x10]; - uint16_t desc[0x58]; - uint8_t reserved1; - uint8_t language; - uint8_t section; - uint8_t ch_class; - } blocked[29]; - uint8_t unk2[0x78]; - struct { - uint32_t guildcard; - uint16_t name[0x18]; - uint16_t team[0x10]; - uint16_t desc[0x58]; - uint8_t reserved1; - uint8_t language; - uint8_t section; - uint8_t ch_class; - uint32_t padding; - uint16_t comment[0x58]; - } entries[104]; - uint8_t unk3[0x01BC]; -} bb_gc_data_t; - */ - - - -#[derive(Copy, Clone)] -pub struct BlockedGuildCard { - pub guildcard: u32, - pub name: [u16; 0x18], - pub team: [u16; 0x10], - pub desc: [u16; 0x58], - pub reserved1: u8, - pub language: u8, - pub section_id: u8, - pub class: u8, +use crate::packet::ship::{GuildcardAccept}; + +#[derive(Copy, Clone, Debug)] +#[repr(C)] +pub struct BlockedGuildCard { // 264 + pub id: u32, // 4 + pub name: [u16; 0x18], // 48 + pub team: [u16; 0x10], // 32 + pub desc: [u16; 0x58], // 176 + pub reserved1: u8, // 1 + pub language: u8, // 1 + pub section_id: u8, // 1 + pub class: u8, // 1 } impl Default for BlockedGuildCard { fn default() -> BlockedGuildCard { BlockedGuildCard { - guildcard: 0, + id: 0, name: [0; 0x18], team: [0; 0x10], desc: [0; 0x58], @@ -59,25 +28,41 @@ impl Default for BlockedGuildCard { } } -#[derive(Copy, Clone)] -pub struct GuildCard { - pub guildcard: u32, - pub name: [u16; 0x18], - pub team: [u16; 0x10], - pub desc: [u16; 0x58], - pub reserved1: u8, - pub language: u8, - pub section_id: u8, - pub class: u8, - pub padding: u32, - pub comment: [u16; 0x58], +impl From for BlockedGuildCard { + fn from(g: GuildCard) -> BlockedGuildCard { + BlockedGuildCard { + id: g.id, + name: g.name, + team: g.team, + desc: g.desc, + reserved1: g.reserved1, + language: g.language, + section_id: g.section_id, + class: g.class, + } + } +} + +#[derive(Copy, Clone, Debug)] +#[repr(C)] +pub struct GuildCard { // 444 + pub id: u32, // 4 + pub name: [u16; 0x18], // 48 + pub team: [u16; 0x10], // 32 + pub desc: [u16; 0x58], // 176 + pub reserved1: u8, // 1 + pub language: u8, // 1 + pub section_id: u8, // 1 + pub class: u8, // 1 + pub padding: u32, // 4 + pub comment: [u16; 0x58], // 176 } impl Default for GuildCard { fn default() -> GuildCard { GuildCard { - guildcard: 0, + id: 0, name: [0; 0x18], team: [0; 0x10], desc: [0; 0x58], @@ -91,13 +76,30 @@ impl Default for GuildCard { } } -#[derive(Copy, Clone)] -pub struct GuildCardData { - pub _unknown1: [u8; 0x114], - pub blocked: [BlockedGuildCard; 29], - pub _unknown2: [u8; 0x78], - pub friends: [GuildCard; 104], - pub _unknown3: [u8; 0x1BC], +impl From<&GuildcardAccept> for GuildCard { + fn from(g: &GuildcardAccept) -> GuildCard { + GuildCard { + id: g.id, + name: g.name, + team: g.team, + desc: g.desc, + reserved1: g.one, + language: g.language, + section_id: g.section_id, + class: g.class, + padding: 0, + comment: [0; 0x58], + } + } +} + +#[derive(Copy, Clone, Debug)] +#[repr(C)] +pub struct GuildCardData { // 54672 0xd590 + pub _unknown1: [u8; 0x114], // 276 + pub blocked: [BlockedGuildCard; 29], // 264 * 29 = 7656 + pub _unknown2: [u8; 0x78], // 120 + pub friends: [GuildCard; 105], // 444 * 105 = 46620 } impl Default for GuildCardData { @@ -106,8 +108,7 @@ impl Default for GuildCardData { _unknown1: [0; 0x114], blocked: [BlockedGuildCard::default(); 29], _unknown2: [0; 0x78], - friends: [GuildCard::default(); 104], - _unknown3: [0; 0x1BC], + friends: [GuildCard::default(); 105], } } } -- 2.36.0 From c9aaa3846594c3186039c0064ddc650c31d7f808 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 22 Apr 2022 00:34:00 +0000 Subject: [PATCH 2/3] 0x for hexes --- src/packet/login.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packet/login.rs b/src/packet/login.rs index 40a47ad..ba0e8b2 100644 --- a/src/packet/login.rs +++ b/src/packet/login.rs @@ -386,9 +386,9 @@ impl std::fmt::Debug for GuildcardDataChunk { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "packet GuildcardDataChunk {{\n").unwrap(); write!(f, " flag: {:?}\n", 0).unwrap(); - write!(f, " _unknown: {:X?}\n", self._unknown).unwrap(); - write!(f, " chunk: {:X?}\n", self.chunk).unwrap(); - write!(f, " buffer: [0..{:X}]\n", self.len).unwrap(); + write!(f, " _unknown: {:#X?}\n", self._unknown).unwrap(); + write!(f, " chunk: {:#X?}\n", self.chunk).unwrap(); + write!(f, " buffer: [0..{:#X}]\n", self.len).unwrap(); write!(f, "}}") } } -- 2.36.0 From 0b80a107bd76a6b8747b5b6d0bd9ccf81240068e Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 22 Apr 2022 00:35:01 +0000 Subject: [PATCH 3/3] GuildcardRecv struct --- src/packet/ship.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/packet/ship.rs b/src/packet/ship.rs index d65153f..0995449 100644 --- a/src/packet/ship.rs +++ b/src/packet/ship.rs @@ -644,4 +644,17 @@ pub struct KeyboardConfig { #[pso_packet(0x5ED)] pub struct GamepadConfig { pub gamepad_config: [u8; 56], -} \ No newline at end of file +} + +// same struct as libpso::packet::messages::GuildcardRecv +#[pso_packet(0x4E8)] +pub struct GuildcardAccept { + id: u32, + name: [u16; 0x18], + team: [u16; 0x10], + desc: [u16; 0x58], + one: u8, + language: u8, + section_id: u8, + class: u8, +} -- 2.36.0