Split off achievement vendor into a proper component

This commit is contained in:
lcdr
2021-03-07 15:25:18 +01:00
parent 4e0a8c84c5
commit 8800ea645c
5 changed files with 38 additions and 2 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ use lu_packets::{
lu,
raknet::client::replica::{
ComponentConstruction, ComponentSerialization, ReplicaContext,
achievement_vendor::{AchievementVendorConstruction, AchievementVendorSerialization},
base_combat_ai::{BaseCombatAiConstruction, BaseCombatAiSerialization},
bbb::{BbbConstruction, BbbSerialization},
bouncer::{BouncerConstruction, BouncerSerialization},
@@ -142,7 +143,7 @@ impl ZipContext<'_> {
61 => { constrs.push(|x| Ok(Box::new(ModuleAssemblyConstruction::deserialize(x)?))); }
98 => { constrs.push(|x| Ok(Box::new(BuffConstruction::deserialize(x)?))); }
100 => { constrs.push(|x| Ok(Box::new(DonationVendorConstruction::deserialize(x)?))); }
102 => { constrs.push(|x| Ok(Box::new(VendorConstruction::deserialize(x)?))); }
102 => { constrs.push(|x| Ok(Box::new(AchievementVendorConstruction::deserialize(x)?))); }
106 => { constrs.push(|x| Ok(Box::new(PlayerForcedMovementConstruction::deserialize(x)?))); }
107 => { constrs.push(|x| Ok(Box::new(BbbConstruction::deserialize(x)?))); }
108 => { constrs.push(|x| Ok(Box::new(PossessableConstruction::deserialize(x)?))); }
@@ -208,7 +209,7 @@ impl ReplicaContext for ZipContext<'_> {
49 => { sers.push(|x| Ok(Box::new(SwitchSerialization::deserialize(x)?))); }
60 => { sers.push(|x| Ok(Box::new(BaseCombatAiSerialization::deserialize(x)?))); }
100 => { sers.push(|x| Ok(Box::new(DonationVendorSerialization::deserialize(x)?))); }
102 => { sers.push(|x| Ok(Box::new(VendorSerialization::deserialize(x)?))); }
102 => { sers.push(|x| Ok(Box::new(AchievementVendorSerialization::deserialize(x)?))); }
106 => { sers.push(|x| Ok(Box::new(PlayerForcedMovementSerialization::deserialize(x)?))); }
107 => { sers.push(|x| Ok(Box::new(BbbSerialization::deserialize(x)?))); }
108 => { sers.push(|x| Ok(Box::new(PossessableSerialization::deserialize(x)?))); }
@@ -0,0 +1,27 @@
use std::io::Result as Res;
use endio::Serialize;
use endio_bit::BEBitWriter;
use lu_packets_derive::{BitVariantTests, ReplicaSerde};
use super::{ComponentConstruction, ComponentSerialization};
use super::vendor::VendorInfo;
#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
pub struct AchievementVendorConstruction {
pub vendor_info: Option<VendorInfo>,
}
impl ComponentConstruction for AchievementVendorConstruction {
fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
self.serialize(writer)
}
}
pub type AchievementVendorSerialization = AchievementVendorConstruction;
impl ComponentSerialization for AchievementVendorSerialization {
fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
self.serialize(writer)
}
}
+1
View File
@@ -1,3 +1,4 @@
pub mod achievement_vendor;
pub mod base_combat_ai;
pub mod bbb;
pub mod bouncer;
@@ -0,0 +1 @@
@@ -0,0 +1,6 @@
AchievementVendorConstruction {
vendor_info: Some(VendorInfo {
has_standard_items: true,
has_multicost_items: true,
}),
}