diff --git a/src/common/workdefinitions/client_select_data.rs b/src/common/workdefinitions/client_select_data.rs index de6f48d..6cb2ac9 100644 --- a/src/common/workdefinitions/client_select_data.rs +++ b/src/common/workdefinitions/client_select_data.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use serde_json::json; -use crate::common::CustomizeData; +use crate::{CLASSJOB_ARRAY_SIZE, common::CustomizeData}; // TODO: this isn't really an enum in the game, nor is it a flag either. it's weird! #[derive(Debug, Clone, Copy, Deserialize, Serialize)] @@ -39,7 +39,7 @@ impl rusqlite::types::FromSql for RemakeMode { pub struct ClientSelectData { pub character_name: String, pub current_class: i32, - pub class_levels: [i32; 32], + pub class_levels: [i32; CLASSJOB_ARRAY_SIZE], pub race: i32, pub subrace: i32, pub gender: i32, diff --git a/src/ipc/zone/player_setup.rs b/src/ipc/zone/player_setup.rs index 129b9c3..cd702da 100644 --- a/src/ipc/zone/player_setup.rs +++ b/src/ipc/zone/player_setup.rs @@ -1,7 +1,7 @@ use binrw::binrw; use crate::{ - AETHERYTE_UNLOCK_BITMASK_SIZE, UNLOCK_BITMASK_SIZE, + AETHERYTE_UNLOCK_BITMASK_SIZE, CLASSJOB_ARRAY_SIZE, UNLOCK_BITMASK_SIZE, common::{CHAR_NAME_MAX_LENGTH, read_string, write_string}, }; @@ -64,13 +64,13 @@ pub struct PlayerStatus { pub sightseeing21_to_80_unlock: u8, pub sightseeing_heavensward_unlock: u8, pub unknown9e: [u8; 26], - pub exp: [u32; 32], + pub exp: [u32; CLASSJOB_ARRAY_SIZE], pub pvp_total_exp: u32, pub unknown_pvp124: u32, pub pvp_exp: u32, pub pvp_frontline_overall_ranks: [u32; 3], pub unknown138: u32, - pub levels: [u16; 32], + pub levels: [u16; CLASSJOB_ARRAY_SIZE], #[br(count = 218)] #[bw(pad_size_to = 218)] pub unknown194: Vec, diff --git a/src/lib.rs b/src/lib.rs index 70a6173..8ea7f2c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,6 +76,9 @@ pub const AETHERYTE_UNLOCK_BITMASK_SIZE: usize = 30; /// The size of the completed quest bitmask. pub const COMPLETED_QUEST_BITMASK_SIZE: usize = 691; +/// The size of various classjob arrays. +pub const CLASSJOB_ARRAY_SIZE: usize = 32; + /// The maximum durability of an item. pub const ITEM_CONDITION_MAX: u16 = 30000; diff --git a/src/world/connection.rs b/src/world/connection.rs index 6cbf7e0..e329e78 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -9,7 +9,7 @@ use mlua::Function; use tokio::net::TcpStream; use crate::{ - COMPLETED_QUEST_BITMASK_SIZE, + CLASSJOB_ARRAY_SIZE, COMPLETED_QUEST_BITMASK_SIZE, common::{ GameData, ObjectId, ObjectTypeId, Position, timestamp_secs, value_to_flag_byte_index_value, }, @@ -62,8 +62,8 @@ pub struct PlayerData { pub account_id: u32, pub classjob_id: u8, - pub classjob_levels: [i32; 32], - pub classjob_exp: [u32; 32], + pub classjob_levels: [i32; CLASSJOB_ARRAY_SIZE], + pub classjob_exp: [u32; CLASSJOB_ARRAY_SIZE], pub curr_hp: u32, pub max_hp: u32, pub curr_mp: u16, diff --git a/src/world/database.rs b/src/world/database.rs index e5ce0f7..8722479 100644 --- a/src/world/database.rs +++ b/src/world/database.rs @@ -4,7 +4,8 @@ use rusqlite::Connection; use serde::Deserialize; use crate::{ - AETHERYTE_UNLOCK_BITMASK_SIZE, COMPLETED_QUEST_BITMASK_SIZE, UNLOCK_BITMASK_SIZE, + AETHERYTE_UNLOCK_BITMASK_SIZE, CLASSJOB_ARRAY_SIZE, COMPLETED_QUEST_BITMASK_SIZE, + UNLOCK_BITMASK_SIZE, common::{ CustomizeData, GameData, Position, workdefinitions::{CharaMake, ClientSelectData, RemakeMode}, @@ -305,8 +306,8 @@ impl WorldDatabase { inventory: row.get(5)?, gm_rank: row.get(6)?, classjob_id: row.get(7)?, - classjob_levels: json_unpack::<[i32; 32]>(row.get(8)?), - classjob_exp: json_unpack::<[u32; 32]>(row.get(9)?), + classjob_levels: json_unpack::<[i32; CLASSJOB_ARRAY_SIZE]>(row.get(8)?), + classjob_exp: json_unpack::<[u32; CLASSJOB_ARRAY_SIZE]>(row.get(9)?), unlocks: json_unpack::>(row.get(10)?), aetherytes: json_unpack::>(row.get(11)?), completed_quests: json_unpack::>(row.get(12)?), @@ -397,7 +398,7 @@ impl WorldDatabase { inventory: Inventory, remake_mode: RemakeMode, classjob_id: i32, - classjob_levels: [i32; 32], + classjob_levels: [i32; CLASSJOB_ARRAY_SIZE], } let result: Result = @@ -409,7 +410,7 @@ impl WorldDatabase { inventory: row.get(3)?, remake_mode: row.get(4)?, classjob_id: row.get(5)?, - classjob_levels: json_unpack::<[i32; 32]>(row.get(6)?), + classjob_levels: json_unpack::<[i32; CLASSJOB_ARRAY_SIZE]>(row.get(6)?), }) }); @@ -490,10 +491,10 @@ impl WorldDatabase { // fill out the initial classjob let chara_make = CharaMake::from_json(chara_make_str); - let mut classjob_levels = [0i32; 32]; + let mut classjob_levels = [0i32; CLASSJOB_ARRAY_SIZE]; classjob_levels[chara_make.classjob_id as usize] = 1; // inital level - let classjob_exp = [0u32; 32]; + let classjob_exp = [0u32; CLASSJOB_ARRAY_SIZE]; // fill out initial unlocks let unlocks = vec![0u8; UNLOCK_BITMASK_SIZE];