mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-23 23:57:46 +00:00
Move zone changing into ZoneConnection's purview
I suspect that we have to rigidly control the fade in/out or whatever PrepareZoning is, and it's just a good idea in general.
This commit is contained in:
parent
f372f3173d
commit
3aaa8ae3eb
3 changed files with 161 additions and 236 deletions
|
@ -32,14 +32,13 @@ async fn main() {
|
||||||
serverbound_oodle: FFXIVOodle::new(),
|
serverbound_oodle: FFXIVOodle::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let zone = Zone::load(010);
|
|
||||||
|
|
||||||
let mut exit_position = None;
|
let mut exit_position = None;
|
||||||
|
|
||||||
let mut connection = ZoneConnection {
|
let mut connection = ZoneConnection {
|
||||||
socket,
|
socket,
|
||||||
state,
|
state,
|
||||||
player_id: 0,
|
player_id: 0,
|
||||||
|
zone: Zone::load(ZONE_ID),
|
||||||
};
|
};
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
@ -250,142 +249,7 @@ async fn main() {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player Class Info
|
connection.change_zone(ZONE_ID).await;
|
||||||
{
|
|
||||||
let ipc = IPCSegment {
|
|
||||||
unk1: 0,
|
|
||||||
unk2: 0,
|
|
||||||
op_code: IPCOpCode::UpdateClassInfo,
|
|
||||||
server_id: 69, // lol
|
|
||||||
timestamp: timestamp_secs(),
|
|
||||||
data: IPCStructData::UpdateClassInfo(
|
|
||||||
UpdateClassInfo {
|
|
||||||
class_id: 35,
|
|
||||||
unknown: 1,
|
|
||||||
synced_level: 90,
|
|
||||||
class_level: 90,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unk10
|
|
||||||
{
|
|
||||||
let ipc = IPCSegment {
|
|
||||||
unk1: 0,
|
|
||||||
unk2: 0,
|
|
||||||
op_code: IPCOpCode::Unk10,
|
|
||||||
server_id: 69, // lol
|
|
||||||
timestamp: timestamp_secs(),
|
|
||||||
data: IPCStructData::Unk10 {
|
|
||||||
unk: 0x41a0000000000002,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unk9
|
|
||||||
{
|
|
||||||
let ipc = IPCSegment {
|
|
||||||
unk1: 0,
|
|
||||||
unk2: 0,
|
|
||||||
op_code: IPCOpCode::Unk9,
|
|
||||||
server_id: 69, // lol
|
|
||||||
timestamp: timestamp_secs(),
|
|
||||||
data: IPCStructData::Unk9 { unk: [0; 24] },
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// link shell information
|
|
||||||
{
|
|
||||||
let ipc = IPCSegment {
|
|
||||||
unk1: 0,
|
|
||||||
unk2: 0,
|
|
||||||
op_code: IPCOpCode::LinkShellInformation,
|
|
||||||
server_id: 69, // lol
|
|
||||||
timestamp: timestamp_secs(),
|
|
||||||
data: IPCStructData::LinkShellInformation {
|
|
||||||
unk: [0; 456],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unk8
|
|
||||||
{
|
|
||||||
let ipc = IPCSegment {
|
|
||||||
unk1: 0,
|
|
||||||
unk2: 0,
|
|
||||||
op_code: IPCOpCode::Unk8,
|
|
||||||
server_id: 69, // lol
|
|
||||||
timestamp: timestamp_secs(),
|
|
||||||
data: IPCStructData::Unk8 { unk: [0; 808] },
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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: ZONE_ID,
|
|
||||||
weather_id: 1,
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
IPCStructData::FinishLoading { .. } => {
|
IPCStructData::FinishLoading { .. } => {
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
|
@ -581,31 +445,7 @@ async fn main() {
|
||||||
|
|
||||||
match &command {
|
match &command {
|
||||||
GameMasterCommandType::ChangeTerritory => {
|
GameMasterCommandType::ChangeTerritory => {
|
||||||
// Init Zone
|
connection.change_zone(*arg as u16).await
|
||||||
{
|
|
||||||
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()
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc {
|
|
||||||
data: ipc,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -622,8 +462,12 @@ async fn main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// find the exit box id
|
// find the exit box id
|
||||||
let (_, exit_box) =
|
let new_territory;
|
||||||
zone.find_exit_box(*exit_box_id).unwrap();
|
{
|
||||||
|
let (_, exit_box) = connection
|
||||||
|
.zone
|
||||||
|
.find_exit_box(*exit_box_id)
|
||||||
|
.unwrap();
|
||||||
tracing::info!("exit box: {:#?}", exit_box);
|
tracing::info!("exit box: {:#?}", exit_box);
|
||||||
|
|
||||||
// find the pop range on the other side
|
// find the pop range on the other side
|
||||||
|
@ -638,6 +482,8 @@ async fn main() {
|
||||||
y: destination_object.transform.translation[1],
|
y: destination_object.transform.translation[1],
|
||||||
z: destination_object.transform.translation[2],
|
z: destination_object.transform.translation[2],
|
||||||
});
|
});
|
||||||
|
new_territory = exit_box.territory_type;
|
||||||
|
}
|
||||||
|
|
||||||
// fade out?
|
// fade out?
|
||||||
{
|
{
|
||||||
|
@ -683,64 +529,9 @@ async fn main() {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::info!(
|
tracing::info!("sending them to {:#?}", new_territory);
|
||||||
"sending them to {:#?}",
|
|
||||||
exit_box.territory_type
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
connection.change_zone(new_territory).await;
|
||||||
d.push("resources/tests/init_zone.bin");
|
|
||||||
|
|
||||||
let buffer = std::fs::read(d).unwrap();
|
|
||||||
let mut buffer = Cursor::new(&buffer);
|
|
||||||
|
|
||||||
let init_zone = InitZone::read_le(&mut buffer).unwrap();
|
|
||||||
|
|
||||||
// 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: exit_box.territory_type,
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// idk
|
|
||||||
{
|
|
||||||
let ipc = IPCSegment {
|
|
||||||
unk1: 0,
|
|
||||||
unk2: 0,
|
|
||||||
op_code: IPCOpCode::PrepareZoning,
|
|
||||||
server_id: 0,
|
|
||||||
timestamp: timestamp_secs(),
|
|
||||||
data: IPCStructData::PrepareZoning {
|
|
||||||
unk: [0x01100000, 0, 0, 0],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
connection
|
|
||||||
.send_segment(PacketSegment {
|
|
||||||
source_actor: connection.player_id,
|
|
||||||
target_actor: connection.player_id,
|
|
||||||
segment_type: SegmentType::Ipc { data: ipc },
|
|
||||||
})
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
IPCStructData::Unk13 { .. } => {
|
IPCStructData::Unk13 { .. } => {
|
||||||
tracing::info!("Recieved Unk13!");
|
tracing::info!("Recieved Unk13!");
|
||||||
|
|
|
@ -10,13 +10,15 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::Position;
|
use super::{InitZone, Position, UpdateClassInfo, Zone};
|
||||||
|
|
||||||
pub struct ZoneConnection {
|
pub struct ZoneConnection {
|
||||||
pub socket: TcpStream,
|
pub socket: TcpStream,
|
||||||
|
|
||||||
pub state: State,
|
pub state: State,
|
||||||
pub player_id: u32,
|
pub player_id: u32,
|
||||||
|
|
||||||
|
pub zone: Zone,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ZoneConnection {
|
impl ZoneConnection {
|
||||||
|
@ -64,4 +66,136 @@ impl ZoneConnection {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn change_zone(&mut self, new_zone_id: u16) {
|
||||||
|
self.zone = Zone::load(new_zone_id);
|
||||||
|
|
||||||
|
// Player Class Info
|
||||||
|
{
|
||||||
|
let ipc = IPCSegment {
|
||||||
|
unk1: 0,
|
||||||
|
unk2: 0,
|
||||||
|
op_code: IPCOpCode::UpdateClassInfo,
|
||||||
|
server_id: 69, // lol
|
||||||
|
timestamp: timestamp_secs(),
|
||||||
|
data: IPCStructData::UpdateClassInfo(UpdateClassInfo {
|
||||||
|
class_id: 35,
|
||||||
|
unknown: 1,
|
||||||
|
synced_level: 90,
|
||||||
|
class_level: 90,
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
self.send_segment(PacketSegment {
|
||||||
|
source_actor: self.player_id,
|
||||||
|
target_actor: self.player_id,
|
||||||
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unk10
|
||||||
|
{
|
||||||
|
let ipc = IPCSegment {
|
||||||
|
unk1: 0,
|
||||||
|
unk2: 0,
|
||||||
|
op_code: IPCOpCode::Unk10,
|
||||||
|
server_id: 69, // lol
|
||||||
|
timestamp: timestamp_secs(),
|
||||||
|
data: IPCStructData::Unk10 {
|
||||||
|
unk: 0x41a0000000000002,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
self.send_segment(PacketSegment {
|
||||||
|
source_actor: self.player_id,
|
||||||
|
target_actor: self.player_id,
|
||||||
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unk9
|
||||||
|
{
|
||||||
|
let ipc = IPCSegment {
|
||||||
|
unk1: 0,
|
||||||
|
unk2: 0,
|
||||||
|
op_code: IPCOpCode::Unk9,
|
||||||
|
server_id: 69, // lol
|
||||||
|
timestamp: timestamp_secs(),
|
||||||
|
data: IPCStructData::Unk9 { unk: [0; 24] },
|
||||||
|
};
|
||||||
|
|
||||||
|
self.send_segment(PacketSegment {
|
||||||
|
source_actor: self.player_id,
|
||||||
|
target_actor: self.player_id,
|
||||||
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: maybe only sent on initial login not every zone?
|
||||||
|
// link shell information
|
||||||
|
{
|
||||||
|
let ipc = IPCSegment {
|
||||||
|
unk1: 0,
|
||||||
|
unk2: 0,
|
||||||
|
op_code: IPCOpCode::LinkShellInformation,
|
||||||
|
server_id: 69, // lol
|
||||||
|
timestamp: timestamp_secs(),
|
||||||
|
data: IPCStructData::LinkShellInformation { unk: [0; 456] },
|
||||||
|
};
|
||||||
|
|
||||||
|
self.send_segment(PacketSegment {
|
||||||
|
source_actor: self.player_id,
|
||||||
|
target_actor: self.player_id,
|
||||||
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unk8
|
||||||
|
{
|
||||||
|
let ipc = IPCSegment {
|
||||||
|
unk1: 0,
|
||||||
|
unk2: 0,
|
||||||
|
op_code: IPCOpCode::Unk8,
|
||||||
|
server_id: 69, // lol
|
||||||
|
timestamp: timestamp_secs(),
|
||||||
|
data: IPCStructData::Unk8 { unk: [0; 808] },
|
||||||
|
};
|
||||||
|
|
||||||
|
self.send_segment(PacketSegment {
|
||||||
|
source_actor: self.player_id,
|
||||||
|
target_actor: self.player_id,
|
||||||
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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: self.zone.id,
|
||||||
|
weather_id: 1,
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
self.send_segment(PacketSegment {
|
||||||
|
source_actor: self.player_id,
|
||||||
|
target_actor: self.player_id,
|
||||||
|
segment_type: SegmentType::Ipc { data: ipc },
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::config::get_config;
|
||||||
|
|
||||||
/// Represents a loaded zone
|
/// Represents a loaded zone
|
||||||
pub struct Zone {
|
pub struct Zone {
|
||||||
id: u16,
|
pub id: u16,
|
||||||
layer_group: LayerGroup,
|
layer_group: LayerGroup,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue