Space and SpaceManager serializers
parent
f8e44ed5b5
commit
202be71287
|
@ -1500,15 +1500,11 @@ void Pi::Serialize(Serializer::Writer &wr)
|
|||
section = Serializer::Writer();
|
||||
section.Double(gameTime);
|
||||
StarSystem::Serialize(section, selectedSystem.Get());
|
||||
StarSystem::Serialize(section, spaceManager->GetSpace()->GetStarSystem().Get());
|
||||
wr.WrSection("PiMisc", section.GetData());
|
||||
|
||||
/*
|
||||
section = Serializer::Writer();
|
||||
Space::Serialize(section);
|
||||
wr.WrSection("Space", section.GetData());
|
||||
*/
|
||||
assert(0);
|
||||
spaceManager->Serialize(wr);
|
||||
wr.WrSection("SpaceManager", section.GetData());
|
||||
|
||||
section = Serializer::Writer();
|
||||
Polit::Serialize(section);
|
||||
|
|
|
@ -52,6 +52,19 @@ Space::~Space()
|
|||
UpdateBodies();
|
||||
}
|
||||
|
||||
void Space::Serialize(Serializer::Writer &wr)
|
||||
{
|
||||
Serializer::Writer section;
|
||||
Frame::Serialize(section, m_rootFrame.Get());
|
||||
wr.WrSection("Frames", section.GetData());
|
||||
|
||||
StarSystem::Serialize(wr, m_starSystem.Get());
|
||||
|
||||
wr.Int32(m_bodies.size());
|
||||
for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i)
|
||||
(*i)->Serialize(wr);
|
||||
}
|
||||
|
||||
void Space::AddBody(Body *b)
|
||||
{
|
||||
m_bodies.push_back(b);
|
||||
|
@ -128,37 +141,6 @@ Body *Space::FindBodyForPath(const SystemPath *path)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void Serialize(Serializer::Writer &wr)
|
||||
{
|
||||
Serializer::Writer wr2;
|
||||
Frame::Serialize(wr2, m_rootFrame);
|
||||
wr.WrSection("Frames", wr2.GetData());
|
||||
|
||||
wr.Int32(m_bodies.size());
|
||||
for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i) {
|
||||
//printf("Serializing %s\n", (*i)->GetLabel().c_str());
|
||||
(*i)->Serialize(wr);
|
||||
}
|
||||
wr.Int32(storedArrivalClouds.size());
|
||||
for (std::list<HyperspaceCloud*>::iterator i = storedArrivalClouds.begin();
|
||||
i != storedArrivalClouds.end(); ++i) {
|
||||
(*i)->Serialize(wr);
|
||||
}
|
||||
if (hyperspacingTo == 0) {
|
||||
wr.Byte(0);
|
||||
} else {
|
||||
wr.Byte(1);
|
||||
hyperspacingTo->Serialize(wr);
|
||||
wr.Float(hyperspaceAnim);
|
||||
wr.Double(hyperspaceDuration);
|
||||
wr.Double(hyperspaceEndTime);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void Unserialize(Serializer::Reader &rd)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
virtual ~Space();
|
||||
|
||||
//void Save(Serializer::Writer &wr);
|
||||
void Serialize(Serializer::Writer &wr);
|
||||
|
||||
RefCountedPtr<StarSystem> GetStarSystem() const { return m_starSystem; }
|
||||
|
||||
|
|
|
@ -9,6 +9,24 @@
|
|||
#include "Sfx.h"
|
||||
#include "MathUtil.h"
|
||||
|
||||
void SpaceManager::Serialize(Serializer::Writer &wr)
|
||||
{
|
||||
Serializer::Writer section;
|
||||
m_space->Serialize(section);
|
||||
wr.WrSection("Space", section.GetData());
|
||||
|
||||
wr.Int32(m_hyperspaceClouds.size());
|
||||
for (std::list<HyperspaceCloud*>::const_iterator i = m_hyperspaceClouds.begin(); i != m_hyperspaceClouds.end(); ++i)
|
||||
(*i)->Serialize(wr);
|
||||
|
||||
wr.Int32(Serializer::LookupBody(m_player));
|
||||
wr.Int32(Uint32(m_state));
|
||||
wr.Bool(m_wantHyperspace);
|
||||
wr.Double(m_hyperspaceProgress);
|
||||
wr.Double(m_hyperspaceDuration);
|
||||
wr.Double(m_hyperspaceEndTime);
|
||||
}
|
||||
|
||||
void SpaceManager::CreateSpaceForDockedStart(const SystemPath &path)
|
||||
{
|
||||
assert(m_state == STATE_NONE);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "vector3.h"
|
||||
#include "SystemPath.h"
|
||||
#include "Serializer.h"
|
||||
|
||||
class Space;
|
||||
class Player;
|
||||
|
@ -21,6 +22,8 @@ public:
|
|||
|
||||
SpaceManager(Player *player) : m_player(player), m_state(STATE_NONE), m_space(0), m_wantHyperspace(false) {}
|
||||
|
||||
void Serialize(Serializer::Writer &wr);
|
||||
|
||||
bool IsNormalSpace() const { return m_state == STATE_NORMAL; }
|
||||
bool IsHyperspace() const { return m_state == STATE_HYPERSPACE; }
|
||||
|
||||
|
@ -51,7 +54,7 @@ private:
|
|||
|
||||
std::list<HyperspaceCloud*> m_hyperspaceClouds;
|
||||
SystemPath m_hyperspaceSource;
|
||||
float m_hyperspaceProgress;
|
||||
double m_hyperspaceProgress;
|
||||
double m_hyperspaceDuration;
|
||||
double m_hyperspaceEndTime;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue