Skip to content
Browse files

Use the new stkaddons feeature to allow more than one achievements to

be sent at a time. This means only one server request when local
achievements are synched to the online account.
  • Loading branch information...
1 parent fa2913c commit 6dd4c6f8030d3964ae66bb06df2ef0a8d392ed57 @hiker hiker committed Jun 16, 2014
Showing with 16 additions and 7 deletions.
  1. +16 −7 src/achievements/achievements_status.cpp
View
23 src/achievements/achievements_status.cpp
@@ -133,19 +133,28 @@ void AchievementsStatus::sync(const std::vector<uint32_t> & achieved_ids)
std::map<uint32_t, Achievement*>::iterator i;
+ // String to collect all local ids that are not synched
+ // to the online account
+ std::string ids;
for(i=m_achievements.begin(); i!=m_achievements.end(); i++)
{
- int id = i->second->getID();
+ unsigned int id = i->second->getID();
if(i->second->isAchieved() && (id>=done.size() || !done[id]) )
{
- Log::info("Achievements", "Synching achievement %d to server.",
- i->first);
- Online::HTTPRequest * request = new Online::HTTPRequest(true,2);
- PlayerManager::setUserDetails(request, "achieving");
- request->addParameter("achievementid", i->second->getID());
- request->queue();
+ ids=ids+StringUtils::toString(id)+",";
}
}
+
+ if(ids.size()>0)
+ {
+ ids.pop_back(); // delete the last "," in the string
+ Log::info("Achievements", "Synching achievement %d to server.",
+ ids.c_str());
+ Online::HTTPRequest * request = new Online::HTTPRequest(true, 2);
+ PlayerManager::setUserDetails(request, "achieving");
+ request->addParameter("achievementid", ids);
+ request->queue();
+ }
} // sync
// ----------------------------------------------------------------------------

0 comments on commit 6dd4c6f

Please sign in to comment.
Something went wrong with that request. Please try again.