From 6190001caa021c54f9c71a0081a061b1e1ec589c Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 22 Mar 2025 17:06:16 -0400 Subject: [PATCH] Remove more hardcoded values for character Since we are now backed by a database, the remaining usages are erroneous and should be removed. --- src/bin/kawari-lobby.rs | 2 -- src/bin/kawari-world.rs | 13 ++++++++----- src/lib.rs | 38 -------------------------------------- src/world/chat_handler.rs | 35 ++++++++++++++++++++++++++++++++--- 4 files changed, 40 insertions(+), 48 deletions(-) diff --git a/src/bin/kawari-lobby.rs b/src/bin/kawari-lobby.rs index 7ec7516..7ec325a 100644 --- a/src/bin/kawari-lobby.rs +++ b/src/bin/kawari-lobby.rs @@ -1,4 +1,3 @@ -use kawari::CONTENT_ID; use kawari::common::custom_ipc::CustomIpcData; use kawari::common::custom_ipc::CustomIpcSegment; use kawari::common::custom_ipc::CustomIpcType; @@ -137,7 +136,6 @@ async fn main() { sequence: character_action.sequence + 1, unk: 0x00010101, details: CharacterDetails { - content_id: CONTENT_ID, character_name: character_action .name .clone(), diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 0b1d885..2f59eb7 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -20,7 +20,7 @@ use kawari::world::{ }, }; use kawari::world::{PlayerData, WorldDatabase}; -use kawari::{CHAR_NAME, CITY_STATE, CONTENT_ID, ZONE_ID, common::timestamp_secs}; +use kawari::{ZONE_ID, common::timestamp_secs}; use physis::common::{Language, Platform}; use physis::gamedata::GameData; use tokio::io::AsyncReadExt; @@ -260,7 +260,7 @@ async fn main() { .chara_make .customize .subrace, - city_state: CITY_STATE, + city_state: chara_details.chara_make.unk6 as u8, // TODO: probably wrong nameday_month: chara_details .chara_make .birth_month @@ -319,7 +319,7 @@ async fn main() { op_code: ServerZoneIpcType::PlayerSpawn, timestamp: timestamp_secs(), data: ServerZoneIpcData::PlayerSpawn(PlayerSpawn { - content_id: CONTENT_ID, + content_id: connection.player_data.content_id, common: CommonSpawn { current_world_id: config.world.world_id, home_world_id: config.world.world_id, @@ -419,13 +419,16 @@ async fn main() { request_type: request.request_type, sequence: request.count, entries: vec![PlayerEntry { - content_id: CONTENT_ID, + // TODO: fill with actual player data, it also shows up wrong in game + content_id: connection + .player_data + .content_id, zone_id: connection.zone.id, zone_id1: 0x0100, class_job: 36, level: 100, one: 1, - name: CHAR_NAME.to_string(), + name: "INVALID".to_string(), fc_tag: "LOCAL".to_string(), ..Default::default() }], diff --git a/src/lib.rs b/src/lib.rs index 8527171..50d6821 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ //! A server replacement for a certain MMO. -use common::CustomizeData; use minijinja::Environment; /// The blowfish implementation used for packet encryption. @@ -31,48 +30,11 @@ pub mod login; /// See the TerritoryType excel sheet for a list of possible IDs. pub const ZONE_ID: u16 = 132; -pub const CONTENT_ID: u64 = 11111111111111111; pub const INVALID_OBJECT_ID: u32 = 0xE0000000; -pub const CUSTOMIZE_DATA: CustomizeData = CustomizeData { - race: 4, - gender: 1, - age: 1, - height: 50, - subrace: 7, - face: 3, - hair: 5, - enable_highlights: 0, - skin_tone: 10, - right_eye_color: 75, - hair_tone: 50, - highlights: 0, - facial_features: 1, - facial_feature_color: 19, - eyebrows: 1, - left_eye_color: 75, - eyes: 1, - nose: 0, - jaw: 1, - mouth: 1, - lips_tone_fur_pattern: 169, - race_feature_size: 100, - race_feature_type: 1, - bust: 100, - face_paint: 0, - face_paint_color: 167, -}; - -pub const DEITY: u8 = 0x8; -pub const NAMEDAY_MONTH: u8 = 0x1; -pub const NAMEDAY_DAY: u8 = 0x1; -pub const CITY_STATE: u8 = 0x3; - /// Maxmimum length of a character's name. pub const CHAR_NAME_MAX_LENGTH: usize = 32; -pub const CHAR_NAME: &str = "Test User"; - pub fn setup_default_environment() -> Environment<'static> { let mut env = Environment::new(); env.add_template("admin.html", include_str!("../templates/admin.html")) diff --git a/src/world/chat_handler.rs b/src/world/chat_handler.rs index e96f529..73e6cbe 100644 --- a/src/world/chat_handler.rs +++ b/src/world/chat_handler.rs @@ -1,6 +1,6 @@ use crate::{ - CHAR_NAME, CUSTOMIZE_DATA, INVALID_OBJECT_ID, - common::timestamp_secs, + INVALID_OBJECT_ID, + common::{CustomizeData, timestamp_secs}, config::get_config, packet::{PacketSegment, SegmentType}, world::ipc::{ @@ -14,6 +14,35 @@ use super::{ ipc::{ChatMessage, Position}, }; +pub const CUSTOMIZE_DATA: CustomizeData = CustomizeData { + race: 4, + gender: 1, + age: 1, + height: 50, + subrace: 7, + face: 3, + hair: 5, + enable_highlights: 0, + skin_tone: 10, + right_eye_color: 75, + hair_tone: 50, + highlights: 0, + facial_features: 1, + facial_feature_color: 19, + eyebrows: 1, + left_eye_color: 75, + eyes: 1, + nose: 0, + jaw: 1, + mouth: 1, + lips_tone_fur_pattern: 169, + race_feature_size: 100, + race_feature_type: 1, + bust: 100, + face_paint: 0, + face_paint_color: 167, +}; + pub struct ChatHandler {} impl ChatHandler { @@ -85,7 +114,7 @@ impl ChatHandler { home_world_id: config.world.world_id, title: 1, class_job: 35, - name: CHAR_NAME.to_string(), + name: "Test Actor".to_string(), hp_curr: 100, hp_max: 100, mp_curr: 100,