From f8a28e45c90e9867f6ed7d6c7e19eff47465d8ce Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 16 Mar 2025 15:20:55 -0400 Subject: [PATCH] Add helper function to send lobby errors This isn't used yet, but implemented for future use. --- src/bin/kawari-lobby.rs | 4 ++++ src/ipc.rs | 14 +++++++++++++- src/lobby/connection.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/bin/kawari-lobby.rs b/src/bin/kawari-lobby.rs index 55759be..33b8de6 100644 --- a/src/bin/kawari-lobby.rs +++ b/src/bin/kawari-lobby.rs @@ -47,6 +47,7 @@ async fn main() { } SegmentType::Ipc { data } => match &data.data { IPCStructData::ClientVersionInfo { + sequence, session_id, version_info, } => { @@ -57,6 +58,9 @@ async fn main() { connection.state.session_id = Some(session_id.clone()); connection.send_account_list().await; + + // request an update + //connection.send_error(*sequence, 1012, 13101).await; } IPCStructData::RequestCharacterList { sequence } => { tracing::info!("Client is requesting character list..."); diff --git a/src/ipc.rs b/src/ipc.rs index 5586c4c..932c0bb 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -237,7 +237,9 @@ pub enum IPCStructData { // Client->Server IPC #[br(pre_assert(*magic == IPCOpCode::ClientVersionInfo))] ClientVersionInfo { - #[brw(pad_before = 18)] // full of nonsense i don't understand yet + sequence: u64, + + #[brw(pad_before = 14)] // full of nonsense i don't understand yet #[br(count = 64)] #[br(map = read_string)] #[bw(ignore)] @@ -549,6 +551,14 @@ pub enum IPCStructData { Unk17 { unk: [u8; 104] }, #[br(pre_assert(false))] SocialList(SocialList), + #[br(pre_assert(false))] + LobbyError { + sequence: u64, + error: u32, + value: u32, + exd_error_id: u16, + unk1: u16, + }, } #[binrw] @@ -579,6 +589,7 @@ impl Default for IPCSegment { data: IPCStructData::ClientVersionInfo { session_id: String::new(), version_info: String::new(), + sequence: 0, }, } } @@ -642,6 +653,7 @@ impl IPCSegment { IPCStructData::ActorMove { .. } => 16, IPCStructData::Unk17 { .. } => 104, IPCStructData::SocialList { .. } => 1136, + IPCStructData::LobbyError { .. } => 536, } } } diff --git a/src/lobby/connection.rs b/src/lobby/connection.rs index 6689b26..b6259ae 100644 --- a/src/lobby/connection.rs +++ b/src/lobby/connection.rs @@ -306,4 +306,30 @@ impl LobbyConnection { }) .await; } + + pub async fn send_error(&mut self, sequence: u64, error: u32, exd_error: u16) { + let lobby_error = IPCStructData::LobbyError { + sequence, + error, + value: 0, + exd_error_id: exd_error, + unk1: 1, + }; + + let ipc = IPCSegment { + unk1: 0, + unk2: 0, + op_code: IPCOpCode::InitializeChat, + server_id: 0, + timestamp: timestamp_secs(), + data: lobby_error, + }; + + self.send_segment(PacketSegment { + source_actor: 0, + target_actor: 0, + segment_type: SegmentType::Ipc { data: ipc }, + }) + .await; + } }