| 66 | } |
| 67 | |
| 68 | void 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 | |
| 101 | Statistics::Stat Statistics::Stat::fromJson(Json const& json) { |
| 102 | return Stat { |
nothing calls this directly
no test coverage detected