mirror of
https://github.com/redstrate/Kawari.git
synced 2025-04-29 09:57:46 +00:00
Move more structs out of the root src/ folder and into their respective server
This commit is contained in:
parent
bdef7752b0
commit
23050e7b95
12 changed files with 96 additions and 90 deletions
|
@ -1,6 +1,6 @@
|
|||
use kawari::CONTENT_ID;
|
||||
use kawari::chara_make::CharaMake;
|
||||
use kawari::ipc::{CharacterDetails, IPCOpCode, IPCSegment, IPCStructData, LobbyCharacterAction};
|
||||
use kawari::lobby::chara_make::CharaMake;
|
||||
use kawari::lobby::connection::LobbyConnection;
|
||||
use kawari::oodle::FFXIVOodle;
|
||||
use kawari::packet::{PacketSegment, SegmentType, State, send_keep_alive};
|
||||
|
|
|
@ -9,7 +9,7 @@ use kawari::world::{
|
|||
};
|
||||
use kawari::{
|
||||
CHAR_NAME, CITY_STATE, CONTENT_ID, CUSTOMIZE_DATA, DEITY, NAMEDAY_DAY, NAMEDAY_MONTH, WORLD_ID,
|
||||
ZONE_ID, timestamp_secs,
|
||||
ZONE_ID, common::timestamp_secs,
|
||||
};
|
||||
use tokio::io::AsyncReadExt;
|
||||
use tokio::net::TcpListener;
|
||||
|
|
|
@ -3,7 +3,7 @@ use serde_json::{Value, json};
|
|||
|
||||
#[binrw]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ClientCustomizeData {
|
||||
pub struct CustomizeData {
|
||||
pub race: u8,
|
||||
pub gender: u8,
|
||||
pub age: u8,
|
||||
|
@ -32,7 +32,7 @@ pub struct ClientCustomizeData {
|
|||
pub face_paint_color: u8,
|
||||
}
|
||||
|
||||
impl ClientCustomizeData {
|
||||
impl CustomizeData {
|
||||
pub fn to_json(&self) -> Value {
|
||||
json!([
|
||||
self.race.to_string(),
|
||||
|
@ -95,74 +95,3 @@ impl ClientCustomizeData {
|
|||
}
|
||||
}
|
||||
}
|
||||
/// See https://github.com/aers/FFXIVClientStructs/blob/main/FFXIVClientStructs/FFXIV/Application/Network/WorkDefinitions/ClientSelectData.cs
|
||||
pub struct ClientSelectData {
|
||||
pub game_name_unk: String,
|
||||
pub current_class: i32,
|
||||
pub class_levels: [i32; 30],
|
||||
pub race: i32,
|
||||
pub subrace: i32,
|
||||
pub gender: i32,
|
||||
pub birth_month: i32,
|
||||
pub birth_day: i32,
|
||||
pub guardian: i32,
|
||||
pub unk8: i32,
|
||||
pub unk9: i32,
|
||||
pub zone_id: i32,
|
||||
pub unk11: i32,
|
||||
pub customize: ClientCustomizeData,
|
||||
pub unk12: i32,
|
||||
pub unk13: i32,
|
||||
pub unk14: [i32; 10], // probably model ids
|
||||
pub unk15: i32,
|
||||
pub unk16: i32,
|
||||
/// If set to 1, the user is granted one opportunity to edit their character and are prompted to re-choose their class.
|
||||
pub legacy_character: i32,
|
||||
pub unk18: i32,
|
||||
pub unk19: i32,
|
||||
pub unk20: i32,
|
||||
pub unk21: String,
|
||||
pub unk22: i32,
|
||||
pub unk23: i32,
|
||||
}
|
||||
|
||||
impl ClientSelectData {
|
||||
pub fn to_json(&self) -> String {
|
||||
let content = json!([
|
||||
self.game_name_unk,
|
||||
self.current_class.to_string(),
|
||||
self.class_levels.map(|x| x.to_string()),
|
||||
self.race.to_string(),
|
||||
self.subrace.to_string(),
|
||||
self.gender.to_string(),
|
||||
self.birth_month.to_string(),
|
||||
self.birth_day.to_string(),
|
||||
self.guardian.to_string(),
|
||||
self.unk8.to_string(),
|
||||
self.unk9.to_string(),
|
||||
self.zone_id.to_string(),
|
||||
self.unk11.to_string(),
|
||||
self.customize.to_json(),
|
||||
self.unk12.to_string(),
|
||||
self.unk13.to_string(),
|
||||
self.unk14.map(|x| x.to_string()),
|
||||
self.unk15.to_string(),
|
||||
self.unk16.to_string(),
|
||||
self.legacy_character.to_string(),
|
||||
self.unk18.to_string(),
|
||||
self.unk19.to_string(),
|
||||
self.unk20.to_string(),
|
||||
self.unk21,
|
||||
self.unk22.to_string(),
|
||||
self.unk23.to_string(),
|
||||
]);
|
||||
|
||||
let obj = json!({
|
||||
"content": content,
|
||||
"classname": "ClientSelectData",
|
||||
"classid": 116,
|
||||
});
|
||||
|
||||
serde_json::to_string(&obj).unwrap()
|
||||
}
|
||||
}
|
|
@ -3,6 +3,9 @@ use std::{
|
|||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
mod customize_data;
|
||||
pub use customize_data::CustomizeData;
|
||||
|
||||
pub(crate) fn read_string(byte_stream: Vec<u8>) -> String {
|
||||
let str = String::from_utf8(byte_stream).unwrap();
|
||||
str.trim_matches(char::from(0)).to_string() // trim \0 from the end of strings
|
|
@ -239,7 +239,7 @@ pub enum IPCStructData {
|
|||
ClientVersionInfo {
|
||||
sequence: u64,
|
||||
|
||||
#[brw(pad_before = 14)] // full of nonsense i don't understand yet
|
||||
#[brw(pad_before = 10)] // full of nonsense i don't understand yet
|
||||
#[br(count = 64)]
|
||||
#[br(map = read_string)]
|
||||
#[bw(ignore)]
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
use client_select_data::ClientCustomizeData;
|
||||
use common::CustomizeData;
|
||||
use minijinja::Environment;
|
||||
use rand::Rng;
|
||||
use rand::distributions::Alphanumeric;
|
||||
|
||||
pub mod blowfish;
|
||||
pub mod chara_make;
|
||||
pub mod client_select_data;
|
||||
mod common;
|
||||
pub use common::timestamp_secs;
|
||||
pub mod common;
|
||||
mod compression;
|
||||
pub mod config;
|
||||
pub mod encryption;
|
||||
|
@ -27,7 +24,7 @@ pub const ZONE_ID: u16 = 132;
|
|||
|
||||
pub const CONTENT_ID: u64 = 11111111111111111;
|
||||
|
||||
pub const CUSTOMIZE_DATA: ClientCustomizeData = ClientCustomizeData {
|
||||
pub const CUSTOMIZE_DATA: CustomizeData = CustomizeData {
|
||||
race: 4,
|
||||
gender: 1,
|
||||
age: 1,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use serde_json::Value;
|
||||
|
||||
use crate::client_select_data::ClientCustomizeData;
|
||||
use crate::common::CustomizeData;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CharaMake {
|
||||
pub customize: ClientCustomizeData,
|
||||
pub customize: CustomizeData,
|
||||
pub unk1: i32, // always 1?
|
||||
pub guardian: i32,
|
||||
pub birth_month: i32,
|
||||
|
@ -19,7 +19,7 @@ impl CharaMake {
|
|||
let content = &v["content"];
|
||||
|
||||
Self {
|
||||
customize: ClientCustomizeData::from_json(&content[0]),
|
||||
customize: CustomizeData::from_json(&content[0]),
|
||||
unk1: content[1].as_str().unwrap().parse::<i32>().unwrap(),
|
||||
guardian: content[2].as_str().unwrap().parse::<i32>().unwrap(),
|
||||
birth_month: content[3].as_str().unwrap().parse::<i32>().unwrap(),
|
75
src/lobby/client_select_data.rs
Normal file
75
src/lobby/client_select_data.rs
Normal file
|
@ -0,0 +1,75 @@
|
|||
use serde_json::json;
|
||||
|
||||
use crate::common::CustomizeData;
|
||||
|
||||
/// See https://github.com/aers/FFXIVClientStructs/blob/main/FFXIVClientStructs/FFXIV/Application/Network/WorkDefinitions/ClientSelectData.cs
|
||||
pub struct ClientSelectData {
|
||||
pub game_name_unk: String,
|
||||
pub current_class: i32,
|
||||
pub class_levels: [i32; 30],
|
||||
pub race: i32,
|
||||
pub subrace: i32,
|
||||
pub gender: i32,
|
||||
pub birth_month: i32,
|
||||
pub birth_day: i32,
|
||||
pub guardian: i32,
|
||||
pub unk8: i32,
|
||||
pub unk9: i32,
|
||||
pub zone_id: i32,
|
||||
pub unk11: i32,
|
||||
pub customize: CustomizeData,
|
||||
pub unk12: i32,
|
||||
pub unk13: i32,
|
||||
pub unk14: [i32; 10], // probably model ids
|
||||
pub unk15: i32,
|
||||
pub unk16: i32,
|
||||
/// If set to 1, the user is granted one opportunity to edit their character and are prompted to re-choose their class.
|
||||
pub legacy_character: i32,
|
||||
pub unk18: i32,
|
||||
pub unk19: i32,
|
||||
pub unk20: i32,
|
||||
pub unk21: String,
|
||||
pub unk22: i32,
|
||||
pub unk23: i32,
|
||||
}
|
||||
|
||||
impl ClientSelectData {
|
||||
pub fn to_json(&self) -> String {
|
||||
let content = json!([
|
||||
self.game_name_unk,
|
||||
self.current_class.to_string(),
|
||||
self.class_levels.map(|x| x.to_string()),
|
||||
self.race.to_string(),
|
||||
self.subrace.to_string(),
|
||||
self.gender.to_string(),
|
||||
self.birth_month.to_string(),
|
||||
self.birth_day.to_string(),
|
||||
self.guardian.to_string(),
|
||||
self.unk8.to_string(),
|
||||
self.unk9.to_string(),
|
||||
self.zone_id.to_string(),
|
||||
self.unk11.to_string(),
|
||||
self.customize.to_json(),
|
||||
self.unk12.to_string(),
|
||||
self.unk13.to_string(),
|
||||
self.unk14.map(|x| x.to_string()),
|
||||
self.unk15.to_string(),
|
||||
self.unk16.to_string(),
|
||||
self.legacy_character.to_string(),
|
||||
self.unk18.to_string(),
|
||||
self.unk19.to_string(),
|
||||
self.unk20.to_string(),
|
||||
self.unk21,
|
||||
self.unk22.to_string(),
|
||||
self.unk23.to_string(),
|
||||
]);
|
||||
|
||||
let obj = json!({
|
||||
"content": content,
|
||||
"classname": "ClientSelectData",
|
||||
"classid": 116,
|
||||
});
|
||||
|
||||
serde_json::to_string(&obj).unwrap()
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ use crate::{
|
|||
CHAR_NAME, CONTENT_ID, CUSTOMIZE_DATA, DEITY, NAMEDAY_DAY, NAMEDAY_MONTH, WORLD_ID, WORLD_NAME,
|
||||
ZONE_ID,
|
||||
blowfish::Blowfish,
|
||||
client_select_data::ClientSelectData,
|
||||
common::timestamp_secs,
|
||||
encryption::generate_encryption_key,
|
||||
ipc::{CharacterDetails, IPCOpCode, IPCSegment, IPCStructData, Server, ServiceAccount},
|
||||
|
@ -16,6 +15,8 @@ use crate::{
|
|||
},
|
||||
};
|
||||
|
||||
use super::client_select_data::ClientSelectData;
|
||||
|
||||
pub struct LobbyConnection {
|
||||
pub socket: TcpStream,
|
||||
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
pub mod chara_make;
|
||||
mod client_select_data;
|
||||
pub mod connection;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{
|
||||
CHAR_NAME, CUSTOMIZE_DATA, WORLD_ID,
|
||||
common::timestamp_secs,
|
||||
ipc::{IPCOpCode, IPCSegment, IPCStructData},
|
||||
packet::{PacketSegment, SegmentType},
|
||||
timestamp_secs,
|
||||
world::PlayerSpawn,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use binrw::binrw;
|
||||
|
||||
use crate::CHAR_NAME_MAX_LENGTH;
|
||||
use crate::client_select_data::ClientCustomizeData;
|
||||
use crate::common::{read_string, write_string};
|
||||
use crate::common::{CustomizeData, read_string, write_string};
|
||||
|
||||
use super::position::Position;
|
||||
use super::status_effect::StatusEffect;
|
||||
|
@ -103,7 +102,7 @@ pub struct PlayerSpawn {
|
|||
#[br(map = read_string)]
|
||||
#[bw(map = write_string)]
|
||||
pub name: String,
|
||||
pub look: ClientCustomizeData,
|
||||
pub look: CustomizeData,
|
||||
#[br(count = 6)]
|
||||
#[bw(pad_size_to = 6)]
|
||||
#[br(map = read_string)]
|
||||
|
|
Loading…
Add table
Reference in a new issue