summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/being.cpp b/src/being.cpp
index d45bbcf74..508f56aef 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -216,7 +216,9 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
mMinHit(0),
mMaxHit(0),
mCriticalHit(0),
- mPvpRank(0)
+ mPvpRank(0),
+ mComment(""),
+ mGotComment(false)
{
mSpriteRemap = new int[20];
mSpriteHide = new int[20];
@@ -236,6 +238,8 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
if (getType() == PLAYER)
mShowName = config.getBoolValue("visiblenames");
+ else
+ mGotComment = true;
config.addListener("visiblenames", this);
@@ -2251,6 +2255,41 @@ void Being::clearCache()
beingInfoCache.clear();
}
+void Being::updateComment()
+{
+ if (mGotComment || mName.empty())
+ return;
+
+ mGotComment = true;
+ mComment = loadComment(mName);
+}
+
+std::string Being::loadComment(const std::string &name)
+{
+ std::string str = Client::getUsersDirectory()
+ + stringToHexPath(name) + "/comment.txt";
+ std::vector<std::string> lines;
+
+ ResourceManager *resman = ResourceManager::getInstance();
+ if (resman->existsLocal(str))
+ {
+ lines = resman->loadTextFileLocal(str);
+ if (lines.size() >= 2)
+ return lines[1];
+ }
+ return "";
+}
+
+void Being::saveComment(const std::string &name,
+ const std::string &comment)
+{
+ std::string dir = Client::getUsersDirectory()
+ + stringToHexPath(name);
+ std::string fileName = dir + "/comment.txt";
+ ResourceManager *resman = ResourceManager::getInstance();
+ resman->saveTextFile(dir, "comment.txt", name + "\n" + comment);
+}
+
BeingEquipBackend::BeingEquipBackend(Being *being):
mBeing(being)
{