diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-14 23:23:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-14 23:36:38 +0300 |
commit | bf9bccc30a186e338f96c230a4f63cc924c77bd8 (patch) | |
tree | e46dbc2f022842982d89164ee598e1bcf827aa39 /src/being.cpp | |
parent | fb0f86589ae9e2d582383cea43e0a391e8d4739d (diff) | |
download | plus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.tar.gz plus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.tar.bz2 plus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.tar.xz plus-bf9bccc30a186e338f96c230a4f63cc924c77bd8.zip |
Add ability to add comments to any players.
Diffstat (limited to 'src/being.cpp')
-rw-r--r-- | src/being.cpp | 41 |
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) { |