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

Rename the remaining lobby IPC opcodes, reorder them too

This commit is contained in:
Joshua Goins 2025-05-01 22:45:49 -04:00
parent 2ec54fa6ec
commit 67ec72a962
4 changed files with 106 additions and 107 deletions

View file

@ -275,39 +275,39 @@
], ],
"ServerLobbyIpcType": [ "ServerLobbyIpcType": [
{ {
"name": "LobbyError", "name": "NackReply",
"opcode": 2, "opcode": 2,
"size": 536 "size": 536
}, },
{ {
"name": "LobbyServiceAccountList", "name": "LoginReply",
"opcode": 12, "opcode": 12,
"size": 656 "size": 656
}, },
{ {
"name": "LobbyCharacterList", "name": "ServiceLoginReply",
"opcode": 13, "opcode": 13,
"size": 2472 "size": 2472
}, },
{ {
"name": "LobbyEnterWorld", "name": "CharaMakeReply",
"opcode": 14,
"size": 2568
},
{
"name": "GameLoginReply",
"opcode": 15, "opcode": 15,
"size": 160 "size": 160
}, },
{ {
"name": "LobbyServerList", "name": "DistWorldInfo",
"opcode": 21, "opcode": 21,
"size": 528 "size": 528
}, },
{ {
"name": "LobbyRetainerList", "name": "DistRetainerInfo",
"opcode": 23, "opcode": 23,
"size": 210 "size": 210
},
{
"name": "CharacterCreated",
"opcode": 14,
"size": 2568
} }
], ],
"ClientLobbyIpcType": [ "ClientLobbyIpcType": [
@ -326,15 +326,15 @@
"opcode": 5, "opcode": 5,
"size": 1144 "size": 1144
}, },
{
"name": "LobbyCharacterAction",
"opcode": 11,
"size": 496
},
{ {
"name": "ShandaLogin", "name": "ShandaLogin",
"opcode": 6, "opcode": 6,
"size": 1456 "size": 1456
},
{
"name": "CharaMake",
"opcode": 11,
"size": 496
} }
] ]
} }

View file

