| 70 | } |
| 71 | |
| 72 | Json CelestialChunk::toJson() const { |
| 73 | JsonArray constellationStore; |
| 74 | for (auto const& constellation : constellations) { |
| 75 | JsonArray lines; |
| 76 | for (auto const& p : constellation) |
| 77 | lines.append(JsonArray{jsonFromVec2I(p.first), jsonFromVec2I(p.second)}); |
| 78 | constellationStore.append(lines); |
| 79 | } |
| 80 | |
| 81 | JsonArray systemParametersStore; |
| 82 | for (auto const& p : systemParameters) |
| 83 | systemParametersStore.append(JsonArray{jsonFromVec3I(p.first), p.second.diskStore()}); |
| 84 | |
| 85 | JsonArray systemObjectsStore; |
| 86 | for (auto const& systemObjectPair : systemObjects) { |
| 87 | JsonArray planetsStore; |
| 88 | for (auto const& planetPair : systemObjectPair.second) { |
| 89 | JsonArray satellitesStore; |
| 90 | for (auto const& satellitePair : planetPair.second.satelliteParameters) |
| 91 | satellitesStore.append(JsonArray{satellitePair.first, satellitePair.second.diskStore()}); |
| 92 | |
| 93 | planetsStore.append(JsonArray{planetPair.first, |
| 94 | JsonObject{ |
| 95 | {"parameters", planetPair.second.planetParameters.diskStore()}, {"satellites", std::move(satellitesStore)}}}); |
| 96 | } |
| 97 | systemObjectsStore.append(JsonArray{jsonFromVec3I(systemObjectPair.first), std::move(planetsStore)}); |
| 98 | } |
| 99 | |
| 100 | return JsonObject{{"chunkIndex", jsonFromVec2I(chunkIndex)}, |
| 101 | {"constellations", constellationStore}, |
| 102 | {"systemParameters", systemParametersStore}, |
| 103 | {"systemObjects", systemObjectsStore}}; |
| 104 | } |
| 105 | |
| 106 | DataStream& operator>>(DataStream& ds, CelestialChunk& chunk) { |
| 107 | ds.read(chunk.chunkIndex); |
nothing calls this directly
no test coverage detected