Example #1
1
void Missile::Save(Serializer::Writer &wr, Space *space)
{
	Ship::Save(wr, space);
	wr.Int32(space->GetIndexForBody(m_owner));
	wr.Int32(m_power);
	wr.Bool(m_armed);
}
void ScannerWidget::Save(Serializer::Writer &wr)
{
	wr.Int32(Sint32(m_mode));
	wr.Float(m_currentRange);
	wr.Float(m_manualRange);
	wr.Float(m_targetRange);
}
Example #3
0
void Body::Save(Serializer::Writer &wr, Space *space)
{
	wr.Int32(space->GetIndexForFrame(m_frame));
	wr.String(m_label);
	wr.Bool(m_dead);
	wr.Bool(m_hasDoubleFrame);
}
Example #4
0
void Player::Save(Serializer::Writer &wr, Space *space)
{
	Ship::Save(wr, space);
	MarketAgent::Save(wr);
	wr.Int32(m_killCount);
	wr.Int32(m_knownKillCount);
}
Example #5
0
bool GameSaver::SaveToFile(const std::string &filename)
{
	bool success = false;
	try {
		if (!FileSystem::rawFileSystem.MakeDirectory(Pi::GetSaveDir())) {
			throw CouldNotOpenFileException();
		}

		Serializer::Writer wr;
		m_game->Serialize(wr);

		const std::string data = wr.GetData();

		FILE *f = fopen(filename.c_str(), "wb");
		if (!f) throw CouldNotOpenFileException();

		size_t nwritten = fwrite(data.data(), data.length(), 1, f);
		fclose(f);

		if (nwritten != 1) throw CouldNotWriteToFileException();

		success = true;
	}
	catch (CouldNotOpenFileException) {
		Gui::Screen::ShowBadError(Lang::GAME_LOAD_CANNOT_OPEN);
	}
	catch (CouldNotWriteToFileException) {
		Gui::Screen::ShowBadError(Lang::GAME_SAVE_CANNOT_WRITE);
	}

	return success;
}
Example #6
0
void ShipFlavour::SaveLmrMaterial(Serializer::Writer &wr, LmrMaterial *m)
{
	for (int i=0; i<4; i++) wr.Float(m->diffuse[i]);
	for (int i=0; i<4; i++) wr.Float(m->specular[i]);
	for (int i=0; i<4; i++) wr.Float(m->emissive[i]);
	wr.Float(m->shininess);
}
Example #7
0
void Sfx::Save(Serializer::Writer &wr)
{
	wr.Vector3d(m_pos);
	wr.Vector3d(m_vel);
	wr.Float(m_age);
	wr.Int32(m_type);
}
Example #8
0
void ShipFlavour::Save(Serializer::Writer &wr)
{
	wr.String(id);
	wr.Int32(price);
	wr.String(regid);
	SaveLmrMaterial(wr, &primaryColor);
	SaveLmrMaterial(wr, &secondaryColor);
}
Example #9
0
void ModelBody::Save(Serializer::Writer &wr, Space *space)
{
	Body::Save(wr, space);
	wr.Bool(m_isStatic);
	wr.Bool(m_colliding);
	wr.String(m_modelName);
	m_model->Save(wr);
}
Example #10
0
void Player::Save(Serializer::Writer &wr)
{
	Ship::Save(wr);
	wr.Int32(static_cast<int>(m_flightControlState));
	wr.Double(m_setSpeed);
	wr.Int32(m_killCount);
	wr.Int32(m_knownKillCount);
}
Example #11
0
void AICommand::Save(Serializer::Writer &wr)
{
	Space *space = Pi::game->GetSpace();
	wr.Int32(m_cmdName);
	wr.Int32(space->GetIndexForBody(m_ship));
	if (m_child) m_child->Save(wr);
	else wr.Int32(CMD_NONE);
}
Example #12
0
void Missile::Save(Serializer::Writer &wr)
{
	Ship::Save(wr);
	wr.Int32(Serializer::LookupBody(m_owner));
	wr.Int32(Serializer::LookupBody(m_target));
	wr.Double(m_distToTarget);
	wr.Int32(m_power);
}
Example #13
0
void Missile::Save(Serializer::Writer &wr, Space *space)
{
	Ship::Save(wr, space);
	wr.Int32(space->GetIndexForBody(m_owner));
	wr.Int32(space->GetIndexForBody(m_target));
	wr.Double(m_distToTarget);
	wr.Int32(m_power);
}
Example #14
0
void NavLights::Save(Serializer::Writer &wr)
{
	wr.Float(m_time);
	wr.Bool(m_enabled);

	for (LightIterator it = m_lights.begin(); it != m_lights.end(); ++it)
		wr.Byte(it->color);
}
Example #15
0
void Projectile::Save(Serializer::Writer &wr, Space *space)
{
	Body::Save(wr, space);
	wr.Vector3d(m_baseVel);
	wr.Vector3d(m_dirVel);
	wr.Float(m_age);
	wr.Int32(m_type);
	wr.Int32(space->GetIndexForBody(m_parent));
}
Example #16
0
void Serialize(Serializer::Writer &wr)
{
	s_criminalRecord.Serialize(wr);
	s_outstandingFine.Serialize(wr);
	for (int i=0; i<BLOC_MAX; i++) {
		wr.Int64(s_playerPerBlocCrimeRecord[i].record);
		wr.Int64(s_playerPerBlocCrimeRecord[i].fine);
	}
}
Example #17
0
void Serialize(Serializer::Writer &wr)
{
	s_criminalRecord.Serialize(wr);
	s_outstandingFine.Serialize(wr);
	wr.Int32(s_playerPerBlocCrimeRecord.size());
	for (Uint32 i=0; i < s_playerPerBlocCrimeRecord.size(); i++) {
		wr.Int64(s_playerPerBlocCrimeRecord[i].record);
		wr.Int64(s_playerPerBlocCrimeRecord[i].fine);
	}
}
Example #18
0
void Model::Save(Serializer::Writer &wr) const
{
	SaveVisitor sv(&wr);
	m_root->Accept(sv);

	for (AnimationContainer::const_iterator i = m_animations.begin(); i != m_animations.end(); ++i)
		wr.Double((*i)->GetProgress());

	wr.Int32(m_curPatternIndex);
}
Example #19
0
void HyperspaceCloud::Save(Serializer::Writer &wr, Space *space)
{
	Body::Save(wr, space);
	wr.Vector3d(m_vel);
	wr.Double(m_birthdate);
	wr.Double(m_due);
	wr.Bool(m_isArrival);
	wr.Bool(m_ship != 0);
	if (m_ship) m_ship->Serialize(wr, space);
}
Example #20
0
void EquipSet::Save(Serializer::Writer &wr)
{
	wr.Int32(Equip::SLOT_MAX);
	for (int i=0; i<Equip::SLOT_MAX; i++) {
		wr.Int32(equip[i].size());
		for (unsigned int j=0; j<equip[i].size(); j++) {
			wr.Int32(static_cast<int>(equip[i][j]));
		}
	}
}
Example #21
0
void ModelSkin::Save(Serializer::Writer &wr) const
{
    for (unsigned int i = 0; i < 3; i++) {
        wr.Byte(m_colors[i].r);
        wr.Byte(m_colors[i].g);
        wr.Byte(m_colors[i].b);
    }
    for (unsigned int i = 0; i < MAX_DECAL_MATERIALS; i++)
        wr.String(m_decals[i]);
    wr.String(m_label);
}
Example #22
0
void Shields::Save(Serializer::Writer &wr)
{
	wr.Bool(m_enabled);

	wr.Int32(m_shields.size());
	for (ShieldIterator it = m_shields.begin(); it != m_shields.end(); ++it) {
		wr.Byte(it->m_colour.r);
		wr.Byte(it->m_colour.g);
		wr.Byte(it->m_colour.b);
		wr.String(it->m_mesh->GetName());
	}
}
Example #23
0
void Serialize(Serializer::Writer &wr)
{
	for(std::list<std::string>::const_iterator i = s_modules.begin(); i!=s_modules.end(); ++i) {
		ModCall((*i).c_str(), "Serialize", 1);
		// string can have nulls in it so must get length
		std::string str;
		OOLUA::pull2cpp(L, str);
		wr.String(*i);
		wr.String(str);
	}
	wr.String("");
}
Example #24
0
static std::string _modelskin_serializer(LuaWrappable *o)
{
	static char buf[256];

	SceneGraph::ModelSkin *skin = static_cast<SceneGraph::ModelSkin*>(o);

	Serializer::Writer wr;
	skin->Save(wr);
	const std::string &ser = wr.GetData();
	snprintf(buf, sizeof(buf), "%lu\n", ser.size());

	return std::string(buf) + ser;
}
Example #25
0
void CollMesh::Save(Serializer::Writer &wr) const
{
	wr.Vector3d(m_aabb.max);
	wr.Vector3d(m_aabb.min);
	wr.Double(m_aabb.radius);

	m_geomTree->Save(wr);

	wr.Int32(m_dynGeomTrees.size());
	for (auto it : m_dynGeomTrees) {
		it->Save(wr);
	}

	wr.Int32(m_totalTris);
}
Example #26
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);
}
Example #27
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);
}
Example #28
0
void Frame::Serialize(Serializer::Writer &wr, Frame *f, Space *space)
{
	wr.Int32(f->m_flags);
	wr.Double(f->m_radius);
	wr.String(f->m_label);
	wr.Vector3d(f->m_pos);
	for (int i=0; i<9; i++) wr.Double(f->m_orient[i]);
	wr.Double(f->m_angSpeed);
	wr.Int32(space->GetIndexForSystemBody(f->m_sbody));
	wr.Int32(space->GetIndexForBody(f->m_astroBody));
	wr.Int32(f->m_children.size());
	for (ChildIterator it = f->BeginChildren(); it != f->EndChildren(); ++it)
		Serialize(wr, *it, space);
	Sfx::Serialize(wr, f);
}
Example #29
0
void Frame::Serialize(Serializer::Writer &wr, Frame *f, Space *space)
{
	wr.Int32(f->m_flags);
	wr.Double(f->m_radius);
	wr.String(f->m_label);
	wr.Vector3d(f->m_pos);
	wr.Double(f->m_angSpeed);
	for (int i=0; i<9; i++) wr.Double(f->m_initialOrient[i]);
	wr.Int32(space->GetIndexForSystemBody(f->m_sbody));
	wr.Int32(space->GetIndexForBody(f->m_astroBody));
	wr.Int32(f->m_children.size());
	for (Frame* kid : f->GetChildren())
		Serialize(wr, kid, space);
	Sfx::Serialize(wr, f);
}
Example #30
0
void DynamicBody::Save(Serializer::Writer &wr)
{
	ModelBody::Save(wr);
	for (int i=0; i<16; i++) wr.Double(m_orient[i]);
	wr.Vector3d(m_force);
	wr.Vector3d(m_torque);
	wr.Vector3d(m_vel);
	wr.Vector3d(m_angVel);
	wr.Double(m_mass);
	wr.Double(m_massRadius);
	wr.Double(m_angInertia);
	wr.Bool(m_enabled);
}