mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-24 08:07:45 +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:
parent
b52ff724ab
commit
a448df65b4
3 changed files with 34 additions and 2 deletions
|
@ -362,10 +362,18 @@ async fn main() {
|
||||||
server_id: 0,
|
server_id: 0,
|
||||||
timestamp: timestamp_secs(),
|
timestamp: timestamp_secs(),
|
||||||
data: IPCStructData::PlayerSpawn(PlayerSpawn {
|
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_curr: 100,
|
||||||
hp_max: 100,
|
hp_max: 100,
|
||||||
mp_curr: 100,
|
mp_curr: 100,
|
||||||
mp_max: 100,
|
mp_max: 100,
|
||||||
|
model_type: 1,
|
||||||
|
spawn_index: 1,
|
||||||
|
state: 1,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -442,6 +450,9 @@ async fn main() {
|
||||||
IPCStructData::Disconnected { .. } => {
|
IPCStructData::Disconnected { .. } => {
|
||||||
tracing::info!("Client disconnected!");
|
tracing::info!("Client disconnected!");
|
||||||
}
|
}
|
||||||
|
IPCStructData::ChatMessage { message } => {
|
||||||
|
tracing::info!("Client sent chat message: {message}!");
|
||||||
|
}
|
||||||
_ => panic!(
|
_ => panic!(
|
||||||
"The server is recieving a IPC response or unknown packet!"
|
"The server is recieving a IPC response or unknown packet!"
|
||||||
),
|
),
|
||||||
|
|
15
src/ipc.rs
15
src/ipc.rs
|
@ -76,6 +76,8 @@ pub enum IPCOpCode {
|
||||||
LogOutComplete = 0x369,
|
LogOutComplete = 0x369,
|
||||||
// Sent by the client when it's actually disconnecting
|
// Sent by the client when it's actually disconnecting
|
||||||
Disconnected = 0x360,
|
Disconnected = 0x360,
|
||||||
|
// Sent by the client when they send a chat message
|
||||||
|
ChatMessage = 0xCA,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
|
@ -275,6 +277,18 @@ pub enum IPCStructData {
|
||||||
// TODO: full of possibly interesting information
|
// TODO: full of possibly interesting information
|
||||||
unk: [u8; 8],
|
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
|
// Server->Client IPC
|
||||||
#[br(pre_assert(false))]
|
#[br(pre_assert(false))]
|
||||||
|
@ -433,6 +447,7 @@ impl IPCSegment {
|
||||||
IPCStructData::LogOut { .. } => todo!(),
|
IPCStructData::LogOut { .. } => todo!(),
|
||||||
IPCStructData::LogOutComplete { .. } => 8,
|
IPCStructData::LogOutComplete { .. } => 8,
|
||||||
IPCStructData::Disconnected { .. } => todo!(),
|
IPCStructData::Disconnected { .. } => todo!(),
|
||||||
|
IPCStructData::ChatMessage { .. } => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
use binrw::binrw;
|
use binrw::binrw;
|
||||||
|
|
||||||
|
use crate::common::{read_string, write_string};
|
||||||
|
|
||||||
use super::position::Position;
|
use super::position::Position;
|
||||||
use super::status_effect::StatusEffect;
|
use super::status_effect::StatusEffect;
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[derive(Debug, Clone, Copy, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct PlayerSpawn {
|
pub struct PlayerSpawn {
|
||||||
pub title: u16,
|
pub title: u16,
|
||||||
pub u1b: u16,
|
pub u1b: u16,
|
||||||
|
@ -78,7 +80,11 @@ pub struct PlayerSpawn {
|
||||||
pub models: [u32; 10],
|
pub models: [u32; 10],
|
||||||
pub unknown6_58: [u8; 10],
|
pub unknown6_58: [u8; 10],
|
||||||
pub padding3: [u8; 7],
|
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 look: [u8; 26],
|
||||||
pub fc_tag: [u8; 6],
|
pub fc_tag: [u8; 6],
|
||||||
pub padding: [u8; 26],
|
pub padding: [u8; 26],
|
||||||
|
|
Loading…
Add table
Reference in a new issue