Show friends currently joined servers when polling user profile
This commit is contained in:
parent
83d49389d6
commit
c8a42fd355
@ -459,6 +459,48 @@ namespace Online
|
|||||||
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
OnlineProfileFriends::getInstance()->refreshFriendsList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<uint32_t, core::stringw> friend_server_map;
|
||||||
|
for (unsigned int i = 0; i < getXMLData()->getNumNodes(); i++)
|
||||||
|
{
|
||||||
|
const XMLNode * node = getXMLData()->getNode(i);
|
||||||
|
if (node->getName() == "friend-in-server")
|
||||||
|
{
|
||||||
|
uint32_t id = 0;
|
||||||
|
core::stringw server_name;
|
||||||
|
node->get("id", &id);
|
||||||
|
node->get("name", &server_name);
|
||||||
|
friend_server_map[id] = server_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::vector<std::pair<core::stringw, core::stringw> >
|
||||||
|
friend_server_notify;
|
||||||
|
std::map<uint32_t, core::stringw>& cur_friend_server_map =
|
||||||
|
PlayerManager::getCurrentPlayer()->getProfile()
|
||||||
|
->getFriendServerMap();
|
||||||
|
for (auto& p : friend_server_map)
|
||||||
|
{
|
||||||
|
if (friend_server_notify.size() > 3)
|
||||||
|
break;
|
||||||
|
uint32_t uid = p.first;
|
||||||
|
const core::stringw& server_name = p.second;
|
||||||
|
if (cur_friend_server_map.find(uid) ==
|
||||||
|
cur_friend_server_map.end() ||
|
||||||
|
cur_friend_server_map.at(uid) != server_name)
|
||||||
|
{
|
||||||
|
friend_server_notify.emplace_back(ProfileManager::get()
|
||||||
|
->getProfileByID(uid)->getUserName(), server_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto& p : friend_server_notify)
|
||||||
|
{
|
||||||
|
// I18N: Show in game to tell your friend if your friend is on
|
||||||
|
// any server
|
||||||
|
core::stringw message = _("%s is now on server \"%s\"",
|
||||||
|
p.first, p.second);
|
||||||
|
MessageQueue::add(MessageQueue::MT_FRIEND, message);
|
||||||
|
}
|
||||||
|
std::swap(cur_friend_server_map, friend_server_map);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <irrString.h>
|
#include <irrString.h>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Online
|
namespace Online
|
||||||
@ -101,7 +102,7 @@ private:
|
|||||||
|
|
||||||
bool m_has_fetched_achievements;
|
bool m_has_fetched_achievements;
|
||||||
std::vector<uint32_t> m_achievements;
|
std::vector<uint32_t> m_achievements;
|
||||||
|
std::map<uint32_t, core::stringw> m_friend_server_map;
|
||||||
bool m_cache_bit;
|
bool m_cache_bit;
|
||||||
|
|
||||||
void storeFriends(const XMLNode * input);
|
void storeFriends(const XMLNode * input);
|
||||||
@ -121,7 +122,9 @@ public:
|
|||||||
void deleteRelationalInfo();
|
void deleteRelationalInfo();
|
||||||
const IDList& getAchievements();
|
const IDList& getAchievements();
|
||||||
void merge(OnlineProfile * profile);
|
void merge(OnlineProfile * profile);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
std::map<uint32_t, core::stringw>& getFriendServerMap()
|
||||||
|
{ return m_friend_server_map; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns true if the achievements for this profile have been fetched. */
|
/** Returns true if the achievements for this profile have been fetched. */
|
||||||
bool hasFetchedAchievements() const { return m_has_fetched_achievements; }
|
bool hasFetchedAchievements() const { return m_has_fetched_achievements; }
|
||||||
|
Loading…
Reference in New Issue
Block a user