summaryrefslogtreecommitdiff
path: root/src/beingmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r--src/beingmanager.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 724ac899..74461d44 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -26,6 +26,7 @@
#include "npc.h"
#include "player.h"
+#include "utils/stringutils.h"
#include "utils/dtor.h"
#include <cassert>
@@ -298,3 +299,37 @@ bool BeingManager::hasBeing(Being *being) const
return false;
}
+
+std::string BeingManager::getAutoCompletePlayerName(std::string partName)
+{
+ Beings::iterator i = mBeings.begin();
+ std::transform(partName.begin(), partName.end(), partName.begin(), tolower);
+ std::string newName("");
+
+ while (i != mBeings.end())
+ {
+ Being *being = (*i);
+ if (being->getType() != Being::MONSTER && 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();
+ }
+ }
+ }
+ ++i;
+ }
+
+ return newName;
+}