Compare commits
2 commits
3bb0cbf026
...
7fc185f614
Author | SHA1 | Date | |
---|---|---|---|
7fc185f614 | |||
f1badb79ca |
1 changed files with 15 additions and 9 deletions
|
@ -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());
|
||||||
|
@ -1743,7 +1749,7 @@ struct SaveData {
|
||||||
joining_particles: RotatingParticleSystem,
|
joining_particles: RotatingParticleSystem,
|
||||||
}
|
}
|
||||||
|
|
||||||
const SAVE_DATA_IDENTIFIER: [u8; 4] = [0x53, 0x41, 0x56, 0x45];
|
const SAVE_DATA_IDENTIFIER: [u8; 8] = [0x53, 0x41, 0x56, 0x45, 'V' as u8, 'e' as u8, 'r' as u8, 1];
|
||||||
|
|
||||||
impl SaveData {
|
impl SaveData {
|
||||||
pub fn deserialize(data: &[u8]) -> Result<(SaveData, usize), ()> {
|
pub fn deserialize(data: &[u8]) -> Result<(SaveData, usize), ()> {
|
||||||
|
|
Loading…
Reference in a new issue