Beispiel #1
1
void HyperspaceCloud::Load(Serializer::Reader &rd, Space *space)
{
	Body::Load(rd, space);
	m_vel = rd.Vector3d();
	m_birthdate = rd.Double();
	m_due = rd.Double();
	m_isArrival = rd.Bool();
	if (rd.Bool()) {
		m_ship = static_cast<Ship*>(Body::Unserialize(rd, space));
	}
}
Beispiel #2
0
void Projectile::Load(Serializer::Reader &rd, Space *space)
{
	Body::Load(rd, space);
	m_baseVel = rd.Vector3d();
	m_dirVel = rd.Vector3d();
	m_age = rd.Float();
	m_type = rd.Int32();
	m_parentIndex = rd.Int32();
}
Beispiel #3
0
void Projectile::Load(Serializer::Reader &rd, Space *space)
{
	Body::Load(rd, space);
	for (int i=0; i<16; i++) m_orient[i] = rd.Double();
	m_baseVel = rd.Vector3d();
	m_dirVel = rd.Vector3d();
	m_age = rd.Float();
	m_type = rd.Int32();
	m_parentIndex = rd.Int32();
}
AIParagonCmdGoTo::AIParagonCmdGoTo(Serializer::Reader &rd) : AICommand(rd, CMD_PARAGON_GOTO) 
{
	m_targetFrameIndex = rd.Int32();
	m_targetPosition = rd.Vector3d();
	m_toTransit = rd.Bool();

	if(Game::s_loadedGameVersion >= 77) { // Save game upgrade: 76 -> 77
		m_targetOrient = matrix3x3d::FromVectors(
			rd.Vector3d(), rd.Vector3d(), rd.Vector3d());
		m_startPO.pos = rd.Vector3d();
		m_startPO.xaxis = rd.Vector3d();
		m_startPO.yaxis = rd.Vector3d();
		m_startPO.zaxis = rd.Vector3d();

		m_endPO.pos = rd.Vector3d();
		m_endPO.xaxis = rd.Vector3d();
		m_endPO.yaxis = rd.Vector3d();
		m_endPO.zaxis = rd.Vector3d();

		m_speedLimit = rd.Double();
		m_arrivalSpeed = rd.Double();

		m_mode = static_cast<EGoToMode>(rd.Int32());
	}
}
Beispiel #5
0
void DynamicBody::Load(Serializer::Reader &rd, Space *space)
{
    ModelBody::Load(rd, space);
    m_force = rd.Vector3d();
    m_torque = rd.Vector3d();
    m_vel = rd.Vector3d();
    m_angVel = rd.Vector3d();
    m_mass = rd.Double();
    m_massRadius = rd.Double();
    m_angInertia = rd.Double();
    m_isMoving = rd.Bool();
}
Beispiel #6
0
void Ship::Load(Serializer::Reader &rd, Space *space)
{
	DynamicBody::Load(rd, space);
	// needs fixups
	m_angThrusters = rd.Vector3d();
	m_thrusters = rd.Vector3d();
	m_wheelTransition = rd.Int32();
	m_wheelState = rd.Float();
	m_launchLockTimeout = rd.Float();
	m_testLanded = rd.Bool();
	m_flightState = FlightState(rd.Int32());
	m_alertState = AlertState(rd.Int32());
	m_lastFiringAlert = rd.Double();

	m_hyperspace.dest = SystemPath::Unserialize(rd);
	m_hyperspace.countdown = rd.Float();

	for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) {
		m_gunState[i] = rd.Int32();
		m_gunRecharge[i] = rd.Float();
		m_gunTemperature[i] = rd.Float();
	}
	m_ecmRecharge = rd.Float();
	m_shipFlavour.Load(rd);
	m_type = &ShipType::types[m_shipFlavour.id];
	m_dockedWithPort = rd.Int32();
	m_dockedWithIndex = rd.Int32();
	m_equipment.InitSlotSizes(m_shipFlavour.id);
	m_equipment.Load(rd);
	Init();
	m_stats.hull_mass_left = rd.Float(); // must be after Init()...
	m_stats.shield_mass_left = rd.Float();
	if(rd.Int32()) m_curAICmd = AICommand::Load(rd);
	else m_curAICmd = 0;
	m_aiMessage = AIError(rd.Int32());
	SetFuel(rd.Double());
	m_stats.fuel_tank_mass_left = GetShipType().fuelTankMass * GetFuel();
	m_reserveFuel = rd.Double();
	UpdateStats(); // this is necessary, UpdateStats() in Ship::Init has wrong values of m_thrusterFuel after Load

	m_controller = 0;
	const ShipController::Type ctype = static_cast<ShipController::Type>(rd.Int32());
	if (ctype == ShipController::PLAYER)
		SetController(new PlayerShipController());
	else
		SetController(new ShipController());
	m_controller->Load(rd);

	m_equipment.onChange.connect(sigc::mem_fun(this, &Ship::OnEquipmentChange));
}
Beispiel #7
0
void DynamicBody::Load(Serializer::Reader &rd)
{
	ModelBody::Load(rd);
	for (int i=0; i<16; i++) m_orient[i] = rd.Double();
	m_oldOrient = m_orient;
	m_force = rd.Vector3d();
	m_torque = rd.Vector3d();
	m_vel = rd.Vector3d();
	m_angVel = rd.Vector3d();
	m_mass = rd.Double();
	m_massRadius = rd.Double();
	m_angInertia = rd.Double();
	m_enabled = rd.Bool();
}
Beispiel #8
0
void Sfx::Load(Serializer::Reader &rd)
{
	m_pos = rd.Vector3d();
	m_vel = rd.Vector3d();
	m_age = rd.Float();
	m_type = static_cast<Sfx::TYPE>(rd.Int32());
}
Beispiel #9
0
void TerrainBody::Load(Serializer::Reader &rd, Space *space)
{
	Body::Load(rd, space);
	m_pos = rd.Vector3d();
	SBody *sbody = space->GetSBodyByIndex(rd.Int32());
	InitTerrainBody(sbody);
}
Beispiel #10
0
void Planet::Load(Serializer::Reader &rd)
{
	Body::Load(rd);
	pos = rd.Vector3d();
	sbody = Serializer::LookupSystemBody(rd.Int32());
	Init();
}
Beispiel #11
0
void SpaceStation::Load(Serializer::Reader &rd, Space *space)
{
	ModelBody::Load(rd, space);
	MarketAgent::Load(rd);
	int num = rd.Int32();
	if (num > Equip::TYPE_MAX) throw SavedGameCorruptException();
	for (int i=0; i<Equip::TYPE_MAX; i++) {
		m_equipmentStock[i] = 0;
	}
	for (int i=0; i<num; i++) {
		m_equipmentStock[i] = static_cast<Equip::Type>(rd.Int32());
	}
	// load shityard
	int numShipsForSale = rd.Int32();
	for (int i=0; i<numShipsForSale; i++) {
		ShipFlavour s;
		s.Load(rd);
		m_shipsOnSale.push_back(s);
	}
	for (int i=0; i<MAX_DOCKING_PORTS; i++) {
		m_shipDocking[i].shipIndex = rd.Int32();
		m_shipDocking[i].stage = rd.Int32();
		m_shipDocking[i].stagePos = rd.Float();
		m_shipDocking[i].fromPos = rd.Vector3d();
		m_shipDocking[i].fromRot = rd.RdQuaternionf();

		m_openAnimState[i] = rd.Float();
		m_dockAnimState[i] = rd.Float();
	}
	m_bbCreated = rd.Bool();
	m_lastUpdatedShipyard = rd.Double();
	m_sbody = space->GetSystemBodyByIndex(rd.Int32());
	m_numPoliceDocked = rd.Int32();
	InitStation();
}
Beispiel #12
0
void Body::Load(Serializer::Reader &rd)
{
	m_frame = Serializer::LookupFrame(rd.Int32());
	m_label = rd.String();
	m_onscreen = rd.Bool();
	m_projectedPos = rd.Vector3d();
	m_dead = rd.Bool();
	m_hasDoubleFrame = rd.Bool();
}	
Beispiel #13
0
void Body::Load(Serializer::Reader &rd, Space *space)
{
	m_frame = space->GetFrameByIndex(rd.Int32());
	m_label = rd.String();
	Properties().Set("label", m_label);
	m_dead = rd.Bool();

	m_pos = rd.Vector3d();
	for (int i=0; i<9; i++) m_orient[i] = rd.Double();
	m_physRadius = rd.Double();
	m_clipRadius = rd.Double();
}
AIParagonCmdDock::AIParagonCmdDock(Serializer::Reader &rd)
	: AICommand(rd, CMD_PARAGON_DOCK)
{
	// an older save should never load a dock comand object since it didn't exist initially
	// but still, better be safe.
	if(Game::s_loadedGameVersion >= 77) { // Save game upgrade: 76 -> 77
		m_stationIndex = rd.Int32();
		m_state = static_cast<EDockingState>(rd.Int32());
		int ap_count = rd.Int32();
		m_approachPoints.clear();
		for (int i = 0; i < ap_count; ++i) {
			SpaceStationType::positionOrient_t po;
			po.pos = rd.Vector3d();
			po.xaxis = rd.Vector3d();
			po.yaxis = rd.Vector3d();
			po.zaxis = rd.Vector3d();
			m_approachPoints.push_back(po);
		}
		m_nextApproachPoint = rd.Int32();
	} 
}
Beispiel #15
0
void Ship::Load(Serializer::Reader &rd)
{
	DynamicBody::Load(rd);
	// needs fixups
	m_angThrusters = rd.Vector3d();
	m_thrusters = rd.Vector3d();
	m_wheelTransition = rd.Int32();
	m_wheelState = rd.Float();
	m_launchLockTimeout = rd.Float();
	m_testLanded = rd.Bool();
	m_flightState = FlightState(rd.Int32());
	m_alertState = AlertState(rd.Int32());
	m_lastFiringAlert = rd.Float();
	
	m_hyperspace.dest = SystemPath::Unserialize(rd);
	m_hyperspace.countdown = rd.Float();

	for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) {
		m_gunState[i] = rd.Int32();
		m_gunRecharge[i] = rd.Float();
		m_gunTemperature[i] = rd.Float();
	}
	m_ecmRecharge = rd.Float();
	m_shipFlavour.Load(rd);
	m_dockedWithPort = rd.Int32();
	m_dockedWithIndex = rd.Int32();
	m_equipment.InitSlotSizes(m_shipFlavour.type);
	m_equipment.Load(rd);
	Init();
	m_stats.hull_mass_left = rd.Float(); // must be after Init()...
	m_stats.shield_mass_left = rd.Float();
	if(rd.Int32()) m_curAICmd = AICommand::Load(rd);
	else m_curAICmd = 0;

	m_equipment.onChange.connect(sigc::mem_fun(this, &Ship::OnEquipmentChange));
}
Beispiel #16
0
void CollMesh::Load(Serializer::Reader &rd)
{
	m_aabb.max = rd.Vector3d();
	m_aabb.min = rd.Vector3d();
	m_aabb.radius = rd.Double();

	m_geomTree = new GeomTree(rd);

	const Uint32 numDynGeomTrees = rd.Int32();
	m_dynGeomTrees.reserve(numDynGeomTrees);
	for (Uint32 it = 0; it < numDynGeomTrees; ++it) {
		m_dynGeomTrees.push_back(new GeomTree(rd));
	}

	m_totalTris = rd.Int32();
}
Beispiel #17
0
void SpaceStation::Load(Serializer::Reader &rd, Space *space)
{
	ModelBody::Load(rd, space);

	m_oldAngDisplacement = 0.0;

	int num = rd.Int32();
	if (num > Equip::TYPE_MAX) throw SavedGameCorruptException();
	const Uint32 numShipDocking = rd.Int32();
	m_shipDocking.reserve(numShipDocking);
	for (Uint32 i=0; i<numShipDocking; i++) {
		m_shipDocking.push_back(shipDocking_t());
		shipDocking_t &sd = m_shipDocking.back();
		sd.shipIndex = rd.Int32();
		sd.stage = rd.Int32();
		sd.stagePos = rd.Float();
		sd.fromPos = rd.Vector3d();
		sd.fromRot = rd.RdQuaternionf();
	}
	// retrieve each of the bay groupings
	const Uint32 numBays = rd.Int32();
	mBayGroups.reserve(numBays);
	for (Uint32 i=0; i<numBays; i++) {
		mBayGroups.push_back(SpaceStationType::SBayGroup());
		SpaceStationType::SBayGroup &bay = mBayGroups.back();
		bay.minShipSize = rd.Int32();
		bay.maxShipSize = rd.Int32();
		bay.inUse = rd.Bool();
		const Uint32 numBayIds = rd.Int32();
		bay.bayIDs.reserve(numBayIds);
		for (Uint32 j=0; j<numBayIds; j++) {
			const Uint32 ID = rd.Int32();
			bay.bayIDs.push_back(ID);
		}
	}

	m_sbody = space->GetSystemBodyByIndex(rd.Int32());
	m_numPoliceDocked = rd.Int32();

	m_doorAnimationStep = rd.Double();
	m_doorAnimationState = rd.Double();

	InitStation();

	m_navLights->Load(rd);
}
Beispiel #18
0
Body *Body::Unserialize(Serializer::Reader &_rd, Space *space)
{
	Serializer::Reader rd = _rd.RdSection("Body");
	Body *b = 0;
	Object::Type type = Object::Type(rd.Int32());
	switch (type) {
		case Object::STAR:
			b = new Star(); break;
		case Object::PLANET:
			b = new Planet();
			break;
		case Object::SPACESTATION:
			b = new SpaceStation(); break;
		case Object::SHIP:
			b = new Ship(); break;
		case Object::PLAYER:
			b = new Player(); break;
		case Object::MISSILE:
			b = new Missile(); break;
		case Object::PROJECTILE:
			b = new Projectile(); break;
		case Object::CARGOBODY:
			b = new CargoBody(); break;
		case Object::HYPERSPACECLOUD:
			b = new HyperspaceCloud(); break;
		default:
			assert(0);
	}
	b->Load(rd, space);
	// must SetFrame() correctly so ModelBodies can add geom to space
	Frame *f = b->m_frame;
	b->m_frame = 0;
	b->SetFrame(f);
	//
	b->SetPosition(rd.Vector3d());
	matrix4x4d m;
	for (int i=0; i<16; i++) m[i] = rd.Double();
	b->SetRotMatrix(m);
	return b;
}
Beispiel #19
0
void SpaceStation::Load(Serializer::Reader &rd, Space *space)
{
	ModelBody::Load(rd, space);
	MarketAgent::Load(rd);
	int num = rd.Int32();
	if (num > Equip::TYPE_MAX) throw SavedGameCorruptException();
	for (int i=0; i<Equip::TYPE_MAX; i++) {
		m_equipmentStock[i] = 0;
	}
	for (int i=0; i<num; i++) {
		m_equipmentStock[i] = static_cast<Equip::Type>(rd.Int32());
	}
	// load shityard
	int numShipsForSale = rd.Int32();
	for (int i=0; i<numShipsForSale; i++) {
		ShipType::Id id(rd.String());
		std::string regId(rd.String());
		SceneGraph::ModelSkin skin;
		skin.Load(rd);
		ShipOnSale sos(id, regId, skin);
		m_shipsOnSale.push_back(sos);
	}
	for (int i=0; i<MAX_DOCKING_PORTS; i++) {
		m_shipDocking[i].shipIndex = rd.Int32();
		m_shipDocking[i].stage = rd.Int32();
		m_shipDocking[i].stagePos = rd.Float();
		m_shipDocking[i].fromPos = rd.Vector3d();
		m_shipDocking[i].fromRot = rd.RdQuaternionf();
	}
	m_dockingLock = rd.Bool();

	m_bbCreated = rd.Bool();
	m_lastUpdatedShipyard = rd.Double();
	m_sbody = space->GetSystemBodyByIndex(rd.Int32());
	m_numPoliceDocked = rd.Int32();
	InitStation();

	m_navLights->Load(rd);
}
Beispiel #20
0
void SpaceStation::Load(Serializer::Reader &rd, Space *space)
{
	ModelBody::Load(rd, space);
	MarketAgent::Load(rd);
	int num = rd.Int32();
	if (num > Equip::TYPE_MAX) throw SavedGameCorruptException();
	for (int i=0; i<Equip::TYPE_MAX; i++) {
		m_equipmentStock[i] = 0;
	}
	for (int i=0; i<num; i++) {
		m_equipmentStock[i] = static_cast<Equip::Type>(rd.Int32());
	}
	// load shityard
	int numShipsForSale = rd.Int32();
	for (int i=0; i<numShipsForSale; i++) {
		ShipType::Id id(rd.String());
		std::string regId(rd.String());
		SceneGraph::ModelSkin skin;
		skin.Load(rd);
		ShipOnSale sos(id, regId, skin);
		m_shipsOnSale.push_back(sos);
	}
	const int32_t numShipDocking = rd.Int32();
	m_shipDocking.reserve(numShipDocking);
	for (int i=0; i<numShipDocking; i++) {
		m_shipDocking.push_back(shipDocking_t());
		shipDocking_t &sd = m_shipDocking.back();
		sd.shipIndex = rd.Int32();
		sd.stage = rd.Int32();
		sd.stagePos = rd.Float();
		sd.fromPos = rd.Vector3d();
		sd.fromRot = rd.RdQuaternionf();
	}
	// retrieve each of the bay groupings
	const int32_t numBays = rd.Int32();
	mBayGroups.reserve(numBays);
	for (int32_t i=0; i<numBays; i++) {
		mBayGroups.push_back(SpaceStationType::SBayGroup());
		SpaceStationType::SBayGroup &bay = mBayGroups.back();
		bay.minShipSize = rd.Int32();
		bay.maxShipSize = rd.Int32();
		bay.inUse = rd.Bool();
		const int32_t numBayIds = rd.Int32();
		bay.bayIDs.reserve(numBayIds);
		for (int32_t j=0; j<numBayIds; j++) {
			const int32_t ID = rd.Int32();
			bay.bayIDs.push_back(ID);
		}
	}

	m_bbCreated = rd.Bool();
	m_lastUpdatedShipyard = rd.Double();
	m_sbody = space->GetSystemBodyByIndex(rd.Int32());
	m_numPoliceDocked = rd.Int32();

	m_doorAnimationStep = rd.Double();
	m_doorAnimationState = rd.Double();

	InitStation();

	m_navLights->Load(rd);
}
Beispiel #21
0
GeomTree::GeomTree(Serializer::Reader &rd)
{
	m_numVertices = rd.Int32();
	m_numEdges = rd.Int32();
	m_numTris = rd.Int32();
	m_radius = rd.Double();

	m_aabb.max = rd.Vector3d();
	m_aabb.min = rd.Vector3d();
	m_aabb.radius = rd.Double();

	const Uint32 numAabbs = rd.Int32();
	m_aabbs.resize(numAabbs);
	for (Uint32 iAabb = 0; iAabb < numAabbs; ++iAabb) {
		m_aabbs[iAabb].max = rd.Vector3d();
		m_aabbs[iAabb].min = rd.Vector3d();
		m_aabbs[iAabb].radius = rd.Double();
	}

	m_edges.resize(m_numEdges);
	for (Sint32 iEdge = 0; iEdge < m_numEdges; ++iEdge) {
		m_edges[iEdge].Load(rd);
	}

	m_vertices.resize(m_numVertices);
	for (Sint32 iVert = 0; iVert < m_numVertices; ++iVert) {
		m_vertices[iVert] = rd.Vector3f();
	}

	const int numIndicies(m_numTris * 3);
	m_indices.resize(numIndicies);
	for (Sint32 iIndi = 0; iIndi < numIndicies; ++iIndi) {
		m_indices[iIndi] = rd.Int16();
	}

	m_triFlags.resize(m_numTris);
	for (Sint32 iTri = 0; iTri < m_numTris; ++iTri) {
		m_triFlags[iTri] = rd.Int32();
	}

	// activeTris = tris we are still trying to put into leaves
	std::vector<int> activeTris;
	activeTris.reserve(m_numTris);
	// So, we ignore tris with flag >= 0x8000
	for (int i = 0; i<m_numTris; i++)
	{
		if (m_triFlags[i] >= IGNORE_FLAG) continue;
		activeTris.push_back(i * 3);
	}
	// regenerate the aabb data
	Aabb *aabbs = new Aabb[activeTris.size()];
	for (unsigned int i = 0; i<activeTris.size(); i++)
	{
		const vector3d v1 = vector3d(m_vertices[m_indices[activeTris[i] + 0]]);
		const vector3d v2 = vector3d(m_vertices[m_indices[activeTris[i] + 1]]);
		const vector3d v3 = vector3d(m_vertices[m_indices[activeTris[i] + 2]]);
		aabbs[i].min = aabbs[i].max = v1;
		aabbs[i].Update(v2);
		aabbs[i].Update(v3);
	}
	m_triTree.reset(new BVHTree(activeTris.size(), &activeTris[0], aabbs));
	delete[] aabbs;

	//
	int *edgeIdxs = new int[m_numEdges];
	memset(edgeIdxs, 0, sizeof(int)*m_numEdges);
	for (int i = 0; i<m_numEdges; i++) {
		edgeIdxs[i] = i;
	}
	m_edgeTree.reset(new BVHTree(m_numEdges, edgeIdxs, &m_aabbs[0]));
}