1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-07-09 15:37:45 +00:00

Add ClientChatIpcSegment

This is just a dummy for now, we just need it downstream in Packet
Analzyer.
This commit is contained in:
Joshua Goins 2025-07-04 16:01:15 -04:00
parent 5acf6580f3
commit f2239378f6
2 changed files with 114 additions and 76 deletions

View file

@ -21,7 +21,6 @@ fn main() {
let key = element.0;
let opcodes = element.1.as_array().unwrap();
if !opcodes.is_empty() {
// beginning
output_str.push_str("#[binrw]\n");
output_str.push_str("#[derive(Clone, PartialEq, Debug)]\n");
@ -99,7 +98,6 @@ fn main() {
// end impl
output_str.push_str("}\n\n");
}
}
std::fs::write("src/opcodes.rs", output_str).expect("Failed to write opcodes file!");
}

View file

@ -1,7 +1,7 @@
use binrw::binrw;
use crate::{
opcodes::ServerChatIpcType,
opcodes::{ClientChatIpcType, ServerChatIpcType},
packet::{IPC_HEADER_SIZE, IpcSegment, ReadWriteIpcSegment},
};
@ -38,6 +38,36 @@ impl Default for ServerChatIpcSegment {
}
}
pub type ClientChatIpcSegment = IpcSegment<ClientChatIpcType, ClientChatIpcData>;
impl ReadWriteIpcSegment for ClientChatIpcSegment {
fn calc_size(&self) -> u32 {
IPC_HEADER_SIZE + self.op_code.calc_size()
}
fn get_name(&self) -> &'static str {
self.op_code.get_name()
}
fn get_opcode(&self) -> u16 {
self.op_code.get_opcode()
}
}
// TODO: make generic
impl Default for ClientChatIpcSegment {
fn default() -> Self {
Self {
unk1: 0x14,
unk2: 0,
op_code: ClientChatIpcType::Unknown(0),
option: 0,
timestamp: 0,
data: ClientChatIpcData::Unknown { unk: Vec::new() },
}
}
}
#[binrw]
#[br(import(magic: &ServerChatIpcType, size: &u32))]
#[derive(Debug, Clone)]
@ -50,3 +80,13 @@ pub enum ServerChatIpcData {
unk: Vec<u8>,
},
}
#[binrw]
#[br(import(_magic: &ClientChatIpcType, size: &u32))]
#[derive(Debug, Clone)]
pub enum ClientChatIpcData {
Unknown {
#[br(count = size - 32)]
unk: Vec<u8>,
},
}