From bfd533ab5469c1c5998ee823cd861968f4ce4ef4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Feb 2016 01:10:55 +0300 Subject: Show also last seen in memory nick for invisible players chat messages (tmwa) --- src/actormanager.cpp | 10 ++++++++++ src/actormanager.h | 2 ++ src/net/tmwa/chatrecv.cpp | 5 +++++ 3 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 6b27e3205..d851864a3 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -2062,6 +2062,16 @@ void ActorManager::updateSeenPlayers(const std::set } } +std::string ActorManager::getSeenPlayerById(const BeingId id) +{ + if (!mEnableIdCollecting) + return std::string(); + + if (mIdName.find(id) != mIdName.end() && !mIdName[id].empty()) + return *(mIdName[id].begin()); + return std::string(); +} + #ifdef EATHENA_SUPPORT void ActorManager::removeRoom(const int chatId) { diff --git a/src/actormanager.h b/src/actormanager.h index 28aa25417..78f53a6d5 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -363,6 +363,8 @@ class ActorManager final: public ConfigListener void updateSeenPlayers(const std::set &onlinePlayers); + std::string getSeenPlayerById(const BeingId id); + size_t size() const { return mActors.size(); } diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp index 27ca74a41..f4bb3725d 100644 --- a/src/net/tmwa/chatrecv.cpp +++ b/src/net/tmwa/chatrecv.cpp @@ -314,7 +314,12 @@ void ChatRecv::processBeingChat(Net::MessageIn &msg) if (being) sender_name = being->getName(); if (sender_name.empty()) + { sender_name = "?" + toString(CAST_S32(beingId)); + const std::string name = actorManager->getSeenPlayerById(beingId); + if (!name.empty()) + sender_name.append(" ").append(name); + } } else if (being && sender_name != being->getName() && -- cgit v1.2.3-70-g09d2