diff options
author | Andrei Karas <akaras@inbox.ru> | 2010-01-08 16:03:29 +0200 |
---|---|---|
committer | Blue <bluesansdouze@gmail.com> | 2010-01-08 23:05:32 +0100 |
commit | c1ddf4c0840bb15016dc69af4a4751d09908393f (patch) | |
tree | 26b8f6a28a469a64208eb9f475fb5e26de13b29b /src/beingmanager.cpp | |
parent | 9b6e5a3189311d5704993d41a1fa195e006a57af (diff) | |
download | mana-c1ddf4c0840bb15016dc69af4a4751d09908393f.tar.gz mana-c1ddf4c0840bb15016dc69af4a4751d09908393f.tar.bz2 mana-c1ddf4c0840bb15016dc69af4a4751d09908393f.tar.xz mana-c1ddf4c0840bb15016dc69af4a4751d09908393f.zip |
Small refactoring in chat auto completing
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r-- | src/beingmanager.cpp | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 74461d44..8bd951fa 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -300,36 +300,21 @@ bool BeingManager::hasBeing(Being *being) const return false; } -std::string BeingManager::getAutoCompletePlayerName(std::string partName) +void BeingManager::getPlayerNames(std::vector<std::string> &names, + bool npcNames) { Beings::iterator i = mBeings.begin(); - std::transform(partName.begin(), partName.end(), partName.begin(), tolower); - std::string newName(""); + names.clear(); while (i != mBeings.end()) { Being *being = (*i); - if (being->getType() != Being::MONSTER && being->getName() != "") + if ((being->getType() == Being::PLAYER + || (being->getType() == Being::NPC && npcNames)) + && being->getName() != "") { - std::string name = being->getName(); - std::transform(name.begin(), name.end(), name.begin(), tolower); - - std::string::size_type pos = name.find(partName, 0); - if (pos == 0) - { - if (newName != "") - { - std::transform(newName.begin(), newName.end(), newName.begin(), tolower); - newName = findSameSubstring(name, newName); - } - else - { - newName = being->getName(); - } - } + names.push_back(being->getName()); } ++i; } - - return newName; } |