summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-08 01:01:44 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-08 01:01:44 +0300
commitf0f4b00290c3ae4b2b80bdef22d4ac56a863d35a (patch)
tree6da506084328c9338f938a287364f68cbb92d86f
parentb3f70d8d46199524edc590269a73c262899763c7 (diff)
downloadmanaverse-f0f4b00290c3ae4b2b80bdef22d4ac56a863d35a.tar.gz
manaverse-f0f4b00290c3ae4b2b80bdef22d4ac56a863d35a.tar.bz2
manaverse-f0f4b00290c3ae4b2b80bdef22d4ac56a863d35a.tar.xz
manaverse-f0f4b00290c3ae4b2b80bdef22d4ac56a863d35a.zip
Fix register in some auto complete strings.
-rw-r--r--src/gui/chatwindow.cpp3
-rw-r--r--src/utils/stringutils.cpp18
-rw-r--r--src/utils/stringutils.h3
3 files changed, 22 insertions, 2 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 0f42fb1b6..639125739 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -1195,8 +1195,7 @@ std::string ChatWindow::autoComplete(std::vector<std::string> &names,
{
if (newName != "")
{
- toLower(newName);
- newName = findSameSubstring(name, newName);
+ newName = findSameSubstringI(*i, newName);
}
else
{
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index f3aed5276..62564e0e0 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -174,6 +174,24 @@ const std::string findSameSubstring(const std::string &str1,
return str1.substr(0, minLength);
}
+const std::string findSameSubstringI(const std::string &s1,
+ const std::string &s2)
+{
+ std::string str1 = s1;
+ std::string str2 = s2;
+ toLower(str1);
+ toLower(str2);
+
+ int minLength = str1.length() > str2.length()
+ ? static_cast<int>(str2.length()) : static_cast<int>(str1.length());
+ for (int f = 0; f < minLength; f ++)
+ {
+ if (str1.at(f) != str2.at(f))
+ return s1.substr(0, f);
+ }
+ return s1.substr(0, minLength);
+}
+
unsigned long findI(std::string str, std::string subStr)
{
str = toLower(str);
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 25fe11e2d..273fa0c8c 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -116,6 +116,9 @@ std::string removeColors(std::string msg);
const std::string findSameSubstring(const std::string &str1,
const std::string &str2);
+const std::string findSameSubstringI(const std::string &str1,
+ const std::string &str2);
+
/**
* Compares the two strings case-insensitively.
*