From 4a4443c79bad2e5397140a8aea55d6cc6cadd1ab Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 23 Oct 2006 12:10:58 +0000 Subject: banexception, chanfilter, inviteexception: use modestacker to stack modes when the module is unloaded. This results in e.g. one line of -gggggg rather than 6 lines of -g. NEEDS TESTING. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5532 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/u_listmode.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/u_listmode.h b/include/u_listmode.h index 79f2af924..0e2f05103 100644 --- a/include/u_listmode.h +++ b/include/u_listmode.h @@ -67,7 +67,7 @@ class ListModeBase : public ModeHandler : ModeHandler(Instance, modechar, 1, 1, true, MODETYPE_CHANNEL, false), listnumeric(lnum), endoflistnumeric(eolnum), endofliststring(eolstr), tidy(autotidy), configtag(ctag) { this->DoRehash(); - infokey = "exceptionbase_mode_" + std::string(1, mode) + "_list"; + infokey = "listbase_mode_" + std::string(1, mode) + "_list"; } std::pair ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) @@ -109,22 +109,24 @@ class ListModeBase : public ModeHandler if (el) { ServerInstance->Log(DEBUG,"Channel is extended with a list"); - char moderemove[MAXBUF]; + irc::modestacker modestack(true); + std::deque stackresult; + const char* mode_junk[MAXMODES+1]; userrec* n = new userrec(ServerInstance); n->SetFd(FD_MAGIC_NUMBER); - modelist copy; - /* Make a copy of it, because we cant change the list whilst iterating over it */ for(modelist::iterator it = el->begin(); it != el->end(); it++) { - copy.push_back(*it); + modestack.Push(this->GetModeChar(), it->mask); } - for(modelist::iterator it = copy.begin(); it != copy.end(); it++) + while (modestack.GetStackedLine(stackresult)) { - ServerInstance->Log(DEBUG,"Remove item %s",it->mask.c_str()); - sprintf(moderemove,"-%c",this->GetModeChar()); - const char* parameters[] = { channel->name, moderemove, it->mask.c_str() }; - ServerInstance->SendMode(parameters, 3, n); + for (size_t j = 0; j < stackresult.size(); j++) + { + mode_junk[j+1] = stackresult[j].c_str(); + } + ServerInstance->SendMode(mode_junk, stackresult.size() + 1, n); } + delete n; } } -- cgit v1.2.3