| 171 | } |
| 172 | |
| 173 | void Statistics::mergeServiceStatistics() { |
| 174 | if (!m_service || !m_service->initialized() || m_service->error()) return; |
| 175 | |
| 176 | // Publish achievements we unlocked when the platform service was unavailable. |
| 177 | StringSet serviceAchievements = m_service->achievementsUnlocked(); |
| 178 | for (String const& achievement : m_achievements.difference(serviceAchievements)) { |
| 179 | m_service->unlockAchievement(achievement); |
| 180 | } |
| 181 | // Locally store all the achievements we unlocked in a different install: |
| 182 | m_achievements.addAll(serviceAchievements); |
| 183 | |
| 184 | // Publish our local statistics, in case we made progress while the service |
| 185 | // was unavailable. |
| 186 | for (auto const& stat : m_stats) { |
| 187 | m_service->setStat(stat.first, stat.second.type, stat.second.value); |
| 188 | } |
| 189 | |
| 190 | // However, don't _pull_ stats from the service - not all stats are recorded |
| 191 | // so inconsistencies will creep in if we try. For example, if the service |
| 192 | // is recording the number of poptop kills but not the total number of kills, |
| 193 | // we could end up with a situation like "2 total kills, 8 poptops killed." |
| 194 | |
| 195 | // The best we can do is let the client be authoritative over its stats and |
| 196 | // have the service validate changes it receives to make sure they only |
| 197 | // ever increase. |
| 198 | |
| 199 | m_service->flush(); |
| 200 | } |
| 201 | |
| 202 | LuaCallbacks Statistics::makeStatisticsCallbacks() { |
| 203 | LuaCallbacks callbacks; |
nothing calls this directly
no test coverage detected