summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-12 01:53:54 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-12 01:53:54 +0300
commitfca4273667f15afba055d3c296094f2f41c7ae91 (patch)
treed2a24602a4a60814a5927384570d2873bed83225 /src/being.cpp
parent44e80c70513022b6c378f64d6bf5d25dda7b0e7f (diff)
downloadmanaplus-fca4273667f15afba055d3c296094f2f41c7ae91.tar.gz
manaplus-fca4273667f15afba055d3c296094f2f41c7ae91.tar.bz2
manaplus-fca4273667f15afba055d3c296094f2f41c7ae91.tar.xz
manaplus-fca4273667f15afba055d3c296094f2f41c7ae91.zip
Add ability to add comments to npcs.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/being.cpp b/src/being.cpp
index cd616fc67..b6f06a75a 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -263,7 +263,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map):
if (mType == PLAYER)
mShowName = config.getBoolValue("visiblenames");
- else
+ else if (mType != NPC)
mGotComment = true;
config.addListener("visiblenames", this);
@@ -2363,13 +2363,26 @@ void Being::updateComment()
return;
mGotComment = true;
- mComment = loadComment(mName);
+ mComment = loadComment(mName, mType);
}
-std::string Being::loadComment(const std::string &name)
+std::string Being::loadComment(const std::string &name, int type)
{
- std::string str = Client::getUsersDirectory()
- + stringToHexPath(name) + "/comment.txt";
+ std::string str;
+ switch (type)
+ {
+ case PLAYER:
+ str = Client::getUsersDirectory();
+ break;
+ case NPC:
+ str = Client::getNpcsDirectory();
+ break;
+ default:
+ return "";
+ }
+
+ str += stringToHexPath(name) + "/comment.txt";
+ logger->log("load from: %s", str.c_str());
std::vector<std::string> lines;
ResourceManager *resman = ResourceManager::getInstance();
@@ -2383,10 +2396,22 @@ std::string Being::loadComment(const std::string &name)
}
void Being::saveComment(const std::string &name,
- const std::string &comment)
+ const std::string &comment, int type)
{
- std::string dir = Client::getUsersDirectory()
- + stringToHexPath(name);
+ std::string dir;
+ switch (type)
+ {
+ case PLAYER:
+ dir = Client::getUsersDirectory();
+ break;
+ case NPC:
+ dir = Client::getNpcsDirectory();
+ break;
+ default:
+ return;
+ }
+ dir += stringToHexPath(name);
+ logger->log("save to: %s", dir.c_str());
ResourceManager *resman = ResourceManager::getInstance();
resman->saveTextFile(dir, "comment.txt", name + "\n" + comment);
}