summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-02 09:24:49 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-02 09:24:49 +0000
commit4ae42b33e653d58539a2d7b5821cd2d1d692132b (patch)
treea44e994ee6da4de5140810dd88263ba0fdabea21 /src
parentbd0413a193f185d4d7a8b26fb19b6b997489e134 (diff)
Add more features to modestacker so that we can stack +, -, and parameterless modes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5391 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/hashcomp.cpp18
-rw-r--r--src/inspircd.cpp42
2 files changed, 59 insertions, 1 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 8a4febb60..4dd9050b4 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -321,6 +321,21 @@ void irc::modestacker::Push(char modeletter, const std::string &parameter)
sequence.push_back(parameter);
}
+void irc::modestacker::Push(char modeletter)
+{
+ this->Push(modeletter,"");
+}
+
+void irc::modestacker::PushPlus()
+{
+ this->Push('+',"");
+}
+
+void irc::modestacker::PushMinus()
+{
+ this->Push('-',"");
+}
+
int irc::modestacker::GetStackedLine(std::deque<std::string> &result)
{
result.clear();
@@ -329,7 +344,8 @@ int irc::modestacker::GetStackedLine(std::deque<std::string> &result)
while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES+1))
{
result[0] += *(sequence[0].begin());
- result.push_back(sequence[1]);
+ if (!sequence[1].empty())
+ result.push_back(sequence[1]);
sequence[0].erase(sequence[0].begin());
sequence.erase(sequence.begin() + 1);
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 2f35c9528..da3c603fa 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -726,6 +726,48 @@ int InspIRCd::Run()
int main(int argc, char** argv)
{
+ /*
+ // test suite for modestacker
+ irc::modestacker x(true);
+ x.Push('o',"Brain");
+ x.Push('h',"Brain");
+ x.Push('v',"Brain");
+ x.Push('q',"Brain");
+ x.Push('a',"Brain");
+ x.Push('o',"Brain");
+ x.Push('h',"Brain");
+ x.Push('v',"Brain");
+ x.Push('q',"Brain");
+ x.Push('a',"Brain");
+ x.Push('o',"Brain");
+ x.Push('h',"Brain");
+ x.Push('v',"Brain");
+ x.Push('q',"Brain");
+ x.Push('a',"Brain");
+ x.Push('o',"Brain");
+ x.Push('h',"Brain");
+ x.Push('v',"Brain");
+ x.Push('q',"Brain");
+ x.Push('a',"Brain");
+ x.Push('o',"Brain");
+ x.Push('h',"Brain");
+ x.Push('v',"Brain");
+ x.Push('q',"Brain");
+ x.Push('a',"Brain");
+
+ std::deque<std::string> modes;
+ for (int i = 0; i < 2; i++)
+ {
+ x.GetStackedLine(modes);
+ printf("=== Stacked line ===\n");
+ printf("Mode sequence length=%d\n",modes.size());
+ for (size_t n = 0; n < modes.size(); n++)
+ {
+ printf("\tmodes[%d]='%s'\n",n,modes[n].c_str());
+ }
+ }
+ return 0;*/
+
SI = new InspIRCd(argc, argv);
SI->Run();
delete SI;