@ -104,7 +104,7 @@ async fn main() {
Some(connection.service_accounts[0].id); Some(connection.service_accounts[0].id);
connection.send_lobby_info(*sequence).await connection.send_lobby_info(*sequence).await
} }
ClientLobbyIpcData::LobbyCharacterAction(character_action) => { ClientLobbyIpcData::CharaMake(character_action) => {
connection.handle_character_action(character_action).await connection.handle_character_action(character_action).await
} }
ClientLobbyIpcData::ShandaLogin { unk } => { ClientLobbyIpcData::ShandaLogin { unk } => {

View file

@ -83,8 +83,7 @@ impl LobbyConnection {
/// Send the service account list to the client. /// Send the service account list to the client.
pub async fn send_account_list(&mut self) { pub async fn send_account_list(&mut self) {
let service_account_list = let service_account_list = ServerLobbyIpcData::LoginReply(LobbyServiceAccountList {
ServerLobbyIpcData::LobbyServiceAccountList(LobbyServiceAccountList {
sequence: 0, sequence: 0,
num_service_accounts: self.service_accounts.len() as u8, num_service_accounts: self.service_accounts.len() as u8,
unk1: 3, unk1: 3,
@ -95,7 +94,7 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyServiceAccountList, op_code: ServerLobbyIpcType::LoginReply,
server_id: 0, server_id: 0,
timestamp: timestamp_secs(), timestamp: timestamp_secs(),
data: service_account_list, data: service_account_list,
@ -127,7 +126,7 @@ impl LobbyConnection {
// add any empty boys // add any empty boys
servers.resize(6, Server::default()); servers.resize(6, Server::default());
let lobby_server_list = ServerLobbyIpcData::LobbyServerList(LobbyServerList { let lobby_server_list = ServerLobbyIpcData::DistWorldInfo(LobbyServerList {
sequence: 0, sequence: 0,
unk1: 1, unk1: 1,
offset: 0, offset: 0,
@ -138,7 +137,7 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyServerList, op_code: ServerLobbyIpcType::DistWorldInfo,
server_id: 0, server_id: 0,
timestamp: timestamp_secs(), timestamp: timestamp_secs(),
data: lobby_server_list, data: lobby_server_list,
@ -154,12 +153,12 @@ impl LobbyConnection {
// send them the retainer list // send them the retainer list
{ {
let lobby_retainer_list = ServerLobbyIpcData::LobbyRetainerList { unk1: 1 }; let lobby_retainer_list = ServerLobbyIpcData::DistRetainerInfo { unk1: 1 };
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyRetainerList, op_code: ServerLobbyIpcType::DistRetainerInfo,
server_id: 0, server_id: 0,
timestamp: timestamp_secs(), timestamp: timestamp_secs(),
data: lobby_retainer_list, data: lobby_retainer_list,
@ -261,10 +260,10 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyCharacterList, op_code: ServerLobbyIpcType::ServiceLoginReply,
server_id: 0, server_id: 0,
timestamp: timestamp_secs(), timestamp: timestamp_secs(),
data: ServerLobbyIpcData::LobbyCharacterList(lobby_character_list), data: ServerLobbyIpcData::ServiceLoginReply(lobby_character_list),
}; };
self.send_segment(PacketSegment { self.send_segment(PacketSegment {
@ -281,7 +280,7 @@ impl LobbyConnection {
pub async fn send_enter_world(&mut self, sequence: u64, content_id: u64, actor_id: u32) { pub async fn send_enter_world(&mut self, sequence: u64, content_id: u64, actor_id: u32) {
let config = get_config(); let config = get_config();
let enter_world = ServerLobbyIpcData::LobbyEnterWorld { let enter_world = ServerLobbyIpcData::GameLoginReply {
sequence, sequence,
actor_id, actor_id,
content_id, content_id,
@ -293,7 +292,7 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyEnterWorld, op_code: ServerLobbyIpcType::GameLoginReply,
server_id: 0, server_id: 0,
timestamp: timestamp_secs(), timestamp: timestamp_secs(),
data: enter_world, data: enter_world,
@ -309,7 +308,7 @@ impl LobbyConnection {
/// Send a lobby error to the client. /// Send a lobby error to the client.
pub async fn send_error(&mut self, sequence: u64, error: u32, exd_error: u16) { pub async fn send_error(&mut self, sequence: u64, error: u32, exd_error: u16) {
let lobby_error = ServerLobbyIpcData::LobbyError { let lobby_error = ServerLobbyIpcData::NackReply {
sequence, sequence,
error, error,
value: 0, value: 0,
@ -320,7 +319,7 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyError, op_code: ServerLobbyIpcType::NackReply,
server_id: 0, server_id: 0,
timestamp: timestamp_secs(), timestamp: timestamp_secs(),
data: lobby_error, data: lobby_error,
@ -369,10 +368,10 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::CharacterCreated, op_code: ServerLobbyIpcType::CharaMakeReply,
server_id: 0, server_id: 0,
timestamp: 0, timestamp: 0,
data: ServerLobbyIpcData::CharacterCreated { data: ServerLobbyIpcData::CharaMakeReply {
sequence: character_action.sequence + 1, sequence: character_action.sequence + 1,
unk1: 0x1, unk1: 0x1,
unk2: 0x1, unk2: 0x1,
@ -396,10 +395,10 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyError, op_code: ServerLobbyIpcType::NackReply,
server_id: 0, server_id: 0,
timestamp: 0, timestamp: 0,
data: ServerLobbyIpcData::LobbyError { data: ServerLobbyIpcData::NackReply {
sequence: character_action.sequence, sequence: character_action.sequence,
error: 0x00000bdb, error: 0x00000bdb,
exd_error_id: 0x32cc, exd_error_id: 0x32cc,
@ -461,10 +460,10 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::CharacterCreated, op_code: ServerLobbyIpcType::CharaMakeReply,
server_id: 0, server_id: 0,
timestamp: 0, timestamp: 0,
data: ServerLobbyIpcData::CharacterCreated { data: ServerLobbyIpcData::CharaMakeReply {
sequence: character_action.sequence + 1, sequence: character_action.sequence + 1,
unk1: 0x1, unk1: 0x1,
unk2: 0x1, unk2: 0x1,
@ -513,10 +512,10 @@ impl LobbyConnection {
let ipc = ServerLobbyIpcSegment { let ipc = ServerLobbyIpcSegment {
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::CharacterCreated, // FIXME: a TERRIBLE name for this packet op_code: ServerLobbyIpcType::CharaMakeReply,
server_id: 0, server_id: 0,
timestamp: 0, timestamp: 0,
data: ServerLobbyIpcData::CharacterCreated { data: ServerLobbyIpcData::CharaMakeReply {
sequence: character_action.sequence + 1, sequence: character_action.sequence + 1,
unk1: 0x1, unk1: 0x1,
unk2: 0x1, unk2: 0x1,

View file

@ -62,10 +62,10 @@ impl Default for ServerLobbyIpcSegment {
Self { Self {
unk1: 0x14, unk1: 0x14,
unk2: 0, unk2: 0,
op_code: ServerLobbyIpcType::LobbyError, op_code: ServerLobbyIpcType::NackReply,
server_id: 0, server_id: 0,
timestamp: 0, timestamp: 0,
data: ServerLobbyIpcData::LobbyError { data: ServerLobbyIpcData::NackReply {
sequence: 0, sequence: 0,
error: 0, error: 0,
value: 0, value: 0,
@ -80,6 +80,20 @@ impl Default for ServerLobbyIpcSegment {
#[br(import(magic: &ClientLobbyIpcType))] #[br(import(magic: &ClientLobbyIpcType))]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ClientLobbyIpcData { pub enum ClientLobbyIpcData {
/// Sent by the client when it requests the character list in the lobby.
#[br(pre_assert(*magic == ClientLobbyIpcType::ServiceLogin))]
ServiceLogin {
#[brw(pad_before = 16)]
sequence: u64,
// TODO: what is in here?
},
/// Sent by the client when it requests to enter a world.
#[br(pre_assert(*magic == ClientLobbyIpcType::GameLogin))]
GameLogin {
sequence: u64,
content_id: u64,
// TODO: what else is in here?
},
/// Sent by the client after exchanging encryption information with the lobby server. /// Sent by the client after exchanging encryption information with the lobby server.
#[br(pre_assert(*magic == ClientLobbyIpcType::LoginEx))] #[br(pre_assert(*magic == ClientLobbyIpcType::LoginEx))]
LoginEx { LoginEx {
@ -98,50 +112,47 @@ pub enum ClientLobbyIpcData {
version_info: String, version_info: String,
// unknown stuff at the end, it's not completely empty // unknown stuff at the end, it's not completely empty
}, },
/// Sent by the client when it requests the character list in the lobby.
#[br(pre_assert(*magic == ClientLobbyIpcType::ServiceLogin))]
ServiceLogin {
#[brw(pad_before = 16)]
sequence: u64,
// TODO: what is in here?
},
/// Sent by the client when they request something about the character (e.g. deletion.)
#[br(pre_assert(*magic == ClientLobbyIpcType::LobbyCharacterAction))]
LobbyCharacterAction(LobbyCharacterAction),
/// Sent by the client when it requests to enter a world.
#[br(pre_assert(*magic == ClientLobbyIpcType::GameLogin))]
GameLogin {
sequence: u64,
content_id: u64,
// TODO: what else is in here?
},
#[br(pre_assert(*magic == ClientLobbyIpcType::ShandaLogin))] #[br(pre_assert(*magic == ClientLobbyIpcType::ShandaLogin))]
ShandaLogin { ShandaLogin {
#[bw(pad_size_to = 1456)] #[bw(pad_size_to = 1456)]
#[br(count = 1456)] #[br(count = 1456)]
unk: Vec<u8>, unk: Vec<u8>,
}, },
/// Sent by the client when they request something about the character (e.g. deletion.)
#[br(pre_assert(*magic == ClientLobbyIpcType::CharaMake))]
CharaMake(LobbyCharacterAction),
} }
#[binrw] #[binrw]
#[br(import(_magic: &ServerLobbyIpcType))] #[br(import(_magic: &ServerLobbyIpcType))]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ServerLobbyIpcData { pub enum ServerLobbyIpcData {
/// Sent by the server to inform the client of their service accounts. /// Sent by the server to indicate an lobby error occured.
LobbyServiceAccountList(LobbyServiceAccountList), NackReply {
/// Sent by the server to inform the client of their servers. sequence: u64,
LobbyServerList(LobbyServerList), error: u32,
/// Sent by the server to inform the client of their retainers. value: u32,
LobbyRetainerList { exd_error_id: u16,
// TODO: what is in here? #[brw(pad_after = 516)] // empty and garbage
#[brw(pad_before = 7)] unk1: u16,
#[brw(pad_after = 202)]
unk1: u8,
}, },
/// Sent by the server to inform the client of their service accounts.
LoginReply(LobbyServiceAccountList),
/// Sent by the server to inform the client of their characters. /// Sent by the server to inform the client of their characters.
LobbyCharacterList(LobbyCharacterList), ServiceLoginReply(LobbyCharacterList),
// Assumed what this is, but probably incorrect
CharaMakeReply {
sequence: u64,
unk1: u8,
unk2: u8,
#[brw(pad_after = 1)] // empty
action: LobbyCharacterActionKind,
#[brw(pad_before = 36)] // empty
#[brw(pad_after = 1336)] // empty and garbage
details: CharacterDetails,
},
/// Sent by the server to tell the client how to connect to the world server. /// Sent by the server to tell the client how to connect to the world server.
LobbyEnterWorld { GameLoginReply {
sequence: u64, sequence: u64,
actor_id: u32, actor_id: u32,
#[brw(pad_before = 4)] #[brw(pad_before = 4)]
@ -160,25 +171,14 @@ pub enum ServerLobbyIpcData {
#[bw(map = write_string)] #[bw(map = write_string)]
host: String, host: String,
}, },
/// Sent by the server to indicate an lobby error occured. /// Sent by the server to inform the client of their servers.
LobbyError { DistWorldInfo(LobbyServerList),
sequence: u64, /// Sent by the server to inform the client of their retainers.
error: u32, DistRetainerInfo {
value: u32, // TODO: what is in here?
exd_error_id: u16, #[brw(pad_before = 7)]
#[brw(pad_after = 516)] // empty and garbage #[brw(pad_after = 202)]
unk1: u16,
},
// Assumed what this is, but probably incorrect
CharacterCreated {
sequence: u64,
unk1: u8, unk1: u8,
unk2: u8,
#[brw(pad_after = 1)] // empty
action: LobbyCharacterActionKind,
#[brw(pad_before = 36)] // empty
#[brw(pad_after = 1336)] // empty and garbage
details: CharacterDetails,
}, },
} }
@ -195,24 +195,24 @@ mod tests {
fn lobby_ipc_sizes() { fn lobby_ipc_sizes() {
let ipc_types = [ let ipc_types = [
( (
ServerLobbyIpcType::LobbyServiceAccountList, ServerLobbyIpcType::LoginReply,
ServerLobbyIpcData::LobbyServiceAccountList(LobbyServiceAccountList::default()), ServerLobbyIpcData::LoginReply(LobbyServiceAccountList::default()),
), ),
( (
ServerLobbyIpcType::LobbyServerList, ServerLobbyIpcType::DistWorldInfo,
ServerLobbyIpcData::LobbyServerList(LobbyServerList::default()), ServerLobbyIpcData::DistWorldInfo(LobbyServerList::default()),
), ),
( (
ServerLobbyIpcType::LobbyRetainerList, ServerLobbyIpcType::DistRetainerInfo,
ServerLobbyIpcData::LobbyRetainerList { unk1: 0 }, ServerLobbyIpcData::DistRetainerInfo { unk1: 0 },
), ),
( (
ServerLobbyIpcType::LobbyCharacterList, ServerLobbyIpcType::ServiceLoginReply,
ServerLobbyIpcData::LobbyCharacterList(LobbyCharacterList::default()), ServerLobbyIpcData::ServiceLoginReply(LobbyCharacterList::default()),
), ),
( (
ServerLobbyIpcType::LobbyEnterWorld, ServerLobbyIpcType::GameLoginReply,
ServerLobbyIpcData::LobbyEnterWorld { ServerLobbyIpcData::GameLoginReply {
sequence: 0, sequence: 0,
actor_id: 0, actor_id: 0,
content_id: 0, content_id: 0,
@ -222,8 +222,8 @@ mod tests {
}, },
), ),
( (
ServerLobbyIpcType::LobbyError, ServerLobbyIpcType::NackReply,
ServerLobbyIpcData::LobbyError { ServerLobbyIpcData::NackReply {
sequence: 0, sequence: 0,
error: 0, error: 0,
value: 0, value: 0,
@ -232,8 +232,8 @@ mod tests {
}, },
), ),
( (
ServerLobbyIpcType::CharacterCreated, ServerLobbyIpcType::CharaMakeReply,
ServerLobbyIpcData::CharacterCreated { ServerLobbyIpcData::CharaMakeReply {
sequence: 0, sequence: 0,
unk1: 0, unk1: 0,
unk2: 0, unk2: 0,