Don't de/serialize some particles

This commit is contained in:
Stephen Seo 2024-02-22 14:55:31 +09:00
parent 3bb0cbf026
commit f1badb79ca

View file

@ -1317,9 +1317,10 @@ impl Planet {
planet.color = color; planet.color = color;
idx += color_size; idx += color_size;
let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?; // No need to deserialize ParticleSystem
planet.particle_system = psystem; //let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?;
idx += psystem_size; //planet.particle_system = psystem;
//idx += psystem_size;
if data.len() < offset + idx + std::mem::size_of::<usize>() { if data.len() < offset + idx + std::mem::size_of::<usize>() {
return Err(()); return Err(());
@ -1344,7 +1345,9 @@ impl Planet {
bytes.append(&mut self.circle.serialize()); bytes.append(&mut self.circle.serialize());
bytes.append(&mut self.color.serialize()); bytes.append(&mut self.color.serialize());
bytes.append(&mut self.particle_system.serialize());
// No need to serialize ParticleSystem.
//bytes.append(&mut self.particle_system.serialize());
let moons_size = self.moons.len(); let moons_size = self.moons.len();
bytes.extend(moons_size.to_be_bytes()); bytes.extend(moons_size.to_be_bytes());
@ -1442,9 +1445,10 @@ impl Star {
star.color = color; star.color = color;
idx += color_size; idx += color_size;
let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?; // No need to deserialize ParticleSystem.
star.particle_system = psystem; //let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?;
idx += psystem_size; //star.particle_system = psystem;
//idx += psystem_size;
if data.len() < offset + idx + std::mem::size_of::<f32>() { if data.len() < offset + idx + std::mem::size_of::<f32>() {
return Err(()); return Err(());
@ -1473,7 +1477,9 @@ impl Star {
let mut bytes = Vec::new(); let mut bytes = Vec::new();
bytes.append(&mut self.color.serialize()); bytes.append(&mut self.color.serialize());
bytes.append(&mut self.particle_system.serialize());
// No need to serialize ParticleSystem.
//bytes.append(&mut self.particle_system.serialize());
bytes.extend(self.velr.to_be_bytes()); bytes.extend(self.velr.to_be_bytes());
bytes.extend(self.r.to_be_bytes()); bytes.extend(self.r.to_be_bytes());