summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-03 18:39:14 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-03 18:39:14 +0300
commit0928d201335e8c247a44a1406cfbee3921ee7901 (patch)
tree06e5d2acf36921f368ae445ba1eac8e351181f18
parent74397044b572c323f9c6bbc6338c17ce743ee3af (diff)
downloadManaVerse-0928d201335e8c247a44a1406cfbee3921ee7901.tar.gz
ManaVerse-0928d201335e8c247a44a1406cfbee3921ee7901.tar.bz2
ManaVerse-0928d201335e8c247a44a1406cfbee3921ee7901.tar.xz
ManaVerse-0928d201335e8c247a44a1406cfbee3921ee7901.zip
Add option for saving mapping between account id and nicks.
This information stored in separate files.
-rw-r--r--src/actormanager.cpp29
-rw-r--r--src/actormanager.h7
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/dirs.cpp16
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp4
-rw-r--r--src/net/ea/beingrecv.cpp5
-rw-r--r--src/net/eathena/beingrecv.cpp12
-rw-r--r--src/settings.h2
8 files changed, 65 insertions, 11 deletions
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<int>(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)
{
diff --git a/src/actormanager.h b/src/actormanager.h
index 536c70b63..6e9020d20 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -56,6 +56,8 @@ typedef std::set<ActorSprite*> ActorSprites;
typedef ActorSprites::iterator ActorSpritesIterator;
typedef ActorSprites::const_iterator ActorSpritesConstIterator;
+typedef std::map<BeingId, std::set<std::string> > IdNameMapping;
+
class ActorManager final: public ConfigListener
{
public:
@@ -354,6 +356,9 @@ class ActorManager final: public ConfigListener
void updateBadges();
+ void updateNameId(const std::string &name,
+ const BeingId beingId);
+
size_t size() const
{ return mActors.size(); }
@@ -389,6 +394,7 @@ class ActorManager final: public ConfigListener
ActorSprites mActors;
ActorSprites mDeleteActors;
+ IdNameMapping mIdName;
std::set<BeingId> mBlockedBeings;
#ifdef EATHENA_SUPPORT
std::map<int32_t, std::string> mChars;
@@ -403,6 +409,7 @@ class ActorManager final: public ConfigListener
bool mCycleMonsters;
bool mCycleNPC;
bool mExtMouseTargeting;
+ bool mEnableIdCollecting;
#define defVarsP(mob) \
std::list<std::string> mPriority##mob;\
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 5ab858a5f..4b5f4748f 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -384,6 +384,7 @@ DefaultsData* getConfigDefaults()
AddDEF("logPlayerActions", false);
AddDEF("enableGuiOpacity", true);
AddDEF("enableTradeFilter", true);
+ AddDEF("enableIdCollecting", true);
return configData;
}
diff --git a/src/dirs.cpp b/src/dirs.cpp
index 190249737..daf332b54 100644
--- a/src/dirs.cpp
+++ b/src/dirs.cpp
@@ -581,15 +581,23 @@ void Dirs::initUsersDir()
if (mkdir_r(settings.usersDir.c_str()))
{
// TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created! "
- "Exiting."), settings.usersDir.c_str()));
+ logger->error(strprintf(_("%s doesn't exist and can't be created!"),
+ settings.usersDir.c_str()));
}
settings.npcsDir = settings.serverConfigDir + "/npcs/";
if (mkdir_r(settings.npcsDir.c_str()))
{
// TRANSLATORS: directory creation error
- logger->error(strprintf(_("%s doesn't exist and can't be created! "
- "Exiting."), settings.npcsDir.c_str()));
+ logger->error(strprintf(_("%s doesn't exist and can't be created!"),
+ settings.npcsDir.c_str()));
+ }
+
+ settings.usersIdDir = settings.serverConfigDir + "/usersid/";
+ if (mkdir_r(settings.usersIdDir.c_str()))
+ {
+ // TRANSLATORS: directory creation error
+ logger->error(strprintf(_("%s doesn't exist and can't be created!"),
+ settings.usersIdDir.c_str()));
}
}
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index bf0dce6b9..402caeedb 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -121,6 +121,10 @@ Setup_Players::Setup_Players(const Widget2 *const widget) :
"hideErased", this, "hideErasedEvent");
// TRANSLATORS: settings option
+ new SetupItemCheckBox(_("Collect players id"),
+ "", "enableIdCollecting", this, "enableIdCollectingEvent");
+
+ // TRANSLATORS: settings option
new SetupItemCheckBox(_("Use special diagonal speed in players moving"),
"", "useDiagonalSpeed", this, "useDiagonalSpeedEvent");
diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp
index cb8af0318..21e79a089 100644
--- a/src/net/ea/beingrecv.cpp
+++ b/src/net/ea/beingrecv.cpp
@@ -310,8 +310,11 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg)
}
const BeingId beingId = msg.readBeingId("being id");
+ const std::string name = msg.readString(24, "name");
Being *const dstBeing = actorManager->findBeing(beingId);
+ actorManager->updateNameId(name, beingId);
+
if (dstBeing)
{
if (beingId == localPlayer->getId())
@@ -320,7 +323,6 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg)
}
else
{
- const std::string name = msg.readString(24, "name");
if (dstBeing->getType() != ActorType::Portal)
{
dstBeing->setName(name);
@@ -357,7 +359,6 @@ void BeingRecv::processNameResponse(Net::MessageIn &msg)
return;
}
}
- msg.readString(24, "name");
BLOCK_END("BeingRecv::processNameResponse")
}
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp
index bb6fff382..35e983296 100644
--- a/src/net/eathena/beingrecv.cpp
+++ b/src/net/eathena/beingrecv.cpp
@@ -1291,12 +1291,13 @@ void BeingRecv::processPlayerGuilPartyInfo(Net::MessageIn &msg)
return;
}
- Being *const dstBeing = actorManager->findBeing(
- msg.readBeingId("being id"));
-
+ const BeingId beingId = msg.readBeingId("being id");
+ const std::string name = msg.readString(24, "char name");
+ actorManager->updateNameId(name, beingId);
+ Being *const dstBeing = actorManager->findBeing(beingId);
if (dstBeing)
{
- dstBeing->setName(msg.readString(24, "char name"));
+ dstBeing->setName(name);
dstBeing->setPartyName(msg.readString(24, "party name"));
dstBeing->setGuildName(msg.readString(24, "guild name"));
dstBeing->setGuildPos(msg.readString(24, "guild pos"));
@@ -1621,8 +1622,9 @@ void BeingRecv::processNameResponse2(Net::MessageIn &msg)
}
const int len = msg.readInt16("len");
- const BeingId beingId = msg.readBeingId("account ic");
+ const BeingId beingId = msg.readBeingId("account id");
const std::string str = msg.readString(len - 8, "name");
+ actorManager->updateNameId(str, beingId);
Being *const dstBeing = actorManager->findBeing(beingId);
if (dstBeing)
{
diff --git a/src/settings.h b/src/settings.h
index a8e2bfdd0..96e77e06f 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -44,6 +44,7 @@ class Settings final
onlineListUrl(),
serverConfigDir(),
usersDir(),
+ usersIdDir(),
npcsDir(),
supportUrl(),
logFileName(),
@@ -90,6 +91,7 @@ class Settings final
std::string onlineListUrl;
std::string serverConfigDir;
std::string usersDir;
+ std::string usersIdDir;
std::string npcsDir;
std::string supportUrl;
std::string logFileName;