mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-25 08:27:44 +00:00
Support the GM command for changing territories
This commit is contained in:
parent
d1139b4618
commit
74f7554aa8
2 changed files with 59 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use kawari::client_select_data::ClientCustomizeData;
|
use kawari::client_select_data::ClientCustomizeData;
|
||||||
use kawari::ipc::{IPCOpCode, IPCSegment, IPCStructData};
|
use kawari::ipc::{GameMasterCommandType, IPCOpCode, IPCSegment, IPCStructData};
|
||||||
use kawari::oodle::FFXIVOodle;
|
use kawari::oodle::FFXIVOodle;
|
||||||
use kawari::packet::{
|
use kawari::packet::{
|
||||||
CompressionType, PacketSegment, SegmentType, State, parse_packet, send_keep_alive, send_packet,
|
CompressionType, PacketSegment, SegmentType, State, parse_packet, send_keep_alive, send_packet,
|
||||||
|
@ -375,6 +375,7 @@ async fn main() {
|
||||||
model_type: 1,
|
model_type: 1,
|
||||||
spawn_index: 1,
|
spawn_index: 1,
|
||||||
state: 1,
|
state: 1,
|
||||||
|
gm_rank: 3,
|
||||||
look: CustomizeData {
|
look: CustomizeData {
|
||||||
race: 3,
|
race: 3,
|
||||||
age: 0,
|
age: 0,
|
||||||
|
@ -483,6 +484,44 @@ async fn main() {
|
||||||
IPCStructData::ChatMessage { message, .. } => {
|
IPCStructData::ChatMessage { message, .. } => {
|
||||||
tracing::info!("Client sent chat message: {message}!");
|
tracing::info!("Client sent chat message: {message}!");
|
||||||
}
|
}
|
||||||
|
IPCStructData::GameMasterCommand { command, arg, .. } => {
|
||||||
|
tracing::info!("Got a game master command!");
|
||||||
|
|
||||||
|
match &command {
|
||||||
|
GameMasterCommandType::ChangeTerritory => {
|
||||||
|
// Init Zone
|
||||||
|
{
|
||||||
|
let ipc = IPCSegment {
|
||||||
|
unk1: 0,
|
||||||
|
unk2: 0,
|
||||||
|
op_code: IPCOpCode::InitZone,
|
||||||
|
server_id: 0,
|
||||||
|
timestamp: timestamp_secs(),
|
||||||
|
data: IPCStructData::InitZone(InitZone {
|
||||||
|
server_id: WORLD_ID,
|
||||||
|
zone_id: *arg as u16,
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
let response_packet = PacketSegment {
|
||||||
|
source_actor: state.player_id.unwrap(),
|
||||||
|
target_actor: state.player_id.unwrap(),
|
||||||
|
segment_type: SegmentType::Ipc {
|
||||||
|
data: ipc,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
send_packet(
|
||||||
|
&mut write,
|
||||||
|
&[response_packet],
|
||||||
|
&mut state,
|
||||||
|
CompressionType::Oodle,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => panic!(
|
_ => panic!(
|
||||||
"The server is recieving a IPC response or unknown packet!"
|
"The server is recieving a IPC response or unknown packet!"
|
||||||
),
|
),
|
||||||
|
|
19
src/ipc.rs
19
src/ipc.rs
|
@ -79,6 +79,8 @@ pub enum IPCOpCode {
|
||||||
Disconnected = 0x360,
|
Disconnected = 0x360,
|
||||||
// Sent by the client when they send a chat message
|
// Sent by the client when they send a chat message
|
||||||
ChatMessage = 0xCA,
|
ChatMessage = 0xCA,
|
||||||
|
// Sent by the client when they send a GM command. This can only be sent by the client if they are sent a GM rank.
|
||||||
|
GameMasterCommand = 0x3B3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
|
@ -162,6 +164,13 @@ pub enum LobbyCharacterAction {
|
||||||
Request = 0x15,
|
Request = 0x15,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[binrw]
|
||||||
|
#[brw(repr = u8)]
|
||||||
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
|
pub enum GameMasterCommandType {
|
||||||
|
ChangeTerritory = 0x58,
|
||||||
|
}
|
||||||
|
|
||||||
#[binrw]
|
#[binrw]
|
||||||
#[br(import(magic: &IPCOpCode))]
|
#[br(import(magic: &IPCOpCode))]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -296,6 +305,15 @@ pub enum IPCStructData {
|
||||||
#[bw(map = write_string)]
|
#[bw(map = write_string)]
|
||||||
message: String,
|
message: String,
|
||||||
},
|
},
|
||||||
|
#[br(pre_assert(*magic == IPCOpCode::GameMasterCommand))]
|
||||||
|
GameMasterCommand {
|
||||||
|
// TODO: incomplete
|
||||||
|
command: GameMasterCommandType,
|
||||||
|
#[br(pad_before = 3)] // idk, not empty though
|
||||||
|
arg: u32,
|
||||||
|
#[br(dbg)]
|
||||||
|
unk: [u8; 24],
|
||||||
|
},
|
||||||
|
|
||||||
// Server->Client IPC
|
// Server->Client IPC
|
||||||
#[br(pre_assert(false))]
|
#[br(pre_assert(false))]
|
||||||
|
@ -455,6 +473,7 @@ impl IPCSegment {
|
||||||
IPCStructData::LogOutComplete { .. } => 8,
|
IPCStructData::LogOutComplete { .. } => 8,
|
||||||
IPCStructData::Disconnected { .. } => todo!(),
|
IPCStructData::Disconnected { .. } => todo!(),
|
||||||
IPCStructData::ChatMessage { .. } => 1056,
|
IPCStructData::ChatMessage { .. } => 1056,
|
||||||
|
IPCStructData::GameMasterCommand { .. } => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue