1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-23 23:57:46 +00:00

Handle chat messages

This makes the server not panic and exit when recieving chat messages from the
client, but we only extract the message for now.
This commit is contained in:
Joshua Goins 2025-03-12 19:34:15 -04:00
parent b52ff724ab
commit a448df65b4
3 changed files with 34 additions and 2 deletions

View file

@ -362,10 +362,18 @@ async fn main() {
server_id: 0,
timestamp: timestamp_secs(),
data: IPCStructData::PlayerSpawn(PlayerSpawn {
current_world_id: WORLD_ID,
home_world_id: WORLD_ID,
title: 1,
class_job: 35,
name: "Test".to_string(),
hp_curr: 100,
hp_max: 100,
mp_curr: 100,
mp_max: 100,
model_type: 1,
spawn_index: 1,
state: 1,
..Default::default()
}),
};
@ -442,6 +450,9 @@ async fn main() {
IPCStructData::Disconnected { .. } => {
tracing::info!("Client disconnected!");
}
IPCStructData::ChatMessage { message } => {
tracing::info!("Client sent chat message: {message}!");
}
_ => panic!(
"The server is recieving a IPC response or unknown packet!"
),

View file

@ -76,6 +76,8 @@ pub enum IPCOpCode {
LogOutComplete = 0x369,
// Sent by the client when it's actually disconnecting
Disconnected = 0x360,
// Sent by the client when they send a chat message
ChatMessage = 0xCA,
}
#[binrw]
@ -275,6 +277,18 @@ pub enum IPCStructData {
// TODO: full of possibly interesting information
unk: [u8; 8],
},
#[br(pre_assert(*magic == IPCOpCode::ChatMessage))]
ChatMessage {
// TODO: incomplete
#[br(dbg)]
#[brw(pad_before = 26)]
#[brw(pad_after = 998)]
#[br(count = 32)]
#[bw(pad_size_to = 32)]
#[br(map = read_string)]
#[bw(map = write_string)]
message: String,
},
// Server->Client IPC
#[br(pre_assert(false))]
@ -433,6 +447,7 @@ impl IPCSegment {
IPCStructData::LogOut { .. } => todo!(),
IPCStructData::LogOutComplete { .. } => 8,
IPCStructData::Disconnected { .. } => todo!(),
IPCStructData::ChatMessage { .. } => todo!(),
}
}
}

View file

@ -1,10 +1,12 @@
use binrw::binrw;
use crate::common::{read_string, write_string};
use super::position::Position;
use super::status_effect::StatusEffect;
#[binrw]
#[derive(Debug, Clone, Copy, Default)]
#[derive(Debug, Clone, Default)]
pub struct PlayerSpawn {
pub title: u16,
pub u1b: u16,
@ -78,7 +80,11 @@ pub struct PlayerSpawn {
pub models: [u32; 10],
pub unknown6_58: [u8; 10],
pub padding3: [u8; 7],
pub name: [u8; 32],
#[br(count = 32)]
#[bw(pad_size_to = 32)]
#[br(map = read_string)]
#[bw(map = write_string)]
pub name: String,
pub look: [u8; 26],
pub fc_tag: [u8; 6],
pub padding: [u8; 26],