From fba46dd0d85b6b06abfa10f0c6dbd9fc6ee5bf90 Mon Sep 17 00:00:00 2001 From: jake Date: Tue, 25 Oct 2022 23:44:48 -0600 Subject: [PATCH] send better guildcard number --- src/entity/account.rs | 6 ++++++ src/ship/packet/builder/mod.rs | 2 +- src/ship/packet/handler/communication.rs | 2 +- src/ship/packet/handler/direct_message.rs | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/entity/account.rs b/src/entity/account.rs index 3958412..8a4acf6 100644 --- a/src/entity/account.rs +++ b/src/entity/account.rs @@ -2,6 +2,8 @@ use serde::{Serialize, Deserialize}; use libpso::character::settings; use libpso::character::guildcard; +const GUILDCARD_OFFSET: u32 = 2300000; + pub const USERFLAG_NEWCHAR: u32 = 0x00000001; pub const USERFLAG_DRESSINGROOM: u32 = 0x00000002; @@ -83,6 +85,10 @@ impl UserAccountEntity { pub fn is_currently_online(&self) -> bool { self.at_login | self.at_character | self.at_ship } + + pub fn guildcard(&self) -> u32 { + self.id.0 + GUILDCARD_OFFSET + } } diff --git a/src/ship/packet/builder/mod.rs b/src/ship/packet/builder/mod.rs index f74015e..5e17e00 100644 --- a/src/ship/packet/builder/mod.rs +++ b/src/ship/packet/builder/mod.rs @@ -15,7 +15,7 @@ use crate::ship::items::inventory::InventoryState; pub fn player_header(tag: u32, client: &ClientState, area_client: &AreaClient) -> PlayerHeader { PlayerHeader { tag, - guildcard: client.user.id.0, + guildcard: client.user.guildcard(), _unknown1: [0; 5], client_id: area_client.local_client.id() as u32, name: libpso::utf8_to_utf16_array!(client.character.name, 16), diff --git a/src/ship/packet/handler/communication.rs b/src/ship/packet/handler/communication.rs index 0a80304..ae67ab6 100644 --- a/src/ship/packet/handler/communication.rs +++ b/src/ship/packet/handler/communication.rs @@ -12,7 +12,7 @@ pub async fn player_chat(id: ClientId, clients: &Clients) -> Result, ShipError> { let cmsg = clients.with(id, |client| Box::pin(async move { - PlayerChat::new(client.user.id.0, msg.message) + PlayerChat::new(client.user.guildcard(), msg.message) })).await?; Ok(client_location.get_all_clients_by_client(id).await.unwrap().into_iter() diff --git a/src/ship/packet/handler/direct_message.rs b/src/ship/packet/handler/direct_message.rs index 5c49a53..cd0e466 100644 --- a/src/ship/packet/handler/direct_message.rs +++ b/src/ship/packet/handler/direct_message.rs @@ -60,7 +60,7 @@ pub async fn guildcard_send(id: ClientId, msg: GameMessage::GuildcardRecv(GuildcardRecv { client: guildcard_send.client, target: guildcard_send.target, - guildcard: client.user.id.0, + guildcard: client.user.guildcard(), name: utf8_to_utf16_array!(client.character.name, 0x18), team: [0; 0x10], // TODO: teams not yet implemented desc: utf8_to_utf16_array!(client.character.guildcard.description, 0x58),