From 0928d201335e8c247a44a1406cfbee3921ee7901 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Feb 2016 18:39:14 +0300 Subject: Add option for saving mapping between account id and nicks. This information stored in separate files. --- src/actormanager.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/actormanager.cpp') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index ba8822bf0..a250fba35 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -42,6 +42,7 @@ #include "input/inputmanager.h" #include "utils/checkutils.h" +#include "utils/files.h" #include "utils/mathutils.h" #include "utils/gettext.h" @@ -191,6 +192,7 @@ class SortBeingFunctor final ActorManager::ActorManager() : mActors(), mDeleteActors(), + mIdName(), mBlockedBeings(), #ifdef EATHENA_SUPPORT mChars(), @@ -205,6 +207,7 @@ ActorManager::ActorManager() : mCycleMonsters(config.getBoolValue("cycleMonsters")), mCycleNPC(config.getBoolValue("cycleNPC")), mExtMouseTargeting(config.getBoolValue("extMouseTargeting")), + mEnableIdCollecting(config.getBoolValue("enableIdCollecting")), mPriorityAttackMobs(), mPriorityAttackMobsSet(), mPriorityAttackMobsMap(), @@ -226,6 +229,7 @@ ActorManager::ActorManager() : config.addListener("cycleNPC", this); config.addListener("extMouseTargeting", this); config.addListener("showBadges", this); + config.addListener("enableIdCollecting", this); loadAttackList(); } @@ -1666,6 +1670,8 @@ void ActorManager::optionChanged(const std::string &name) mExtMouseTargeting = config.getBoolValue("extMouseTargeting"); else if (name == "showBadges") updateBadges(); + else if (name == "enableIdCollecting") + mEnableIdCollecting = config.getBoolValue("enableIdCollecting"); } void ActorManager::removeAttackMob(const std::string &name) @@ -1953,6 +1959,29 @@ void ActorManager::updateBadges() } } +void ActorManager::updateNameId(const std::string &name, + const BeingId beingId) +{ + if (!mEnableIdCollecting) + return; + const int id = static_cast(beingId); + if (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; + dir.append(toString(id)); + dir.append("/"); + dir.append(stringToHexPath(name)); + Files::saveTextFile(dir, + "info.txt", + (name + "\n").append(getDateString())); + } +} + #ifdef EATHENA_SUPPORT void ActorManager::removeRoom(const int chatId) { -- cgit v1.2.3-70-g09d2