From a8cdeb1fd8b52871123788e153203bb896ef51d0 Mon Sep 17 00:00:00 2001 From: lcdr Date: Mon, 22 Feb 2021 16:52:41 +0100 Subject: [PATCH] Add support for vendor component --- examples/capture_parser/main.rs | 3 +- examples/capture_parser/zip_context.rs | 123 +++++------------- src/raknet/client/replica/mod.rs | 1 + .../replica/tests/VendorConstruction.bin | 1 + .../replica/tests/VendorConstruction.rs | 6 + src/raknet/client/replica/vendor.rs | 33 +++++ 6 files changed, 76 insertions(+), 91 deletions(-) create mode 100644 src/raknet/client/replica/tests/VendorConstruction.bin create mode 100644 src/raknet/client/replica/tests/VendorConstruction.rs create mode 100644 src/raknet/client/replica/vendor.rs diff --git a/examples/capture_parser/main.rs b/examples/capture_parser/main.rs index dd8cb05..e14eec4 100644 --- a/examples/capture_parser/main.rs +++ b/examples/capture_parser/main.rs @@ -20,7 +20,7 @@ use self::zip_context::ZipContext; static mut PRINT_PACKETS: bool = false; -const COMP_ORDER : [u32; 18] = [1, 3, 40, 98, 7, 110, 109, 106, 4, 17, 5, 9, 60, 48, 6, 2, 44, 107]; +const COMP_ORDER : [u32; 19] = [1, 3, 40, 98, 7, 110, 109, 106, 4, 17, 5, 9, 60, 48, 16, 6, 2, 44, 107]; pub struct Cdclient { conn: Connection, @@ -152,6 +152,7 @@ fn parse(path: &Path, cdclient: &mut Cdclient) -> Res { && !file.name().contains("[1647]") && !file.name().contains("[1648]")) || (file.name().contains("[24]") + && !file.name().contains("(4930)") && !file.name().contains("(5958)") && !file.name().contains("(6267)") && !file.name().contains("(6010)") diff --git a/examples/capture_parser/zip_context.rs b/examples/capture_parser/zip_context.rs index 91a2601..35b2db5 100644 --- a/examples/capture_parser/zip_context.rs +++ b/examples/capture_parser/zip_context.rs @@ -22,6 +22,7 @@ use lu_packets::{ simple_physics::{SimplePhysicsConstruction, SimplePhysicsSerialization}, script::ScriptConstruction, skill::SkillConstruction, + vendor::{VendorConstruction, VendorSerialization}, }, world::Lot, }; @@ -52,57 +53,24 @@ impl ReplicaContext for ZipContext<'_> { let mut constrs: Vec) -> Res>> = vec![]; for comp in comps { match comp { - 1 => { - constrs.push(|x| Ok(Box::new(ControllablePhysicsConstruction::deserialize(x)?))); - } - 3 => { - constrs.push(|x| Ok(Box::new(SimplePhysicsConstruction::deserialize(x)?))); - } - 4 => { - constrs.push(|x| Ok(Box::new(CharacterConstruction::deserialize(x)?))); - } - 5 => { - constrs.push(|x| Ok(Box::new(ScriptConstruction::deserialize(x)?))); - } - 6 => { - constrs.push(|x| Ok(Box::new(BouncerConstruction::deserialize(x)?))); - } - 7 => { - constrs.push(|x| Ok(Box::new(DestroyableConstruction::deserialize(x)?))); - } - 9 => { - constrs.push(|x| Ok(Box::new(SkillConstruction::deserialize(x)?))); - } - 17 => { - constrs.push(|x| Ok(Box::new(InventoryConstruction::deserialize(x)?))); - } - 40 => { - constrs.push(|x| Ok(Box::new(PhantomPhysicsConstruction::deserialize(x)?))); - } - 44 => { - constrs.push(|x| Ok(Box::new(FxConstruction::deserialize(x)?))); - } - 48 => { - constrs.push(|x| Ok(Box::new(QuickbuildConstruction::deserialize(x)?))); - } - 60 => { - constrs.push(|x| Ok(Box::new(BaseCombatAiConstruction::deserialize(x)?))); - } - 98 => { - constrs.push(|x| Ok(Box::new(BuffConstruction::deserialize(x)?))); - } - 106 => { - constrs.push(|x| Ok(Box::new(PlayerForcedMovementConstruction::deserialize(x)?))); - } - 107 => { - constrs.push(|x| Ok(Box::new(BbbConstruction::deserialize(x)?))); - } - 109 => { - constrs.push(|x| Ok(Box::new(LevelProgressionConstruction::deserialize(x)?))); - } - 110 => { - constrs.push(|x| Ok(Box::new(PossessionControlConstruction::deserialize(x)?))); - } + 1 => { constrs.push(|x| Ok(Box::new(ControllablePhysicsConstruction::deserialize(x)?))); } + 3 => { constrs.push(|x| Ok(Box::new(SimplePhysicsConstruction::deserialize(x)?))); } + 4 => { constrs.push(|x| Ok(Box::new(CharacterConstruction::deserialize(x)?))); } + 5 => { constrs.push(|x| Ok(Box::new(ScriptConstruction::deserialize(x)?))); } + 6 => { constrs.push(|x| Ok(Box::new(BouncerConstruction::deserialize(x)?))); } + 7 => { constrs.push(|x| Ok(Box::new(DestroyableConstruction::deserialize(x)?))); } + 9 => { constrs.push(|x| Ok(Box::new(SkillConstruction::deserialize(x)?))); } + 16 => { constrs.push(|x| Ok(Box::new(VendorConstruction::deserialize(x)?))); } + 17 => { constrs.push(|x| Ok(Box::new(InventoryConstruction::deserialize(x)?))); } + 40 => { constrs.push(|x| Ok(Box::new(PhantomPhysicsConstruction::deserialize(x)?))); } + 44 => { constrs.push(|x| Ok(Box::new(FxConstruction::deserialize(x)?))); } + 48 => { constrs.push(|x| Ok(Box::new(QuickbuildConstruction::deserialize(x)?))); } + 60 => { constrs.push(|x| Ok(Box::new(BaseCombatAiConstruction::deserialize(x)?))); } + 98 => { constrs.push(|x| Ok(Box::new(BuffConstruction::deserialize(x)?))); } + 106 => { constrs.push(|x| Ok(Box::new(PlayerForcedMovementConstruction::deserialize(x)?))); } + 107 => { constrs.push(|x| Ok(Box::new(BbbConstruction::deserialize(x)?))); } + 109 => { constrs.push(|x| Ok(Box::new(LevelProgressionConstruction::deserialize(x)?))); } + 110 => { constrs.push(|x| Ok(Box::new(PossessionControlConstruction::deserialize(x)?))); } 2 | 31 | 35 | 55 | 56 | 64 | 68 | 73 => {}, x => panic!("{}", x), } @@ -119,45 +87,20 @@ impl ReplicaContext for ZipContext<'_> { let mut sers: Vec) -> Res>> = vec![]; for comp in comps { match comp { - 1 => { - sers.push(|x| Ok(Box::new(ControllablePhysicsSerialization::deserialize(x)?))); - } - 3 => { - sers.push(|x| Ok(Box::new(SimplePhysicsSerialization::deserialize(x)?))); - } - 4 => { - sers.push(|x| Ok(Box::new(CharacterSerialization::deserialize(x)?))); - } - 6 => { - sers.push(|x| Ok(Box::new(BouncerSerialization::deserialize(x)?))); - } - 7 => { - sers.push(|x| Ok(Box::new(DestroyableSerialization::deserialize(x)?))); - } - 17 => { - sers.push(|x| Ok(Box::new(InventorySerialization::deserialize(x)?))); - } - 40 => { - sers.push(|x| Ok(Box::new(PhantomPhysicsSerialization::deserialize(x)?))); - } - 48 => { - sers.push(|x| Ok(Box::new(QuickbuildSerialization::deserialize(x)?))); - } - 60 => { - sers.push(|x| Ok(Box::new(BaseCombatAiSerialization::deserialize(x)?))); - } - 106 => { - sers.push(|x| Ok(Box::new(PlayerForcedMovementSerialization::deserialize(x)?))); - } - 107 => { - sers.push(|x| Ok(Box::new(BbbSerialization::deserialize(x)?))); - } - 109 => { - sers.push(|x| Ok(Box::new(LevelProgressionSerialization::deserialize(x)?))); - } - 110 => { - sers.push(|x| Ok(Box::new(PossessionControlSerialization::deserialize(x)?))); - } + 1 => { sers.push(|x| Ok(Box::new(ControllablePhysicsSerialization::deserialize(x)?))); } + 3 => { sers.push(|x| Ok(Box::new(SimplePhysicsSerialization::deserialize(x)?))); } + 4 => { sers.push(|x| Ok(Box::new(CharacterSerialization::deserialize(x)?))); } + 6 => { sers.push(|x| Ok(Box::new(BouncerSerialization::deserialize(x)?))); } + 7 => { sers.push(|x| Ok(Box::new(DestroyableSerialization::deserialize(x)?))); } + 16 => { sers.push(|x| Ok(Box::new(VendorSerialization::deserialize(x)?))); } + 17 => { sers.push(|x| Ok(Box::new(InventorySerialization::deserialize(x)?))); } + 40 => { sers.push(|x| Ok(Box::new(PhantomPhysicsSerialization::deserialize(x)?))); } + 48 => { sers.push(|x| Ok(Box::new(QuickbuildSerialization::deserialize(x)?))); } + 60 => { sers.push(|x| Ok(Box::new(BaseCombatAiSerialization::deserialize(x)?))); } + 106 => { sers.push(|x| Ok(Box::new(PlayerForcedMovementSerialization::deserialize(x)?))); } + 107 => { sers.push(|x| Ok(Box::new(BbbSerialization::deserialize(x)?))); } + 109 => { sers.push(|x| Ok(Box::new(LevelProgressionSerialization::deserialize(x)?))); } + 110 => { sers.push(|x| Ok(Box::new(PossessionControlSerialization::deserialize(x)?))); } 2 | 5 | 9 | 31 | 35 | 44 | 55 | 56 | 64 | 68 | 73 | 98 => {}, x => panic!("{}", x), } diff --git a/src/raknet/client/replica/mod.rs b/src/raknet/client/replica/mod.rs index 3e45c2b..7f53378 100644 --- a/src/raknet/client/replica/mod.rs +++ b/src/raknet/client/replica/mod.rs @@ -15,6 +15,7 @@ pub mod quickbuild; pub mod script; pub mod simple_physics; pub mod skill; +pub mod vendor; use std::fmt::Debug; use std::io::{Read, Result as Res, Write}; diff --git a/src/raknet/client/replica/tests/VendorConstruction.bin b/src/raknet/client/replica/tests/VendorConstruction.bin new file mode 100644 index 0000000..eda5949 --- /dev/null +++ b/src/raknet/client/replica/tests/VendorConstruction.bin @@ -0,0 +1 @@ +à \ No newline at end of file diff --git a/src/raknet/client/replica/tests/VendorConstruction.rs b/src/raknet/client/replica/tests/VendorConstruction.rs new file mode 100644 index 0000000..3124a7b --- /dev/null +++ b/src/raknet/client/replica/tests/VendorConstruction.rs @@ -0,0 +1,6 @@ +VendorConstruction { + vendor_info: Some(VendorInfo { + has_standard_items: true, + has_multicost_items: true, + }), +} diff --git a/src/raknet/client/replica/vendor.rs b/src/raknet/client/replica/vendor.rs new file mode 100644 index 0000000..472e2ac --- /dev/null +++ b/src/raknet/client/replica/vendor.rs @@ -0,0 +1,33 @@ +use std::io::Result as Res; + +use endio::{Deserialize, Serialize}; +use endio_bit::BEBitWriter; +use lu_packets_derive::{BitVariantTests, ReplicaSerde}; + +use crate::common::ObjId; +use super::{ComponentConstruction, ComponentSerialization}; + +#[derive(Debug, PartialEq, ReplicaSerde)] +pub struct VendorInfo { + pub has_standard_items: bool, + pub has_multicost_items: bool, +} + +#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)] +pub struct VendorConstruction { + pub vendor_info: Option, +} + +impl ComponentConstruction for VendorConstruction { + fn ser(&self, writer: &mut BEBitWriter>) -> Res<()> { + self.serialize(writer) + } +} + +pub type VendorSerialization = VendorConstruction; + +impl ComponentSerialization for VendorSerialization { + fn ser(&self, writer: &mut BEBitWriter>) -> Res<()> { + self.serialize(writer) + } +}