From 329771bb20094d2c4587310f1c3c2b7342d837e6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Feb 2016 20:41:57 +0300 Subject: Update last seen also from online list. It lack account id, but can update time. --- src/actormanager.cpp | 38 ++++++++++++++++++++++++++++++-------- src/actormanager.h | 2 ++ src/gui/windows/whoisonline.cpp | 4 ++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/actormanager.cpp b/src/actormanager.cpp index cc46ac34b..bfcc92e81 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1965,22 +1965,30 @@ void ActorManager::updateNameId(const std::string &name, if (!mEnableIdCollecting) return; const int id = static_cast(beingId); - if (id < 2000000 || id >= 110000000) + if (id && + id < 2000000 || + id >= 110000000) + { return; + } if (mIdName.find(beingId) == mIdName.end() || mIdName[beingId].find(name) == mIdName[beingId].end()) { mIdName[beingId].insert(name); - std::string dir = settings.usersIdDir; const std::string idStr = toString(id); - dir.append(idStr); - dir.append("/"); - dir.append(stringToHexPath(name)); const std::string dateStr = getDateTimeString(); - Files::saveTextFile(dir, - "info.txt", - (name + "\n").append(dateStr)); + std::string dir; + if (beingId != BeingId_zero) + { + dir = settings.usersIdDir; + dir.append(idStr); + dir.append("/"); + dir.append(stringToHexPath(name)); + Files::saveTextFile(dir, + "info.txt", + (name + "\n").append(dateStr)); + } dir = settings.usersDir; dir.append(stringToHexPath(name)); @@ -1990,6 +1998,20 @@ void ActorManager::updateNameId(const std::string &name, } } +void ActorManager::updateSeenPlayers(const std::set + &onlinePlayers) +{ + if (!mEnableIdCollecting) + return; + + FOR_EACH (std::set::const_iterator, it, onlinePlayers) + { + const std::string name = *it; + if (!findBeingByName(name, ActorType::Player)) + updateNameId(name, BeingId_zero); + } +} + #ifdef EATHENA_SUPPORT void ActorManager::removeRoom(const int chatId) { diff --git a/src/actormanager.h b/src/actormanager.h index 6e9020d20..2738181f7 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -359,6 +359,8 @@ class ActorManager final: public ConfigListener void updateNameId(const std::string &name, const BeingId beingId); + void updateSeenPlayers(const std::set &onlinePlayers); + size_t size() const { return mActors.size(); } diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 81225ba33..d51af6b05 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -346,6 +346,8 @@ void WhoIsOnline::loadList(const std::vector &list) chatWindow->updateOnline(mOnlineNicks); if (socialWindow) socialWindow->updateActiveList(); + if (actorManager) + actorManager->updateSeenPlayers(mOnlineNicks); } updateSize(); mFriends.clear(); @@ -681,6 +683,8 @@ void WhoIsOnline::slowLogic() chatWindow->updateOnline(mOnlineNicks); if (socialWindow) socialWindow->updateActiveList(); + if (actorManager) + actorManager->updateSeenPlayers(mOnlineNicks); } } break; -- cgit v1.2.3-60-g2f50