MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / toJson

Method toJson

source/game/StarCelestialTypes.cpp:72–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72Json 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
106DataStream& operator>>(DataStream& ds, CelestialChunk& chunk) {
107 ds.read(chunk.chunkIndex);

Callers

nothing calls this directly

Calls 4

jsonFromVec2IFunction · 0.85
jsonFromVec3IFunction · 0.85
appendMethod · 0.45
diskStoreMethod · 0.45

Tested by

no test coverage detected