diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-02-25 00:11:46 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-02-25 00:11:46 +0000 |
commit | ad8705d3f051e98b24ba404fcdd888acd30e13db (patch) | |
tree | aa603a7981c9e6f78ec4443dd8cbbb3fc1bf9823 /src/hashcomp.cpp | |
parent | 37976713821bf13dfe67c7b5d0d43c59affd12c7 (diff) |
Add max line length value to modestacker, so that it can clamp the max length of a composed line to a given size. Defaults to 350 which should be safe with fmode and mode with a server name
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6609 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r-- | src/hashcomp.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 060d78fe2..f927fbc99 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -335,19 +335,37 @@ void irc::modestacker::PushMinus() this->Push('-',""); } -int irc::modestacker::GetStackedLine(std::deque<std::string> &result) +int irc::modestacker::GetStackedLine(std::deque<std::string> &result, int max_line_size) { + if (sequence.empty()) + { + result.clear(); + return 0; + } + int n = 0; + int size = 1; /* Account for initial +/- char */ + int nextsize = 0; result.clear(); result.push_back(adding ? "+" : "-"); - while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES+1)) + if (sequence.size() > 1) + nextsize = sequence[1].length(); + + while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES+1) && ((size+nextsize) < max_line_size)) { result[0] += *(sequence[0].begin()); if (!sequence[1].empty()) + { result.push_back(sequence[1]); + size += sequence[1].length() + 2; /* Account for mode character and whitespace */ + } sequence[0].erase(sequence[0].begin()); sequence.erase(sequence.begin() + 1); + + if (sequence.size() > 1) + nextsize = sequence[1].length(); + n++; } |