void GameData::WriteEconomy(DataWriter &out) { out.Write("economy"); out.BeginChild(); { if(!purchases.empty()) { out.Write("purchases"); out.BeginChild(); for(const auto &pit : purchases) for(const auto &cit : pit.second) out.Write(pit.first->Name(), cit.first, cit.second); out.EndChild(); } out.WriteToken("system"); for(const auto &cit : GameData::Commodities()) out.WriteToken(cit.name); out.Write(); for(const auto &sit : GameData::Systems()) { out.WriteToken(sit.second.Name()); for(const auto &cit : GameData::Commodities()) out.WriteToken(static_cast<int>(sit.second.Supply(cit.name))); out.Write(); } } out.EndChild(); }
void Planet::Save(DataWriter &file) const { file.Write("planet", name); file.BeginChild(); { if(!attributes.empty()) { file.WriteToken("attributes"); for(const QString &it : attributes) file.WriteToken(it); file.Write(); } file.Write("landscape", landscape); // Break the descriptions into paragraphs. for(const QString &str : description.split('\n', QString::SkipEmptyParts)) { file.WriteToken("description"); file.WriteToken(str, '`'); file.Write(); } for(const QString &str : spaceport.split('\n', QString::SkipEmptyParts)) { file.WriteToken("spaceport"); file.WriteToken(str, '`'); file.Write(); } for(const QString &it : shipyard) file.Write("shipyard", it); for(const QString &it : outfitter) file.Write("outfitter", it); if(!std::isnan(requiredReputation)) file.Write("required reputation", requiredReputation); if(!std::isnan(bribe)) file.Write("bribe", bribe); if(!std::isnan(security)) file.Write("security", security); for(const DataNode &node : unparsed) file.Write(node); } file.EndChild(); }