diff --git a/src/online/online_player_profile.cpp b/src/online/online_player_profile.cpp index aeef259a5..1dcec4a7d 100644 --- a/src/online/online_player_profile.cpp +++ b/src/online/online_player_profile.cpp @@ -459,6 +459,48 @@ namespace Online OnlineProfileFriends::getInstance()->refreshFriendsList(); } } + + std::map 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 > + friend_server_notify; + std::map& 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 { diff --git a/src/online/online_profile.hpp b/src/online/online_profile.hpp index 2985bf52d..29fda22bc 100644 --- a/src/online/online_profile.hpp +++ b/src/online/online_profile.hpp @@ -26,6 +26,7 @@ #include #include +#include #include namespace Online @@ -101,7 +102,7 @@ private: bool m_has_fetched_achievements; std::vector m_achievements; - + std::map m_friend_server_map; bool m_cache_bit; void storeFriends(const XMLNode * input); @@ -121,7 +122,9 @@ public: void deleteRelationalInfo(); const IDList& getAchievements(); void merge(OnlineProfile * profile); - + // ------------------------------------------------------------------------ + std::map& getFriendServerMap() + { return m_friend_server_map; } // ------------------------------------------------------------------------ /** Returns true if the achievements for this profile have been fetched. */ bool hasFetchedAchievements() const { return m_has_fetched_achievements; }