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

Method writeStatistics

source/game/StarStatistics.cpp:21–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21void Statistics::writeStatistics() {
22 auto versioningDatabase = Root::singleton().versioningDatabase();
23 String filename = File::relativeTo(m_storageDirectory, "statistics");
24
25 Json stats = JsonObject::from(m_stats.pairs().transformed([](auto const& entry) {
26 return make_pair(entry.first, entry.second.toJson());
27 }));
28 JsonObject storage = {
29 { "stats", stats },
30 { "achievements", jsonFromStringSet(m_achievements) }
31 };
32
33 auto versionedStorage = versioningDatabase->makeCurrentVersionedJson("Statistics", storage);
34 VersionedJson::writeFile(versionedStorage, filename);
35}
36
37Json Statistics::stat(String const& name, Json def) const {
38 if (m_stats.contains(name))

Callers 2

shutdownMethod · 0.80
changeStateMethod · 0.80

Calls 7

singletonClass · 0.85
jsonFromStringSetFunction · 0.85
versioningDatabaseMethod · 0.80
transformedMethod · 0.45
pairsMethod · 0.45
toJsonMethod · 0.45

Tested by

no test coverage detected