1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-05-01 02:47:45 +00:00

Send ClientSelectData JSON, show character in lobby screen

This commit is contained in:
Joshua Goins 2025-03-09 09:40:11 -04:00
parent 7613723151
commit 1013556eba
4 changed files with 192 additions and 3 deletions

View file

@ -1,6 +1,8 @@
use std::cmp::min;
use std::fs::read;
use std::time::{SystemTime, UNIX_EPOCH};
use kawari::client_select_data::{ClientCustomizeData, ClientSelectData};
use kawari::encryption::{blowfish_encode, generate_encryption_key};
use kawari::ipc::{CharacterDetails, IPCOpCode, IPCSegment, IPCStructData, Server, ServiceAccount};
use kawari::packet::{
@ -231,6 +233,61 @@ async fn send_lobby_info(socket: &mut WriteHalf<TcpStream>, state: &State, seque
// now send them the character list
{
let select_data = ClientSelectData {
game_name_unk: "Final Fantasy".to_string(),
version_maybe: 1,
unk1: [0; 30],
unk2: 0,
unk3: 0,
unk4: 0,
unk5: 0,
unk6: 0,
unk7: 0,
unk8: 0,
unk9: 0,
unk10: 0,
unk11: 0,
customize: ClientCustomizeData {
race: 3,
gender: 1,
height: 0,
subrace: 0,
face: 1,
hair: 1,
enable_highlights: 1,
skin_tone: 1,
right_eye_color: 1,
hair_tone: 1,
highlights: 1,
facial_features: 1,
facial_feature_color: 1,
eyebrows: 1,
left_eye_color: 1,
eyes: 1,
nose: 1,
jaw: 1,
mouth: 1,
lips_tone_fur_pattern: 1,
race_feature_size: 1,
race_feature_type: 1,
bust: 0,
face_paint: 1,
face_paint_color: 0,
},
unk12: 0,
unk13: 0,
unk14: [0; 10],
unk15: 0,
unk16: 0,
unk17: 0,
unk18: 0,
unk19: 0,
unk20: 0,
unk21: String::new(),
unk22: 0,
unk23: 0,
};
let mut characters = vec![CharacterDetails {
id: 0,
content_id: 11111111111111111,
@ -241,7 +298,7 @@ async fn send_lobby_info(socket: &mut WriteHalf<TcpStream>, state: &State, seque
character_name: "test".to_string(),
character_server_name: WORLD_NAME.to_string(),
character_server_name1: WORLD_NAME.to_string(),
character_detail_json: "test".to_string(),
character_detail_json: select_data.to_json(),
unk2: [0; 20],
}];
@ -267,8 +324,8 @@ async fn send_lobby_info(socket: &mut WriteHalf<TcpStream>, state: &State, seque
unk6: 0,
veteran_rank: 0,
unk7: 0,
days_subscribed: 0,
remaining_days: 0,
days_subscribed: 5,
remaining_days: 5,
days_to_next_rank: 0,
max_characters_on_world: 0,
unk8: 8,

130
src/client_select_data.rs Normal file
View file

@ -0,0 +1,130 @@
use serde_json::{Value, json};
pub struct ClientCustomizeData {
pub race: i32,
pub gender: i32,
pub height: i32,
pub subrace: i32,
pub face: i32,
pub hair: i32,
pub enable_highlights: i32,
pub skin_tone: i32,
pub right_eye_color: i32,
pub hair_tone: i32,
pub highlights: i32,
pub facial_features: i32,
pub facial_feature_color: i32,
pub eyebrows: i32,
pub left_eye_color: i32,
pub eyes: i32,
pub nose: i32,
pub jaw: i32,
pub mouth: i32,
pub lips_tone_fur_pattern: i32,
pub race_feature_size: i32,
pub race_feature_type: i32,
pub bust: i32,
pub face_paint: i32,
pub face_paint_color: i32,
}
impl ClientCustomizeData {
pub fn to_json(&self) -> Value {
json!([
self.race.to_string(),
self.gender.to_string(),
self.height.to_string(),
self.subrace.to_string(),
self.face.to_string(),
self.enable_highlights.to_string(),
self.skin_tone.to_string(),
self.right_eye_color.to_string(),
self.hair_tone.to_string(),
self.highlights.to_string(),
self.facial_features.to_string(),
self.facial_feature_color.to_string(),
self.eyebrows.to_string(),
self.left_eye_color.to_string(),
self.eyes.to_string(),
self.nose.to_string(),
self.jaw.to_string(),
self.mouth.to_string(),
self.lips_tone_fur_pattern.to_string(),
self.race_feature_size.to_string(),
self.race_feature_type.to_string(),
self.bust.to_string(),
self.face_paint.to_string(),
self.face_paint_color.to_string(),
])
}
}
pub struct ClientSelectData {
pub game_name_unk: String,
pub version_maybe: i32,
pub unk1: [i32; 30],
pub unk2: i32,
pub unk3: i32,
pub unk4: i32,
pub unk5: i32,
pub unk6: i32,
pub unk7: i32,
pub unk8: i32,
pub unk9: i32,
pub unk10: i32,
pub unk11: i32,
pub customize: ClientCustomizeData,
pub unk12: i32,
pub unk13: i32,
pub unk14: [i32; 10],
pub unk15: i32,
pub unk16: i32,
pub unk17: 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.version_maybe.to_string(),
self.unk1.map(|x| x.to_string()),
self.unk2.to_string(),
self.unk3.to_string(),
self.unk4.to_string(),
self.unk5.to_string(),
self.unk6.to_string(),
self.unk7.to_string(),
self.unk8.to_string(),
self.unk9.to_string(),
self.unk10.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.unk17.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_pretty(&obj).unwrap()
}
}

View file

@ -169,6 +169,7 @@ pub enum IPCStructData {
unk1: u8,
unk2: u8,
unk3: u8,
/// Set to 128 if legacy character
unk4: u8,
unk5: [u32; 7],
unk6: u8,

View file

@ -2,6 +2,7 @@ use minijinja::Environment;
use rand::Rng;
use rand::distributions::Alphanumeric;
pub mod client_select_data;
mod common;
pub mod config;
pub mod encryption;