Skip to content

Commit

Permalink
Fix pet serialization (closes #17)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcdr committed Oct 29, 2023
1 parent e5831d1 commit d6e7c32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
14 changes: 1 addition & 13 deletions src/raknet/client/replica/pet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,7 @@ impl ComponentConstruction for PetConstruction {
}
}

#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct PetSerializationInfo {
/// todo: bitflag
pub pet_state: u32,
pub ability_in_use: PetAbilityType,
pub interaction_id: Option<ObjId>,
pub owner_id: Option<ObjId>,
}

#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
pub struct PetSerialization {
pub pet_serialization_info: Option<PetSerializationInfo>,
}
pub type PetSerialization = PetConstruction;

impl ComponentSerialization for PetSerialization {
fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
Expand Down
Binary file modified src/raknet/client/replica/tests/PetSerialization.bin
Binary file not shown.
13 changes: 9 additions & 4 deletions src/raknet/client/replica/tests/PetSerialization.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
PetSerialization {
pet_serialization_info: Some(PetSerializationInfo {
pet_state: 8,
ability_in_use: PetAbilityType::JumpOnObject,
PetConstruction {
pet_construction_info: Some(PetConstructionInfo {
pet_state: 4,
ability_in_use: PetAbilityType::GoToObject,
interaction_id: Some(1152921510209247111),
owner_id: Some(1152921510209247112),
tamed_pet_info: Some(TamedPetInfo {
pet_name_moderation_status: PetModerationStatus::Accepted,
pet_name: lu!("steve"),
owner_name: lu!("ChiefRedWizard"),
}),
}),
}

0 comments on commit d6e7c32

Please sign in to comment.