Fixed some iterator issue and a bug in the notification messages

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13530 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-08-21 01:15:00 +00:00
parent fc789d6b3d
commit 1f45958323
2 changed files with 12 additions and 6 deletions

View File

@ -429,6 +429,7 @@ namespace Online{
for(unsigned int i = 0; i < parts.size(); ++i) for(unsigned int i = 0; i < parts.size(); ++i)
{ {
online_friends.push_back(atoi(parts[i].c_str())); online_friends.push_back(atoi(parts[i].c_str()));
Log::info("online friend", "%d", online_friends[i]);
} }
std::vector<uint32_t> friends = CurrentUser::get()->getProfile()->getFriends(); std::vector<uint32_t> friends = CurrentUser::get()->getProfile()->getFriends();
std::vector<irr::core::stringw> to_notify; std::vector<irr::core::stringw> to_notify;
@ -439,7 +440,8 @@ namespace Online{
{ {
if (*iter == friends[i]) if (*iter == friends[i])
{ {
online_friends.erase(iter++); Log::info("found online friend", "%d", *iter);
online_friends.erase(iter--);
break; break;
} }
else else
@ -447,7 +449,10 @@ namespace Online{
} }
bool now_online = false; bool now_online = false;
if(iter != online_friends.end()) if(iter != online_friends.end())
{
now_online = true; now_online = true;
Log::info("now online", "%d", *iter);
}
Profile * profile = ProfileManager::get()->getProfileByID(friends[i]); Profile * profile = ProfileManager::get()->getProfileByID(friends[i]);
Profile::RelationInfo * relation_info = profile->getRelationInfo(); Profile::RelationInfo * relation_info = profile->getRelationInfo();
@ -462,6 +467,7 @@ namespace Online{
{ {
relation_info->setOnline(true); relation_info->setOnline(true);
to_notify.push_back(profile->getUserName()); to_notify.push_back(profile->getUserName());
Log::info("adding", "%d", friends[i]);
} }
} }
@ -472,19 +478,19 @@ namespace Online{
irr::core::stringw message(""); irr::core::stringw message("");
if(to_notify.size() == 1) if(to_notify.size() == 1)
{ {
message = to_notify[0] + _(" is now online."); message = to_notify[0] + irr::core::stringw(_(" is now online."));
} }
else if(to_notify.size() == 2) else if(to_notify.size() == 2)
{ {
message = to_notify[0] + _(" and ") + to_notify[1] + _(" are now online."); message = to_notify[0] + irr::core::stringw(_(" and ")) + to_notify[1] + irr::core::stringw(_(" are now online."));
} }
else if(to_notify.size() == 3) else if(to_notify.size() == 3)
{ {
message = to_notify[0] + _(", ") + to_notify[1] + _(" and ") + to_notify[2] + _(" are now online."); message = to_notify[0] + irr::core::stringw(_(", ")) + to_notify[1] + irr::core::stringw(_(" and ")) + to_notify[2] + irr::core::stringw(_(" are now online."));
} }
else if(to_notify.size() > 3) else if(to_notify.size() > 3)
{ {
message = StringUtils::toWString(to_notify.size()) + _(" friends are now online."); message = StringUtils::toWString(to_notify.size()) + irr::core::stringw(_(" friends are now online."));
} }
GUIEngine::DialogQueue::get()->pushDialog( new MessageDialog(message, true), false); GUIEngine::DialogQueue::get()->pushDialog( new MessageDialog(message, true), false);
OnlineProfileFriends::getInstance()->refreshFriendsList(); OnlineProfileFriends::getInstance()->refreshFriendsList();

View File

@ -79,7 +79,7 @@ namespace Online{
curl_global_init(CURL_GLOBAL_DEFAULT); curl_global_init(CURL_GLOBAL_DEFAULT);
pthread_cond_init(&m_cond_request, NULL); pthread_cond_init(&m_cond_request, NULL);
m_abort.setAtomic(false); m_abort.setAtomic(false);
m_time_since_poll = 0.0f; m_time_since_poll = MENU_POLLING_INTERVAL * (2.0/3.0);
m_polling = false; m_polling = false;
} }