Esempio n. 1
0
void Body::Serialize(Serializer::Writer &_wr, Space *space)
{
	Serializer::Writer wr;
	wr.Int32(int(GetType()));
	switch (GetType()) {
		case Object::STAR:
		case Object::PLANET:
		case Object::SPACESTATION:
		case Object::SHIP:
		case Object::PLAYER:
		case Object::MISSILE:
		case Object::CARGOBODY:
		case Object::PROJECTILE:
		case Object::HYPERSPACECLOUD:
			Save(wr, space);
			break;
		default:
			assert(0);
	}
	wr.Vector3d(GetPosition());
	matrix4x4d m;
	GetRotMatrix(m);
	for (int i=0; i<16; i++) wr.Double(m[i]);
	_wr.WrSection("Body", wr.GetData());
}
Esempio n. 2
0
File: Pi.cpp Progetto: Snaar/pioneer
void Pi::Serialize(Serializer::Writer &wr)
{
	Serializer::Writer section;

	Serializer::IndexFrames();
	Serializer::IndexBodies();
	Serializer::IndexSystemBodies(currentSystem);

	section = Serializer::Writer();
	section.Double(gameTime);
	StarSystem::Serialize(section, selectedSystem);
	StarSystem::Serialize(section, currentSystem);
	wr.WrSection("PiMisc", section.GetData());
	
	section = Serializer::Writer();
	Space::Serialize(section);
	wr.WrSection("Space", section.GetData());

	section = Serializer::Writer();
	Polit::Serialize(section);
	wr.WrSection("Polit", section.GetData());
	
	section = Serializer::Writer();
	sectorView->Save(section);
	wr.WrSection("SectorView", section.GetData());

	section = Serializer::Writer();
	worldView->Save(section);
	wr.WrSection("WorldView", section.GetData());

	section = Serializer::Writer();
	PiLuaModules::Serialize(section);
	wr.WrSection("LuaModules", section.GetData());
}
Esempio n. 3
0
void Space::Serialize(Serializer::Writer &wr)
{
    RebuildFrameIndex();
    RebuildBodyIndex();
    RebuildSystemBodyIndex();

    StarSystem::Serialize(wr, m_starSystem.Get());

    Serializer::Writer section;
    Frame::Serialize(section, m_rootFrame.Get(), this);
    wr.WrSection("Frames", section.GetData());

    wr.Int32(m_bodies.size());
    for (BodyIterator i = m_bodies.begin(); i != m_bodies.end(); ++i)
        (*i)->Serialize(wr, this);
}
Esempio n. 4
0
void Space::Serialize(Serializer::Writer &wr)
{
	RebuildFrameIndex();
	RebuildBodyIndex();
	RebuildSystemBodyIndex();

	StarSystem::Serialize(wr, m_starSystem.Get());

	Serializer::Writer section;
	Frame::Serialize(section, m_rootFrame.get(), this);
	wr.WrSection("Frames", section.GetData());

	wr.Int32(m_bodies.size());
	for (Body* b : m_bodies)
		b->Serialize(wr, this);
}
Esempio n. 5
0
void Body::Serialize(Serializer::Writer &_wr, Space *space)
{
	Serializer::Writer wr;
	wr.Int32(int(GetType()));
	switch (GetType()) {
		case Object::STAR:
		case Object::PLANET:
		case Object::SPACESTATION:
		case Object::SHIP:
		case Object::PLAYER:
		case Object::MISSILE:
		case Object::CARGOBODY:
		case Object::PROJECTILE:
		case Object::HYPERSPACECLOUD:
			Save(wr, space);
			break;
		default:
			assert(0);
	}
	_wr.WrSection("Body", wr.GetData());
}
Esempio n. 6
0
void Game::Serialize(Serializer::Writer &wr)
{
	// leading signature
	for (Uint32 i = 0; i < strlen(s_saveStart)+1; i++)
		wr.Byte(s_saveStart[i]);

	// version
	wr.Int32(s_saveVersion);

	Serializer::Writer section;

	// game state
	section.Double(m_time);
	section.Int32(Uint32(m_state));

	section.Bool(m_wantHyperspace);
	section.Double(m_hyperspaceProgress);
	section.Double(m_hyperspaceDuration);
	section.Double(m_hyperspaceEndTime);

	wr.WrSection("Game", section.GetData());


	// space, all the bodies and things
	section = Serializer::Writer();
	m_space->Serialize(section);
	section.Int32(m_space->GetIndexForBody(m_player.get()));
	wr.WrSection("Space", section.GetData());


	// space transition state
	section = Serializer::Writer();

	// hyperspace clouds being brought over from the previous system
	section.Int32(m_hyperspaceClouds.size());
	for (std::list<HyperspaceCloud*>::const_iterator i = m_hyperspaceClouds.begin(); i != m_hyperspaceClouds.end(); ++i)
		(*i)->Serialize(section, m_space.get());

	wr.WrSection("HyperspaceClouds", section.GetData());


	// system political data (crime etc)
	section = Serializer::Writer();
	Polit::Serialize(section);
	wr.WrSection("Polit", section.GetData());


	// views. must be saved in init order
	section = Serializer::Writer();
	Pi::cpan->Save(section);
	wr.WrSection("ShipCpanel", section.GetData());

	section = Serializer::Writer();
	Pi::sectorView->Save(section);
	wr.WrSection("SectorView", section.GetData());

	section = Serializer::Writer();
	Pi::worldView->Save(section);
	wr.WrSection("WorldView", section.GetData());


	// lua
	section = Serializer::Writer();
	Pi::luaSerializer->Serialize(section);
	wr.WrSection("LuaModules", section.GetData());


	// trailing signature
	for (Uint32 i = 0; i < strlen(s_saveEnd)+1; i++)
		wr.Byte(s_saveEnd[i]);
}