示例#1
1
文件: Missile.cpp 项目: lwho/pioneer
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);
}
示例#2
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);
}
void BinaryConverter::SaveMaterials(Serializer::Writer& wr, Model* model)
{
	//Look for the .model definition and parse it
	//for material definitions
	const ModelDefinition &modelDef = FindModelDefinition(model->GetName());

	wr.Int32(modelDef.matDefs.size());

	for (const auto& m : modelDef.matDefs) {
		wr.String(m.name);
		wr.String(m.tex_diff);
		wr.String(m.tex_spec);
		wr.String(m.tex_glow);
		wr.String(m.tex_ambi);
		wr.String(m.tex_norm);
		wr.Color4UB(m.diffuse);
		wr.Color4UB(m.specular);
		wr.Color4UB(m.ambient);
		wr.Color4UB(m.emissive);
		wr.Int16(m.shininess);
		wr.Int16(m.opacity);
		wr.Bool(m.alpha_test);
		wr.Bool(m.unlit);
		wr.Bool(m.use_pattern);
	}
}
示例#4
0
void SpaceStation::Save(Serializer::Writer &wr, Space *space)
{
	ModelBody::Save(wr, space);
	MarketAgent::Save(wr);
	wr.Int32(Equip::TYPE_MAX);
	for (int i=0; i<Equip::TYPE_MAX; i++) {
		wr.Int32(int(m_equipmentStock[i]));
	}
	// save shipyard
	wr.Int32(m_shipsOnSale.size());
	for (std::vector<ShipOnSale>::iterator i = m_shipsOnSale.begin();
			i != m_shipsOnSale.end(); ++i) {
		wr.String((*i).id);
		wr.String((*i).regId);
		(*i).skin.Save(wr);
	}
	for (int i=0; i<MAX_DOCKING_PORTS; i++) {
		wr.Int32(space->GetIndexForBody(m_shipDocking[i].ship));
		wr.Int32(m_shipDocking[i].stage);
		wr.Float(float(m_shipDocking[i].stagePos));
		wr.Vector3d(m_shipDocking[i].fromPos);
		wr.WrQuaternionf(m_shipDocking[i].fromRot);
	}
	wr.Bool(m_dockingLock);

	wr.Bool(m_bbCreated);
	wr.Double(m_lastUpdatedShipyard);
	wr.Int32(space->GetIndexForSystemBody(m_sbody));
	wr.Int32(m_numPoliceDocked);

	m_navLights->Save(wr);
}
示例#5
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);
}
示例#6
0
文件: Body.cpp 项目: GAlexx/pioneer
void Body::Save(Serializer::Writer &wr)
{
	wr.Int32(Serializer::LookupFrame(m_frame));
	wr.String(m_label);
	wr.Bool(m_onscreen);
	wr.Vector3d(m_projectedPos);
	wr.Bool(m_dead);
	wr.Bool(m_hasDoubleFrame);
}
示例#7
0
void SpaceStation::Save(Serializer::Writer &wr, Space *space)
{
	ModelBody::Save(wr, space);
	wr.Int32(Equip::TYPE_MAX);
	wr.Int32(m_shipDocking.size());
	for (Uint32 i=0; i<m_shipDocking.size(); i++) {
		wr.Int32(space->GetIndexForBody(m_shipDocking[i].ship));
		wr.Int32(m_shipDocking[i].stage);
		wr.Float(float(m_shipDocking[i].stagePos));
		wr.Vector3d(m_shipDocking[i].fromPos);
		wr.WrQuaternionf(m_shipDocking[i].fromRot);
	}
	// store each of the bay groupings
	wr.Int32(mBayGroups.size());
	for (Uint32 i=0; i<mBayGroups.size(); i++) {
		wr.Int32(mBayGroups[i].minShipSize);
		wr.Int32(mBayGroups[i].maxShipSize);
		wr.Bool(mBayGroups[i].inUse);
		wr.Int32(mBayGroups[i].bayIDs.size());
		for (Uint32 j=0; j<mBayGroups[i].bayIDs.size(); j++) {
			wr.Int32(mBayGroups[i].bayIDs[j]);
		}
	}

	wr.Int32(space->GetIndexForSystemBody(m_sbody));
	wr.Int32(m_numPoliceDocked);

	wr.Double(m_doorAnimationStep);
	wr.Double(m_doorAnimationState);

	m_navLights->Save(wr);
}
示例#8
0
void SectorView::Save(Serializer::Writer &wr)
{
    wr.Float(m_pos.x);
    wr.Float(m_pos.y);
    wr.Float(m_pos.z);
    wr.Float(m_rotX);
    wr.Float(m_rotZ);
    wr.Float(m_zoom);
    wr.Bool(m_inSystem);
    m_current.Serialize(wr);
    m_selected.Serialize(wr);
    m_hyperspaceTarget.Serialize(wr);
    wr.Bool(m_matchTargetToSelection);
    wr.Bool(m_selectionFollowsMovement);
    wr.Byte(m_detailBoxVisible);
}
示例#9
0
文件: Ship.cpp 项目: GAlexx/pioneer
void Ship::Save(Serializer::Writer &wr)
{
	DynamicBody::Save(wr);
	wr.Vector3d(m_angThrusters);
	wr.Vector3d(m_thrusters);
	wr.Int32(m_wheelTransition);
	wr.Float(m_wheelState);
	wr.Float(m_launchLockTimeout);
	wr.Bool(m_testLanded);
	wr.Int32(int(m_flightState));
	wr.Int32(int(m_alertState));
	wr.Float(m_lastFiringAlert);

	m_hyperspace.dest.Serialize(wr);
	wr.Float(m_hyperspace.countdown);

	for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) {
		wr.Int32(m_gunState[i]);
		wr.Float(m_gunRecharge[i]);
		wr.Float(m_gunTemperature[i]);
	}
	wr.Float(m_ecmRecharge);
	m_shipFlavour.Save(wr);
	wr.Int32(m_dockedWithPort);
	wr.Int32(Serializer::LookupBody(m_dockedWith));
	m_equipment.Save(wr);
	wr.Float(m_stats.hull_mass_left);
	wr.Float(m_stats.shield_mass_left);
	if(m_curAICmd) { wr.Int32(1); m_curAICmd->Save(wr); }
	else wr.Int32(0);
}
示例#10
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);
}
示例#11
0
void SpaceStation::Save(Serializer::Writer &wr, Space *space)
{
	ModelBody::Save(wr, space);
	MarketAgent::Save(wr);
	wr.Int32(Equip::TYPE_MAX);
	for (int i=0; i<Equip::TYPE_MAX; i++) {
		wr.Int32(int(m_equipmentStock[i]));
	}
	// save shipyard
	wr.Int32(m_shipsOnSale.size());
	for (std::vector<ShipOnSale>::iterator i = m_shipsOnSale.begin();
			i != m_shipsOnSale.end(); ++i) {
		wr.String((*i).id);
		wr.String((*i).regId);
		(*i).skin.Save(wr);
	}
	wr.Int32(m_shipDocking.size());
	for (uint32_t i=0; i<m_shipDocking.size(); i++) {
		wr.Int32(space->GetIndexForBody(m_shipDocking[i].ship));
		wr.Int32(m_shipDocking[i].stage);
		wr.Float(float(m_shipDocking[i].stagePos));
		wr.Vector3d(m_shipDocking[i].fromPos);
		wr.WrQuaternionf(m_shipDocking[i].fromRot);
	}
	// store each of the bay groupings
	wr.Int32(mBayGroups.size());
	for (uint32_t i=0; i<mBayGroups.size(); i++) {
		wr.Int32(mBayGroups[i].minShipSize);
		wr.Int32(mBayGroups[i].maxShipSize);
		wr.Bool(mBayGroups[i].inUse);
		wr.Int32(mBayGroups[i].bayIDs.size());
		for (uint32_t j=0; j<mBayGroups[i].bayIDs.size(); j++) {
			wr.Int32(mBayGroups[i].bayIDs[j]);
		}
	}

	wr.Bool(m_bbCreated);
	wr.Double(m_lastUpdatedShipyard);
	wr.Int32(space->GetIndexForSystemBody(m_sbody));
	wr.Int32(m_numPoliceDocked);

	wr.Double(m_doorAnimationStep);
	wr.Double(m_doorAnimationState);

	m_navLights->Save(wr);
}
示例#12
0
void PlayerShipController::Save(Serializer::Writer &wr, Space *space)
{
	wr.Int32(static_cast<int>(m_flightControlState));
	wr.Double(m_setSpeed);
	wr.Float(m_lowThrustPower);
	wr.Bool(m_rotationDamping);
	wr.Int32(space->GetIndexForBody(m_combatTarget));
	wr.Int32(space->GetIndexForBody(m_navTarget));
	wr.Int32(space->GetIndexForBody(m_setSpeedTarget));
}
示例#13
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);
}
示例#14
0
void Body::Save(Serializer::Writer &wr, Space *space)
{
	wr.Int32(space->GetIndexForFrame(m_frame));
	wr.String(m_label);
	wr.Bool(m_dead);

	wr.Vector3d(m_pos);
	for (int i=0; i<9; i++) wr.Double(m_orient[i]);
	wr.Double(m_physRadius);
	wr.Double(m_clipRadius);
}
示例#15
0
void DynamicBody::Save(Serializer::Writer &wr, Space *space)
{
    ModelBody::Save(wr, space);
    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_isMoving);
}
示例#16
0
文件: Shields.cpp 项目: lwho/pioneer
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());
	}
}
示例#17
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);
}
示例#18
0
void Ship::Save(Serializer::Writer &wr, Space *space)
{
	DynamicBody::Save(wr, space);
	wr.Vector3d(m_angThrusters);
	wr.Vector3d(m_thrusters);
	wr.Int32(m_wheelTransition);
	wr.Float(m_wheelState);
	wr.Float(m_launchLockTimeout);
	wr.Bool(m_testLanded);
	wr.Int32(int(m_flightState));
	wr.Int32(int(m_alertState));
	wr.Double(m_lastFiringAlert);

	// XXX make sure all hyperspace attrs and the cloud get saved
	m_hyperspace.dest.Serialize(wr);
	wr.Float(m_hyperspace.countdown);

	for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) {
		wr.Int32(m_gunState[i]);
		wr.Float(m_gunRecharge[i]);
		wr.Float(m_gunTemperature[i]);
	}
	wr.Float(m_ecmRecharge);
	m_shipFlavour.Save(wr);
	wr.Int32(m_dockedWithPort);
	wr.Int32(space->GetIndexForBody(m_dockedWith));
	m_equipment.Save(wr);
	wr.Float(m_stats.hull_mass_left);
	wr.Float(m_stats.shield_mass_left);
	if(m_curAICmd) { wr.Int32(1); m_curAICmd->Save(wr); }
	else wr.Int32(0);
	wr.Int32(int(m_aiMessage));
	wr.Double(m_thrusterFuel);
	wr.Double(m_reserveFuel);

	wr.Int32(static_cast<int>(m_controller->GetType()));
	m_controller->Save(wr, space);
}
示例#19
0
void AIParagonCmdGoTo::Save(Serializer::Writer &wr) 
{
	if (m_child) { 
		delete m_child; m_child = 0; 
	}
	AICommand::Save(wr);
	wr.Int32(Pi::game->GetSpace()->GetIndexForFrame(m_targetFrame));
	wr.Vector3d(m_targetPosition);
	wr.Bool(m_toTransit);
	wr.Vector3d(m_targetOrient.VectorX());
	wr.Vector3d(m_targetOrient.VectorY());
	wr.Vector3d(m_targetOrient.VectorZ());
	wr.Vector3d(m_startPO.pos);
	wr.Vector3d(m_startPO.xaxis);
	wr.Vector3d(m_startPO.yaxis);
	wr.Vector3d(m_startPO.zaxis);
	wr.Vector3d(m_endPO.pos);
	wr.Vector3d(m_endPO.xaxis);
	wr.Vector3d(m_endPO.yaxis);
	wr.Vector3d(m_endPO.zaxis);
	wr.Double(m_speedLimit);
	wr.Double(m_arrivalSpeed);
	wr.Int32(static_cast<int>(m_mode));
}
示例#20
0
文件: Game.cpp 项目: jfabrix/pioneer
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]);
}
示例#21
0
void ModelBody::Save(Serializer::Writer &wr, Space *space)
{
	Body::Save(wr, space);
	wr.Bool(m_isStatic);
	wr.Bool(m_colliding);
}