diff options
author | Andrei Karas <akaras@inbox.ru> | 2010-01-11 18:52:23 +0200 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-01-12 16:22:52 +0000 |
commit | 087babc2525ddb89e5b31f240a08739d9a3029a9 (patch) | |
tree | bc7f22a62869b323328b6d03a3efa7b082f331d3 /src/gui/widgets/chattab.cpp | |
parent | b09ede7286093519af8f2b044ad7be17600d2cda (diff) | |
download | mana-087babc2525ddb89e5b31f240a08739d9a3029a9.tar.gz mana-087babc2525ddb89e5b31f240a08739d9a3029a9.tar.bz2 mana-087babc2525ddb89e5b31f240a08739d9a3029a9.tar.xz mana-087babc2525ddb89e5b31f240a08739d9a3029a9.zip |
Improve chat speed.
For improve chat speed this patch add some hacks to
BrowserBox class, split big words in ChatTab.
Also fix DoS in chat.
Diffstat (limited to 'src/gui/widgets/chattab.cpp')
-rw-r--r-- | src/gui/widgets/chattab.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 6a915e5b..1701cbd3 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -42,6 +42,8 @@ #include <guichan/widgets/tabbedarea.hpp> +#define MAX_WORD_SIZE 50 + ChatTab::ChatTab(const std::string &name) : Tab() { setCaption(name); @@ -181,12 +183,12 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) // at comparison. if (mScrollArea->getVerticalScrollAmount() >= mScrollArea->getVerticalMaxScroll()) { - mTextOutput->addRow(line); + addRow(line); mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); } else { - mTextOutput->addRow(line); + addRow(line); } mScrollArea->logic(); @@ -275,3 +277,22 @@ int ChatTab::getType() const { return INPUT; } + +void ChatTab::addRow(std::string &line) +{ + std::string::size_type idx = 0; + + for (unsigned int f = 0; f < line.length(); f++) + { + if (line.at(f) == ' ') + { + idx = f; + } + else if (f - idx > MAX_WORD_SIZE) + { + line.insert(f, " "); + idx = f; + } + } + mTextOutput->addRow(line); +} |