You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.4 KiB

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 {
id: 0,
name: [0; 0x18],
team: [0; 0x10],
desc: [0; 0x58],
reserved1: 0,
language: 0,
section_id: 0,
class: 0,
}
}
}
impl From<GuildCard> 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 {
id: 0,
name: [0; 0x18],
team: [0; 0x10],
desc: [0; 0x58],
reserved1: 0,
language: 0,
section_id: 0,
class: 0,
padding: 0,
comment: [0; 0x58],
}
}
}
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 {
fn default() -> GuildCardData {
GuildCardData {
_unknown1: [0; 0x114],
blocked: [BlockedGuildCard::default(); 29],
_unknown2: [0; 0x78],
friends: [GuildCard::default(); 105],
}
}
}
impl GuildCardData {
pub fn from_bytes(bytes: [u8; 0xD590]) -> GuildCardData {
unsafe {
std::mem::transmute(bytes)
}
}
pub fn as_bytes(&self) -> [u8; 0xD590] {
unsafe {
std::mem::transmute(*self)
}
}
}
#[cfg(test)]
mod tests {
#[test]
fn guildcard_default_zero() {
let gc = super::GuildCardData::default();
let bytes = gc.as_bytes();
for k in bytes.iter() {
assert!(*k == 0);
}
}
}