diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-24 03:29:58 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-10-24 03:29:58 +0000 |
commit | b868bb52c55fc902e0acab3c4a43576826817e85 (patch) | |
tree | ee67ec4b764846b9f43b064c9c4667ca70192e57 /src/modules | |
parent | b16e16ac1bae4ac5494778b4b8a7009febb58137 (diff) |
Get rid of ModePair
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11963 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_chanprotect.cpp | 35 | ||||
-rw-r--r-- | src/modules/m_delayjoin.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_delaymsg.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_invisible.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_joinflood.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_nickflood.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_ojoin.cpp | 25 | ||||
-rw-r--r-- | src/modules/m_operprefix.cpp | 21 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_servprotect.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 2 |
13 files changed, 16 insertions, 145 deletions
diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 9164d9992..369703d2c 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -44,31 +44,6 @@ class FounderProtectBase { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - User* x = ServerInstance->FindNick(parameter); - if (x) - { - Membership* memb = channel->GetUser(x); - if (!memb) - { - return std::make_pair(false, parameter); - } - else - { - if (memb->hasMode(mode)) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, parameter); - } - } - } - return std::make_pair(false, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { const UserMembList* cl = channel->GetUsers(); @@ -143,11 +118,6 @@ class ChanFounder : public ModeHandler, public FounderProtectBase return FOUNDER_VALUE; } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - return FounderProtectBase::ModeSet(source, dest, channel, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { FounderProtectBase::RemoveMode(channel, stack); @@ -215,11 +185,6 @@ class ChanProtect : public ModeHandler, public FounderProtectBase return PROTECT_VALUE; } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - return FounderProtectBase::ModeSet(source, dest, channel, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { FounderProtectBase::RemoveMode(channel, stack); diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 5c545c2f6..cde9ed047 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -154,9 +154,12 @@ void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std: /* Display the join to everyone else (the user who joined got it earlier) */ channel->WriteAllExceptSender(user, false, 0, "JOIN %s", channel->name.c_str()); - std::string n = ServerInstance->Modes->ModeString(user, channel); - if (n.length() > 0) - channel->WriteAllExceptSender(user, false, 0, "MODE %s +%s", channel->name.c_str(), n.c_str()); + std::string ms = memb->modes; + for(unsigned int i=0; i < memb->modes.length(); i++) + ms.append(" ").append(user->nick); + + if (ms.length() > 0) + channel->WriteAllExceptSender(user, false, 0, "MODE %s +%s", channel->name.c_str(), ms.c_str()); } MODULE_INIT(ModuleDelayJoin) diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index 0432bce5b..192bca15f 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -28,19 +28,6 @@ class DelayMsgMode : public ModeHandler levelrequired = OP_VALUE; } - ModePair ModeSet(User*, User*, Channel* channel, const std::string ¶meter) - { - std::string climit = channel->GetModeParameter('d'); - if (!climit.empty()) - { - return std::make_pair(true, climit); - } - else - { - return std::make_pair(false, parameter); - } - } - bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel*) { return (atoi(their_param.c_str()) < atoi(our_param.c_str())); diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index 0c7cc4dc7..cc2080f7f 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -49,7 +49,11 @@ class InvisibleMode : public ModeHandler snprintf(tb,MAXBUF,":%s %s %s", dest->GetFullHost().c_str(), adding ? "PART" : "JOIN", (*f)->name.c_str()); std::string out = tb; - std::string n = ServerInstance->Modes->ModeString(dest, (*f)); + Membership* memb = (**f).GetUser(dest); + std::string ms = memb->modes; + for(unsigned int i=0; i < memb->modes.length(); i++) + ms.append(" ").append(dest->nick); + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { @@ -57,8 +61,8 @@ class InvisibleMode : public ModeHandler if (IS_LOCAL(i->first) && !IS_OPER(i->first)) { i->first->Write(out); - if (!n.empty() && !adding) - i->first->WriteServ("MODE %s +%s", (*f)->name.c_str(), n.c_str()); + if (!ms.empty() && !adding) + i->first->WriteServ("MODE %s +%s", (**f).name.c_str(), ms.c_str()); } } } diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index e0555b37f..77d02a288 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -88,15 +88,6 @@ class JoinFlood : public ModeHandler JoinFlood(Module* Creator) : ModeHandler(Creator, "joinflood", 'j', PARAM_SETONLY, MODETYPE_CHANNEL), ext("joinflood", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - joinfloodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, ConvToStr(x->joins)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (adding) diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 9d5fe3b62..aee4bf869 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -34,14 +34,6 @@ class KickRejoin : public ModeHandler KickRejoin(Module* Creator) : ModeHandler(Creator, "kicknorejoin", 'J', PARAM_SETONLY, MODETYPE_CHANNEL), ext("norejoinusers", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - if (channel->IsModeSet('J')) - return std::make_pair(true, channel->GetModeParameter('J')); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (!adding) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index c39bc9807..5fceee19c 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -78,15 +78,6 @@ class MsgFlood : public ModeHandler MsgFlood(Module* Creator) : ModeHandler(Creator, "flood", 'f', PARAM_SETONLY, MODETYPE_CHANNEL), ext("messageflood", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - floodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, (x->ban ? "*" : "")+ConvToStr(x->lines)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { floodsettings *f = ext.get(channel); diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index a267cd404..f34cc81e4 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -92,15 +92,6 @@ class NickFlood : public ModeHandler NickFlood(Module* Creator) : ModeHandler(Creator, "nickflood", 'F', PARAM_SETONLY, MODETYPE_CHANNEL), ext("nickflood", Creator) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - nickfloodsettings* x = ext.get(channel); - if (x) - return std::make_pair(true, ConvToStr(x->nicks)+":"+ConvToStr(x->secs)); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { nickfloodsettings *f = ext.get(channel); diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index d5f7b9443..775dea204 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -103,31 +103,6 @@ class NetworkPrefix : public ModeHandler m_paramtype = TR_NICK; } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - User* x = ServerInstance->FindNick(parameter); - if (x) - { - Membership* m = channel->GetUser(x); - if (!m) - { - return std::make_pair(false, parameter); - } - else - { - if (m->hasMode('Y')) - { - return std::make_pair(true, x->nick); - } - else - { - return std::make_pair(false, parameter); - } - } - } - return std::make_pair(false, parameter); - } - void RemoveMode(Channel* channel, irc::modestacker* stack) { const UserMembList* cl = channel->GetUsers(); diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index da1e4d242..e40f6b050 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -49,27 +49,6 @@ class OperPrefixMode : public ModeHandler } } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - User* x = ServerInstance->FindNick(parameter); - Membership* m = channel->GetUser(x); - if (x) - { - if (!m) - { - return std::make_pair(false, parameter); - } - else - { - if (m->hasMode('y')) - return std::make_pair(true, x->nick); - else - return std::make_pair(false, parameter); - } - } - return std::make_pair(false, parameter); - } - bool NeedsOper() { return true; } }; diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 9a138b7fc..50d2e929f 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -22,14 +22,6 @@ class Redirect : public ModeHandler public: Redirect(Module* Creator) : ModeHandler(Creator, "redirect", 'L', PARAM_SETONLY, MODETYPE_CHANNEL) { } - ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string ¶meter) - { - if (channel->IsModeSet('L')) - return std::make_pair(true, channel->GetModeParameter('L')); - else - return std::make_pair(false, parameter); - } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { if (adding) diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 7fd867e9b..dcb0cd7d5 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -79,11 +79,12 @@ class ModuleServProtectMode : public Module User *u = ServerInstance->FindNick(param); if (u) { + Membership* memb = chan->GetUser(u); /* The target user has +k set on themselves, and you are trying to remove a privilege mode the user has set on themselves. * This includes any prefix permission mode, even those registered in other modules, e.g. +qaohv. Using ::ModeString() * here means that the number of modes is restricted to only modes the user has, limiting it to as short a loop as possible. */ - if (u->IsModeSet('k') && ServerInstance->Modes->ModeString(u, chan, false).find(mode) != std::string::npos) + if (u->IsModeSet('k') && memb && memb->modes.find(mode) != std::string::npos) { /* BZZZT, Denied! */ user->WriteNumeric(482, "%s %s :You are not permitted to remove privileges from %s services", user->nick.c_str(), chan->name.c_str(), ServerInstance->Config->Network.c_str()); diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 82b6c2b68..981c903a1 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -103,7 +103,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { size_t ptrlen = 0; - std::string modestr = ServerInstance->Modes->ModeString(i->first, c, false); + std::string modestr = i->second->modes; if ((curlen + modestr.length() + i->first->uuid.length() + 4) > 480) { |