Compare commits

..

No commits in common. "7fc185f614a5658fa89899711d0893891770b1ee" and "3bb0cbf026c8a9982d5b70b258a47696f30828e7" have entirely different histories.

View file

@ -1317,10 +1317,9 @@ impl Planet {
planet.color = color;
idx += color_size;
// No need to deserialize ParticleSystem
//let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?;
//planet.particle_system = psystem;
//idx += psystem_size;
let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?;
planet.particle_system = psystem;
idx += psystem_size;
if data.len() < offset + idx + std::mem::size_of::<usize>() {
return Err(());
@ -1345,9 +1344,7 @@ impl Planet {
bytes.append(&mut self.circle.serialize());
bytes.append(&mut self.color.serialize());
// No need to serialize ParticleSystem.
//bytes.append(&mut self.particle_system.serialize());
bytes.append(&mut self.particle_system.serialize());
let moons_size = self.moons.len();
bytes.extend(moons_size.to_be_bytes());
@ -1445,10 +1442,9 @@ impl Star {
star.color = color;
idx += color_size;
// No need to deserialize ParticleSystem.
//let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?;
//star.particle_system = psystem;
//idx += psystem_size;
let (psystem, psystem_size) = ParticleSystem::deserialize(data, offset + idx)?;
star.particle_system = psystem;
idx += psystem_size;
if data.len() < offset + idx + std::mem::size_of::<f32>() {
return Err(());
@ -1477,9 +1473,7 @@ impl Star {
let mut bytes = Vec::new();
bytes.append(&mut self.color.serialize());
// No need to serialize ParticleSystem.
//bytes.append(&mut self.particle_system.serialize());
bytes.append(&mut self.particle_system.serialize());
bytes.extend(self.velr.to_be_bytes());
bytes.extend(self.r.to_be_bytes());
@ -1749,7 +1743,7 @@ struct SaveData {
joining_particles: RotatingParticleSystem,
}
const SAVE_DATA_IDENTIFIER: [u8; 8] = [0x53, 0x41, 0x56, 0x45, 'V' as u8, 'e' as u8, 'r' as u8, 1];
const SAVE_DATA_IDENTIFIER: [u8; 4] = [0x53, 0x41, 0x56, 0x45];
impl SaveData {
pub fn deserialize(data: &[u8]) -> Result<(SaveData, usize), ()> {