void GeomTree::Save(Serializer::Writer &wr) const { wr.Int32(m_numVertices); wr.Int32(m_numEdges); wr.Int32(m_numTris); wr.Double(m_radius); wr.Vector3d(m_aabb.max); wr.Vector3d(m_aabb.min); wr.Double(m_aabb.radius); wr.Int32(m_numEdges); for (Sint32 iAabb = 0; iAabb < m_numEdges; ++iAabb) { wr.Vector3d(m_aabbs[iAabb].max); wr.Vector3d(m_aabbs[iAabb].min); wr.Double(m_aabbs[iAabb].radius); } for (Sint32 iEdge = 0; iEdge < m_numEdges; ++iEdge) { m_edges[iEdge].Save(wr); } for (Sint32 iVert = 0; iVert < m_numVertices; ++iVert) { wr.Vector3f(m_vertices[iVert]); } for (Sint32 iIndi = 0; iIndi < (m_numTris * 3); ++iIndi) { wr.Int16(m_indices[iIndi]); } for (Sint32 iTri = 0; iTri < m_numTris; ++iTri) { wr.Int32(m_triFlags[iTri]); } }
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); }
void BinaryConverter::SaveAnimations(Serializer::Writer &wr, Model *m) { const auto& anims = m->GetAnimations(); wr.Int32(anims.size()); for (const auto& anim : anims) { wr.String(anim->GetName()); wr.Double(anim->GetDuration()); wr.Int32(anim->GetChannels().size()); for (const auto &chan : anim->GetChannels()) { wr.String(chan.node->GetName()); //write pos/rot/scale keys wr.Int32(chan.positionKeys.size()); for (const auto &pkey : chan.positionKeys) { wr.Double(pkey.time); wr.Vector3f(pkey.position); } wr.Int32(chan.rotationKeys.size()); for (const auto &rkey : chan.rotationKeys) { wr.Double(rkey.time); wr.WrQuaternionf(rkey.rotation); } wr.Int32(chan.scaleKeys.size()); for (const auto &skey : chan.scaleKeys) { wr.Double(skey.time); wr.Vector3f(skey.scale); } } } }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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()); }
void SpaceStation::Save(Serializer::Writer &wr) { ModelBody::Save(wr); 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<ShipFlavour>::iterator i = m_shipsOnSale.begin(); i != m_shipsOnSale.end(); ++i) { (*i).Save(wr); } for (int i=0; i<MAX_DOCKING_PORTS; i++) { wr.Int32(Serializer::LookupBody(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.Float(float(m_openAnimState[i])); wr.Float(float(m_dockAnimState[i])); } wr.Double(m_lastUpdatedShipyard); wr.Int32(Serializer::LookupSystemBody(m_sbody)); wr.Int32(m_numPoliceDocked); }
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()); }
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); }
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()); }
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); }
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); }
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); }
void PlayerShipController::Save(Serializer::Writer &wr, Space *space) { wr.Int32(static_cast<int>(m_flightControlState)); wr.Double(m_setSpeed); wr.Float(m_lowThrustPower); wr.Int32(space->GetIndexForBody(m_combatTarget)); wr.Int32(space->GetIndexForBody(m_navTarget)); wr.Int32(space->GetIndexForBody(m_setSpeedTarget)); }
void Projectile::Save(Serializer::Writer &wr, Space *space) { Body::Save(wr, space); for (int i=0; i<16; i++) wr.Double(m_orient[i]); wr.Vector3d(m_baseVel); wr.Vector3d(m_dirVel); wr.Float(m_age); wr.Int32(m_type); wr.Int32(space->GetIndexForBody(m_parent)); }
void Player::Save(Serializer::Writer &wr, Space *space) { Ship::Save(wr, space); MarketAgent::Save(wr); wr.Int32(static_cast<int>(m_flightControlState)); wr.Double(m_setSpeed); wr.Int32(m_killCount); wr.Int32(m_knownKillCount); wr.Int32(space->GetIndexForBody(m_combatTarget)); wr.Int32(space->GetIndexForBody(m_navTarget)); wr.Int32(space->GetIndexForBody(m_setSpeedTarget)); }
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); }
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); }
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)); }
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]); }