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

Method update

source/game/StarStatistics.cpp:68–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void Statistics::update() {
69 if (m_service) {
70 if (auto error = m_service->error()) {
71 Logger::error("Statistics platform service error: {}", *error);
72 // Service failed. Continue with local stats and achievements only.
73 m_service = {};
74 m_initialized = true;
75 return;
76 }
77 }
78
79 if (!m_initialized) {
80 if (m_service->initialized()) {
81 mergeServiceStatistics();
82 m_initialized = true;
83 }
84 }
85
86 for (auto event : m_pendingEvents) {
87 processEvent(event.first, event.second);
88 }
89
90 for (String const& achievement : m_pendingAchievementChecks) {
91 if (checkAchievement(achievement))
92 unlockAchievement(achievement);
93 }
94
95 if (m_service && (m_pendingEvents.size() > 0 || m_pendingAchievementChecks.size() > 0))
96 m_service->flush();
97 m_pendingEvents = {};
98 m_pendingAchievementChecks = {};
99}
100
101Statistics::Stat Statistics::Stat::fromJson(Json const& json) {
102 return Stat {

Callers

nothing calls this directly

Calls 5

errorFunction · 0.85
errorMethod · 0.45
initializedMethod · 0.45
sizeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected