diff --git a/crates/message/src/lib.rs b/crates/message/src/lib.rs index f351152..c1173f3 100644 --- a/crates/message/src/lib.rs +++ b/crates/message/src/lib.rs @@ -17,6 +17,7 @@ pub(crate) mod request; pub(crate) mod response; pub(crate) mod push; pub(crate) mod payload; +pub(crate) mod log; pub use player::*; pub use shared::*; @@ -37,3 +38,4 @@ pub use request::*; pub use response::*; pub use push::*; pub use payload::*; +pub use log::*; diff --git a/crates/message/src/log.rs b/crates/message/src/log.rs new file mode 100644 index 0000000..be031a7 --- /dev/null +++ b/crates/message/src/log.rs @@ -0,0 +1,65 @@ +use serde::{Deserialize, Serialize}; + +use crate::Location; + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RequestUseItemLogParams { + pub used_items: Vec, + pub location: Location, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RequestUseItemLogParamsEntry { + pub item_id: u32, + pub times_used: u32, + pub unk3: u32, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RequestGetItemLogParams { + pub acquired_items: Vec, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RequestGetItemLogParamsEntry { + pub location: Location, + pub item_category: u32, + pub item_id: u32, + pub quantity: u32, + pub unk1: u32, + pub unk2: u32, + pub unk3: u32, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RequestKillEnemyLogParams { + pub killed_enemies: Vec, + pub location: Location, +} + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct RequestKillEnemyLogParamsEntry { + pub npc_param: u32, + pub killed_count: u32, +} +#[cfg(test)] +mod test { + use waygate_wire::deserialize; + use crate::RequestUseItemLogParams; + + #[test] + fn deserialize_use_item_log() { + let deserialized: RequestUseItemLogParams = deserialize( + include_bytes!("../test/data/RequestUseItemLog.bin"), + ).unwrap(); + + assert_eq!(deserialized.used_items.len(), 1); + assert_eq!(deserialized.used_items[0].item_id, 101); + assert_eq!(deserialized.used_items[0].times_used, 1); + assert_eq!(deserialized.used_items[0].unk3, 1); + assert_eq!(deserialized.location.map, 60423600); + assert_eq!(deserialized.location.x, -45.939575); + assert_eq!(deserialized.location.y, 92.36392); + assert_eq!(deserialized.location.z, 79.65545); + } +} diff --git a/crates/message/src/player.rs b/crates/message/src/player.rs index 4e88621..dae27ad 100755 --- a/crates/message/src/player.rs +++ b/crates/message/src/player.rs @@ -5,7 +5,7 @@ use super::*; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct RequestUpdatePlayerStatusParams { pub unk1: u32, - pub map_id: u32, + pub play_region: u32, pub unk2: u32, pub death_count: u32, pub total_summon_count: u32, @@ -57,20 +57,13 @@ pub struct CharacterData { pub max_reinforce_level: u32, pub unk20: u32, - // This is cursed. Apparently serde only takes u8 arrays of size n % 8 - //pub unk21: [u8; 0x27], - pub unk21: [u8; 0x20], - pub wtf1: u8, - pub wtf2: u8, - pub wtf3: u8, - pub wtf4: u8, - pub wtf5: u8, - pub wtf6: u8, - pub wtf7: u8, + pub unk21: [u8; 0x1b], + pub unk_vec: Vec, + pub unk22: u32, pub password: String, pub group_passwords: Vec, - pub unk22: u16, + pub unk23: u16, pub unk24: u8, pub unk25: u8, pub sites_of_grace: Vec, @@ -106,12 +99,12 @@ pub struct CharacterDataAttributes { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct CharacterDataAttack { - pub right_armament_primary: u32, - pub right_armament_secondary: u32, - pub right_armament_tertiary: u32, - pub left_armament_primary: u32, - pub left_armament_secondary: u32, - pub left_armament_tertiary: u32, + pub right_armament_primary: i32, + pub right_armament_secondary: i32, + pub right_armament_tertiary: i32, + pub left_armament_primary: i32, + pub left_armament_secondary: i32, + pub left_armament_tertiary: i32, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -154,73 +147,30 @@ pub struct SiteOfGrace { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct EquippedWeapon { - pub weapon: u32, - pub ash_of_war: u32, + pub weapon: i32, + pub ash_of_war: i32, } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct EquippedProtector { - pub protector: u32, - pub unk: u32, + pub protector: i32, + pub unk: i32, } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct CharacterEquipment { pub weapons_left_hand: Vec, pub weapons_right_hand: Vec, - pub head: EquippedProtector, pub chest: EquippedProtector, pub arms: EquippedProtector, pub legs: EquippedProtector, - - pub accessories: Vec, - pub quickslots: Vec, - pub menuslots: Vec, - pub arrows: Vec, - pub bolts: Vec, - pub spells: Vec, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct RequestUseItemLogParams { - pub used_items: Vec, - pub location: Location, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct RequestUseItemLogParamsEntry { - pub item_id: u32, - pub times_used: u32, - pub unk3: u32, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct RequestGetItemLogParams { - pub acquired_items: Vec, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct RequestGetItemLogParamsEntry { - pub location: Location, - pub item_category: u32, - pub item_id: u32, - pub quantity: u32, - pub unk1: u32, - pub unk2: u32, - pub unk3: u32, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct RequestKillEnemyLogParams { - pub killed_enemies: Vec, - pub location: Location, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct RequestKillEnemyLogParamsEntry { - pub npc_param: u32, - pub killed_count: u32, + pub accessories: Vec, + pub quickslots: Vec, + pub pouchslots: Vec, + pub arrows: Vec, + pub bolts: Vec, + pub spells: Vec, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -232,25 +182,3 @@ pub struct RequestJoinMultiplayParams { pub unk5: u32, pub unk6: u32, } - -#[cfg(test)] -mod test { - use waygate_wire::deserialize; - use crate::{ObjectIdentifier, RequestUpdateSignParams, RequestUseItemLogParams}; - - #[test] - fn deserialize_use_item_log() { - let deserialized: RequestUseItemLogParams = deserialize( - include_bytes!("../test/data/RequestUseItemLog.bin"), - ).unwrap(); - - assert_eq!(deserialized.used_items.len(), 1); - assert_eq!(deserialized.used_items[0].item_id, 101); - assert_eq!(deserialized.used_items[0].times_used, 1); - assert_eq!(deserialized.used_items[0].unk3, 1); - assert_eq!(deserialized.location.map, 60423600); - assert_eq!(deserialized.location.x, -45.939575); - assert_eq!(deserialized.location.y, 92.36392); - assert_eq!(deserialized.location.z, 79.65545); - } -} diff --git a/crates/message/src/request.rs b/crates/message/src/request.rs index 97c5300..0ed8e93 100755 --- a/crates/message/src/request.rs +++ b/crates/message/src/request.rs @@ -51,15 +51,15 @@ pub enum RequestParams { DieLog, UseMagicLog, UseGestureLog, - UseItemLog(Box), + UseItemLog(Box), PurchaseItemLog, - GetItemLog(Box), + GetItemLog(Box), DropItemLog, LeaveItemLog, SaleItemLog, CreateItemLog, SummonBuddyLog, - KillEnemyLog(Box), + KillEnemyLog(Box), KillBossLog, GlobalEventLog, DiscoverMapPointLog, diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 7835fc2..c5a9668 100755 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -175,4 +175,3 @@ async fn handle_connection( client.serve().await?; } } -