diff options
Diffstat (limited to 'src/modules')
36 files changed, 231 insertions, 561 deletions
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index fda38a885..eb23f7dc8 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -84,7 +84,7 @@ class ModuleAuditorium : public Module if (OperOverride && issuer->HasPrivPermission("channels/auspex")) return; - if (ShowOps && (issuer != user) && (channel->GetStatus(user) < STATUS_OP)) + if (ShowOps && (issuer != user) && (channel->GetPrefixValue(user) < OP_VALUE)) { /* Showops is set, hide all non-ops from the user, except themselves */ nick.clear(); @@ -104,11 +104,11 @@ class ModuleAuditorium : public Module if (!OperOverride) return; - CUList *ulist = channel->GetUsers(); - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + const UserMembList *ulist = channel->GetUsers(); + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { if (i->first->HasPrivPermission("channels/auspex") && source != i->first) - if (!ShowOps || (ShowOps && channel->GetStatus(i->first) < STATUS_OP)) + if (!ShowOps || (ShowOps && channel->GetPrefixValue(i->first) < OP_VALUE)) i->first->WriteFrom(source, "%s",text.c_str()); } } @@ -121,7 +121,7 @@ class ModuleAuditorium : public Module /* Because we silenced the event, make sure it reaches the user whos joining (but only them of course) */ user->WriteFrom(user, "JOIN %s", channel->name.c_str()); if (ShowOps) - channel->WriteAllExceptSender(user, false, channel->GetStatus(user) >= STATUS_OP ? 0 : '@', "JOIN %s", channel->name.c_str()); + channel->WriteAllExceptSender(user, false, channel->GetPrefixValue(user) >= OP_VALUE ? 0 : '@', "JOIN %s", channel->name.c_str()); WriteOverride(user, channel, "JOIN "+channel->name); } } @@ -137,7 +137,7 @@ class ModuleAuditorium : public Module partmessage.empty() ? "" : partmessage.c_str()); if (ShowOps) { - channel->WriteAllExceptSender(user, false, channel->GetStatus(user) >= STATUS_OP ? 0 : '@', "PART %s%s%s", channel->name.c_str(), partmessage.empty() ? "" : " :", + channel->WriteAllExceptSender(user, false, channel->GetPrefixValue(user) >= OP_VALUE ? 0 : '@', "PART %s%s%s", channel->name.c_str(), partmessage.empty() ? "" : " :", partmessage.empty() ? "" : partmessage.c_str()); } WriteOverride(user, channel, "PART " + channel->name + (partmessage.empty() ? "" : (" :" + partmessage))); @@ -152,8 +152,8 @@ class ModuleAuditorium : public Module /* Send silenced event only to the user being kicked and the user doing the kick */ source->WriteFrom(source, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), reason.c_str()); if (ShowOps) - chan->WriteAllExceptSender(source, false, chan->GetStatus(user) >= STATUS_OP ? 0 : '@', "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), reason.c_str()); - if ((!ShowOps) || (chan->GetStatus(user) < STATUS_OP)) /* make sure the target gets the event */ + chan->WriteAllExceptSender(source, false, chan->GetPrefixValue(user) >= OP_VALUE ? 0 : '@', "KICK %s %s %s", chan->name.c_str(), user->nick.c_str(), reason.c_str()); + if ((!ShowOps) || (chan->GetPrefixValue(user) < OP_VALUE)) /* make sure the target gets the event */ user->WriteFrom(source, "KICK %s %s :%s", chan->name.c_str(), user->nick.c_str(), reason.c_str()); WriteOverride(source, chan, "KICK " + chan->name + " " + user->nick + " :" + reason); } @@ -162,7 +162,7 @@ class ModuleAuditorium : public Module ModResult OnHostCycle(User* user) { for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - if (f->first->IsModeSet('u')) + if ((*f)->IsModeSet('u')) return MOD_RES_DENY; return MOD_RES_PASSTHRU; @@ -176,8 +176,8 @@ class ModuleAuditorium : public Module { for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) { - if (f->first->IsModeSet('u')) - to_leave.push_back(f->first->name); + if ((*f)->IsModeSet('u')) + to_leave.push_back((*f)->name); } /* We cant do this neatly in one loop, as we are modifying the map we are iterating */ for (std::vector<std::string>::iterator n = to_leave.begin(); n != to_leave.end(); n++) diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index da08d06fb..b7eb6f1ae 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -131,7 +131,7 @@ class BanRedirect : public ModeWatcher source->WriteNumeric(690, "%s :Target channel %s must exist to be set as a redirect.",source->nick.c_str(),mask[CHAN].c_str()); return false; } - else if (c->GetStatus(source) < STATUS_OP) + else if (c->GetPrefixValue(source) < OP_VALUE) { source->WriteNumeric(690, "%s :You must be opped on %s to set it as a redirect.",source->nick.c_str(), mask[CHAN].c_str()); return false; diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index ca1bc5a2b..135e072b1 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -60,7 +60,7 @@ public: Channel* c = (Channel*)dest; - if (CHANOPS_EXEMPT(ServerInstance, 'B') && c->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'B') && c->GetPrefixValue(user) == OP_VALUE) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index 5bd86bccf..1aa2a1bd9 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -48,7 +48,7 @@ class ModuleBlockColour : public Module { Channel* c = (Channel*)dest; - if (CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'c') && c->GetPrefixValue(user) == OP_VALUE) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_cap.h b/src/modules/m_cap.h index 72c7a14a5..a37580126 100644 --- a/src/modules/m_cap.h +++ b/src/modules/m_cap.h @@ -32,7 +32,7 @@ class GenericCap public: LocalIntExt ext; const std::string cap; - GenericCap(Module* parent, const std::string &Cap) : ext("cap_" + cap, parent), cap(Cap) + GenericCap(Module* parent, const std::string &Cap) : ext("cap_" + Cap, parent), cap(Cap) { Extensible::Register(&ext); } diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 6050d49ab..2ffe2ab45 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -77,7 +77,7 @@ class ModuleCensor : public Module { active = ((Channel*)dest)->IsModeSet('G'); Channel* c = (Channel*)dest; - if (CHANOPS_EXEMPT(ServerInstance, 'G') && c->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'G') && c->GetPrefixValue(user) == OP_VALUE) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 4636d2372..1079505d5 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -85,7 +85,7 @@ class ModuleChanFilter : public Module virtual ModResult ProcessMessages(User* user,Channel* chan,std::string &text) { - if (!IS_LOCAL(user) || (CHANOPS_EXEMPT(ServerInstance, 'g') && chan->GetStatus(user) == STATUS_OP)) + if (!IS_LOCAL(user) || (CHANOPS_EXEMPT(ServerInstance, 'g') && chan->GetPrefixValue(user) == OP_VALUE)) return MOD_RES_PASSTHRU; modelist* list = cf.extItem.get(chan); diff --git a/src/modules/m_channelban.cpp b/src/modules/m_channelban.cpp index fd5d5d401..727ab15a3 100644 --- a/src/modules/m_channelban.cpp +++ b/src/modules/m_channelban.cpp @@ -39,7 +39,7 @@ class ModuleBadChannelExtban : public Module ModResult rv; for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { - rv = rv + c->GetExtBanStatus(i->first->name, 'j'); + rv = rv + c->GetExtBanStatus((*i)->name, 'j'); } return rv; diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index bc52a53a1..15481fb7f 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -24,17 +24,17 @@ class FounderProtectBase { private: - InspIRCd* MyInstance; - std::string extend; - std::string type; - int list; - int end; + InspIRCd* const MyInstance; + const std::string type; + const char mode; + const int list; + const int end; protected: bool& remove_own_privs; bool& remove_other_privs; public: - FounderProtectBase(InspIRCd* Instance, const std::string &ext, const std::string &mtype, int l, int e, bool &remove_own, bool &remove_others) : - MyInstance(Instance), extend(ext), type(mtype), list(l), end(e), remove_own_privs(remove_own), remove_other_privs(remove_others) + FounderProtectBase(InspIRCd* Instance, char Mode, const std::string &mtype, int l, int e, bool &remove_own, bool &remove_others) : + MyInstance(Instance), type(mtype), mode(Mode), list(l), end(e), remove_own_privs(remove_own), remove_other_privs(remove_others) { } @@ -43,14 +43,14 @@ class FounderProtectBase User* x = MyInstance->FindNick(parameter); if (x) { - if (!channel->HasUser(x)) + Membership* memb = channel->GetUser(x); + if (!memb) { return std::make_pair(false, parameter); } else { - std::string item = extend+std::string(channel->name); - if (x->GetExt(item)) + if (memb->hasMode(mode)) { return std::make_pair(true, x->nick); } @@ -63,23 +63,22 @@ class FounderProtectBase return std::make_pair(false, parameter); } - void RemoveMode(Channel* channel, char mc, irc::modestacker* stack) + void RemoveMode(Channel* channel, irc::modestacker* stack) { - CUList* cl = channel->GetUsers(); - std::string item = extend + std::string(channel->name); + const UserMembList* cl = channel->GetUsers(); std::vector<std::string> mode_junk; mode_junk.push_back(channel->name); irc::modestacker modestack(MyInstance, false); std::deque<std::string> stackresult; - for (CUList::iterator i = cl->begin(); i != cl->end(); i++) + for (UserMembCIter i = cl->begin(); i != cl->end(); i++) { - if (i->first->GetExt(item)) + if (i->second->hasMode(mode)) { if (stack) - stack->Push(mc, i->first->nick); + stack->Push(mode, i->first->nick); else - modestack.Push(mc, i->first->nick); + modestack.Push(mode, i->first->nick); } } @@ -96,11 +95,10 @@ class FounderProtectBase void DisplayList(User* user, Channel* channel) { - CUList* cl = channel->GetUsers(); - std::string item = extend+std::string(channel->name); - for (CUList::reverse_iterator i = cl->rbegin(); i != cl->rend(); ++i) + const UserMembList* cl = channel->GetUsers(); + for (UserMembCIter i = cl->begin(); i != cl->end(); ++i) { - if (i->first->GetExt(item)) + if (i->second->hasMode(mode)) { user->WriteServ("%d %s %s %s", list, user->nick.c_str(), channel->name.c_str(), i->first->nick.c_str()); } @@ -108,46 +106,10 @@ class FounderProtectBase user->WriteServ("%d %s %s :End of channel %s list", end, user->nick.c_str(), channel->name.c_str(), type.c_str()); } - User* FindAndVerify(std::string ¶meter, Channel* channel) - { - User* theuser = MyInstance->FindNick(parameter); - if ((!theuser) || (!channel->HasUser(theuser))) - { - parameter.clear(); - return NULL; - } - return theuser; - } - - bool CanRemoveOthers(User* u1, User* u2, Channel* c) + bool CanRemoveOthers(User* u1, Channel* c) { - std::string item = extend+std::string(c->name); - return (remove_other_privs && u1->GetExt(item) && u2->GetExt(item)); - } - - ModeAction HandleChange(User* source, User* theuser, bool adding, Channel* channel, std::string ¶meter) - { - std::string item = extend+std::string(channel->name); - - if (adding) - { - if (!theuser->GetExt(item)) - { - theuser->Extend(item); - parameter = theuser->nick; - return MODEACTION_ALLOW; - } - } - else - { - if (theuser->GetExt(item)) - { - theuser->Shrink(item); - parameter = theuser->nick; - return MODEACTION_ALLOW; - } - } - return MODEACTION_DENY; + Membership* m1 = c->GetUser(u1); + return (remove_other_privs && m1 && m1->hasMode(mode)); } }; @@ -158,7 +120,7 @@ class ChanFounder : public ModeHandler, public FounderProtectBase public: ChanFounder(InspIRCd* Instance, Module* Creator, char my_prefix, bool &depriv_self, bool &depriv_others) : ModeHandler(Instance, Creator, 'q', 1, 1, true, MODETYPE_CHANNEL, false, my_prefix, 0, TR_NICK), - FounderProtectBase(Instance, "cm_founder_", "founder", 386, 387, depriv_self, depriv_others) { } + FounderProtectBase(Instance, 'q', "founder", 386, 387, depriv_self, depriv_others) { } unsigned int GetPrefixRank() { @@ -172,7 +134,7 @@ class ChanFounder : public ModeHandler, public FounderProtectBase void RemoveMode(Channel* channel, irc::modestacker* stack) { - FounderProtectBase::RemoveMode(channel, this->GetModeChar(), stack); + FounderProtectBase::RemoveMode(channel, stack); } void RemoveMode(User* user, irc::modestacker* stack) @@ -181,16 +143,16 @@ class ChanFounder : public ModeHandler, public FounderProtectBase ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { - User* theuser = FounderProtectBase::FindAndVerify(parameter, channel); + User* theuser = ServerInstance->FindNick(parameter); if (!theuser) { return MODEACTION_DENY; } - if ((!adding) && FounderProtectBase::CanRemoveOthers(source, theuser, channel)) + if ((!adding) && FounderProtectBase::CanRemoveOthers(source, channel)) { - return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); + return MODEACTION_ALLOW; } char isoverride=0; @@ -202,15 +164,14 @@ class ChanFounder : public ModeHandler, public FounderProtectBase isoverride = tmp[0]; } // source is a server, or ulined, we'll let them +-q the user. - if (source == ServerInstance->FakeClient || + if (!IS_LOCAL(source) || ((source == theuser) && (!adding) && (FounderProtectBase::remove_own_privs)) || (ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server) || - (!IS_LOCAL(source)) || isoverride) { - return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); + return MODEACTION_ALLOW; } else { @@ -234,7 +195,7 @@ class ChanProtect : public ModeHandler, public FounderProtectBase public: ChanProtect(InspIRCd* Instance, Module* Creator, char my_prefix, bool &depriv_self, bool &depriv_others) : ModeHandler(Instance, Creator, 'a', 1, 1, true, MODETYPE_CHANNEL, false, my_prefix, 0, TR_NICK), - FounderProtectBase(Instance,"cm_protect_","protected user", 388, 389, depriv_self, depriv_others) { } + FounderProtectBase(Instance,'a',"protected user", 388, 389, depriv_self, depriv_others) { } unsigned int GetPrefixRank() { @@ -248,7 +209,7 @@ class ChanProtect : public ModeHandler, public FounderProtectBase void RemoveMode(Channel* channel, irc::modestacker* stack) { - FounderProtectBase::RemoveMode(channel, this->GetModeChar(), stack); + FounderProtectBase::RemoveMode(channel, stack); } void RemoveMode(User* user, irc::modestacker* stack) @@ -257,16 +218,14 @@ class ChanProtect : public ModeHandler, public FounderProtectBase ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { - User* theuser = FounderProtectBase::FindAndVerify(parameter, channel); + User* theuser = ServerInstance->FindNick(parameter); if (!theuser) return MODEACTION_DENY; - std::string founder = "cm_founder_"+std::string(channel->name); - - if ((!adding) && FounderProtectBase::CanRemoveOthers(source, theuser, channel)) + if ((!adding) && FounderProtectBase::CanRemoveOthers(source, channel)) { - return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); + return MODEACTION_ALLOW; } char isoverride=0; @@ -278,17 +237,16 @@ class ChanProtect : public ModeHandler, public FounderProtectBase isoverride = tmp[0]; } // source has +q, is a server, or ulined, we'll let them +-a the user. - if (source == ServerInstance->FakeClient || + if (!IS_LOCAL(source) || ((source == theuser) && (!adding) && (FounderProtectBase::remove_own_privs)) || (ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server) || - (source->GetExt(founder)) || - (!IS_LOCAL(source)) || + (channel->GetPrefixValue(source) > PROTECT_VALUE) || isoverride ) { - return FounderProtectBase::HandleChange(source, theuser, adding, channel, parameter); + return MODEACTION_ALLOW; } else { @@ -342,20 +300,6 @@ class ModuleChanProtect : public Module ServerInstance->Modules->Attach(eventlist, this, 4); } - virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent) - { - // FIX: when someone gets kicked from a channel we must remove their Extensibles! - user->Shrink("cm_founder_"+std::string(chan->name)); - user->Shrink("cm_protect_"+std::string(chan->name)); - } - - virtual void OnUserPart(User* user, Channel* channel, std::string &partreason, bool &silent) - { - // FIX: when someone parts a channel we must remove their Extensibles! - user->Shrink("cm_founder_"+std::string(channel->name)); - user->Shrink("cm_protect_"+std::string(channel->name)); - } - void LoadSettings() { ConfigReader Conf(ServerInstance); @@ -403,34 +347,33 @@ class ModuleChanProtect : public Module // always allow the action if: // (A) The source is ulined - // firstly, if a ulined nick, or a server, is setting the mode, then allow them to set the mode - // without any access checks, we're not worthy :p if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server)) - return MOD_RES_ALLOW; + return MOD_RES_PASSTHRU; if (!channel) return MOD_RES_PASSTHRU; - std::string founder("cm_founder_"+channel->name); - std::string protect("cm_protect_"+channel->name); - // Can do anything to yourself if deprotectself is enabled. if (DeprivSelf && source == dest) return MOD_RES_PASSTHRU; - bool candepriv_founder = (DeprivOthers && source->GetExt(founder)); - bool candepriv_protected = (source->GetExt(founder) || (DeprivOthers && source->GetExt(protect))); // Can the source remove +a? + Membership* smemb = channel->GetUser(source); + Membership* dmemb = channel->GetUser(source); + bool candepriv_founder = (DeprivOthers && smemb && smemb->hasMode('q')); + bool candepriv_protect = smemb && (smemb->hasMode('q') || (DeprivOthers && smemb->hasMode('a'))); + bool desthas_founder = dmemb->hasMode('q'); + bool desthas_protect = dmemb->hasMode('a'); switch (access_type) { // a user has been deopped. Do we let them? hmmm... case AC_DEOP: - if (dest->GetExt(founder) && !candepriv_founder) + if (desthas_founder && !candepriv_founder) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't deop "+dest->nick+" as they're a channel founder"); return MOD_RES_DENY; } - if ((dest->GetExt(protect)) && !candepriv_protected) + if (desthas_protect && !candepriv_protect) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't deop "+dest->nick+" as they're protected (+a)"); return MOD_RES_DENY; @@ -439,12 +382,12 @@ class ModuleChanProtect : public Module // a user is being kicked. do we chop off the end of the army boot? case AC_KICK: - if (dest->GetExt(founder) && !candepriv_founder) + if (desthas_founder && !candepriv_founder) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't kick "+dest->nick+" as they're a channel founder"); return MOD_RES_DENY; } - if ((dest->GetExt(protect)) && !candepriv_protected) + if (desthas_protect && !candepriv_protect) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't kick "+dest->nick+" as they're protected (+a)"); return MOD_RES_DENY; @@ -453,12 +396,12 @@ class ModuleChanProtect : public Module // a user is being dehalfopped. Yes, we do disallow -h of a +ha user case AC_DEHALFOP: - if (dest->GetExt(founder) && !candepriv_founder) + if (desthas_founder && !candepriv_founder) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't de-halfop "+dest->nick+" as they're a channel founder"); return MOD_RES_DENY; } - if ((dest->GetExt(protect)) && !candepriv_protected) + if (desthas_protect && !candepriv_protect) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't de-halfop "+dest->nick+" as they're protected (+a)"); return MOD_RES_DENY; @@ -467,12 +410,12 @@ class ModuleChanProtect : public Module // same with devoice. case AC_DEVOICE: - if (dest->GetExt(founder) && !candepriv_founder) + if (desthas_founder && !candepriv_founder) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't devoice "+dest->nick+" as they're a channel founder"); return MOD_RES_DENY; } - if ((dest->GetExt(protect)) && !candepriv_protected) + if (desthas_protect && !candepriv_protect) { source->WriteNumeric(484, source->nick+" "+channel->name+" :Can't devoice "+dest->nick+" as they're protected (+a)"); return MOD_RES_DENY; @@ -494,7 +437,7 @@ class ModuleChanProtect : public Module virtual Version GetVersion() { - return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION); + return Version("Founder and Protect modes (+qa)", VF_COMMON | VF_VENDOR); } }; diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 964a8c075..33f950b4c 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -140,10 +140,10 @@ class CommandCheck : public Command /* now the ugly bit, spool current members of a channel. :| */ - CUList *ulist= targchan->GetUsers(); + const UserMembList *ulist= targchan->GetUsers(); /* note that unlike /names, we do NOT check +i vs in the channel */ - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { char tmpbuf[MAXBUF]; /* diff --git a/src/modules/m_cycle.cpp b/src/modules/m_cycle.cpp index 1348feeb3..8caa07b62 100644 --- a/src/modules/m_cycle.cpp +++ b/src/modules/m_cycle.cpp @@ -50,7 +50,7 @@ class CommandCycle : public Command */ if (IS_LOCAL(user)) { - if (channel->GetStatus(user) < STATUS_VOICE && channel->IsBanned(user)) + if (channel->GetPrefixValue(user) < VOICE_VALUE && channel->IsBanned(user)) { /* banned, boned. drop the message. */ user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not cycle, as you are banned on channel " + channel->name); diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 90c63e30d..a61582629 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -43,6 +43,7 @@ typedef std::vector<DCCAllow> dccallowlist; dccallowlist* dl; typedef std::vector<BannedFileList> bannedfilelist; bannedfilelist bfl; +SimpleExtItem<dccallowlist>* ext; class CommandDccallow : public Command { @@ -97,7 +98,8 @@ class CommandDccallow : public Command if (action == '-') { // check if it contains any entries - if (user->GetExt("dccallow_list", dl)) + dl = ext->get(user); + if (dl) { for (dccallowlist::iterator i = dl->begin(); i != dl->end(); ++i) { @@ -110,22 +112,6 @@ class CommandDccallow : public Command } } } - else - { - delete dl; - user->Shrink("dccallow_list"); - - // remove from userlist - for (userlist::iterator j = ul.begin(); j != ul.end(); ++j) - { - User* u = (User*)(*j); - if (u == user) - { - ul.erase(j); - break; - } - } - } } else if (action == '+') { @@ -135,10 +121,11 @@ class CommandDccallow : public Command return CMD_FAILURE; } - if (!user->GetExt("dccallow_list", dl)) + dl = ext->get(user); + if (!dl) { dl = new dccallowlist; - user->Extend("dccallow_list", dl); + ext->set(user, dl); // add this user to the userlist ul.push_back(user); } @@ -233,7 +220,8 @@ class CommandDccallow : public Command // display current DCCALLOW list user->WriteNumeric(990, "%s :Users on your DCCALLOW list:", user->nick.c_str()); - if (user->GetExt("dccallow_list", dl)) + dl = ext->get(user); + if (dl) { for (dccallowlist::const_iterator c = dl->begin(); c != dl->end(); ++c) { @@ -255,6 +243,8 @@ class ModuleDCCAllow : public Module : Module(Me), cmd(Me, this) { Conf = new ConfigReader(ServerInstance); + ext = new SimpleExtItem<dccallowlist>("dccallow", this); + Extensible::Register(ext); ServerInstance->AddCommand(&cmd); ReadFileConf(); Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserQuit, I_OnUserPreNick, I_OnRehash }; @@ -271,13 +261,11 @@ class ModuleDCCAllow : public Module virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) { - dccallowlist* udl; + dccallowlist* udl = ext->get(user); // remove their DCCALLOW list if they have one - if (user->GetExt("dccallow_list", udl)) + if (udl) { - delete udl; - user->Shrink("dccallow_list"); RemoveFromUserlist(user); } @@ -286,7 +274,6 @@ class ModuleDCCAllow : public Module RemoveNick(user); } - virtual ModResult OnUserPreNick(User* user, const std::string &newnick) { RemoveNick(user); @@ -320,7 +307,8 @@ class ModuleDCCAllow : public Module if (strncmp(text.c_str(), "\1DCC ", 5) == 0) { - if (u->GetExt("dccallow_list", dl) && dl->size()) + dl = ext->get(u); + if (dl && dl->size()) { for (dccallowlist::const_iterator iter = dl->begin(); iter != dl->end(); ++iter) if (InspIRCd::Match(user->GetFullHost(), iter->hostmask)) @@ -387,7 +375,8 @@ class ModuleDCCAllow : public Module for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter) { User* u = (User*)(*iter); - if (u->GetExt("dccallow_list", dl)) + dl = ext->get(u); + if (dl) { if (dl->size()) { @@ -419,7 +408,8 @@ class ModuleDCCAllow : public Module for (userlist::iterator iter = ul.begin(); iter != ul.end(); ++iter) { User *u = (User*)(*iter); - if (u->GetExt("dccallow_list", dl)) + dl = ext->get(u); + if (dl) { if (dl->size()) { @@ -475,6 +465,7 @@ class ModuleDCCAllow : public Module virtual ~ModuleDCCAllow() { delete Conf; + delete ext; Conf = NULL; } diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index aaa3696b5..caad1feb1 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -105,7 +105,7 @@ class ModuleDeaf : public Module virtual void BuildDeafList(MessageType message_type, Channel* chan, User* sender, char status, const std::string &text, CUList &exempt_list) { - CUList *ulist = chan->GetUsers(); + const UserMembList *ulist = chan->GetUsers(); bool is_a_uline; bool is_bypasschar, is_bypasschar_avail; bool is_bypasschar_uline, is_bypasschar_uline_avail; @@ -131,7 +131,7 @@ class ModuleDeaf : public Module if (!is_bypasschar_uline_avail && is_bypasschar) return; - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { /* not +d ? */ if (!i->first->IsModeSet('d')) @@ -152,7 +152,7 @@ class ModuleDeaf : public Module continue; /* don't deliver message! */ - exempt_list[i->first] = i->first->nick; + exempt_list.insert(i->first); } } diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 9ccb89167..c894db124 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -26,21 +26,20 @@ class DelayJoinMode : public ModeHandler class ModuleDelayJoin : public Module { - private: DelayJoinMode djm; - CUList nl; public: - ModuleDelayJoin(InspIRCd* Me) : Module(Me), djm(Me, this) + LocalIntExt unjoined; + ModuleDelayJoin(InspIRCd* Me) : Module(Me), djm(Me, this), unjoined("delayjoin", this) { if (!ServerInstance->Modes->AddMode(&djm)) throw ModuleException("Could not add new modes!"); Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnUserQuit, I_OnNamesListItem, I_OnText, I_OnHostCycle }; ServerInstance->Modules->Attach(eventlist, this, 7); } - virtual ~ModuleDelayJoin(); - virtual Version GetVersion(); - virtual void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick); - virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created); + ~ModuleDelayJoin(); + Version GetVersion(); + void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick); + void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created); void CleanUser(User* user); ModResult OnHostCycle(User* user); void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent); @@ -64,8 +63,8 @@ ModeAction DelayJoinMode::OnModeChange(User* source, User* dest, Channel* channe * Make all users visible, as +D is being removed. If we don't do this, * they remain permanently invisible on this channel! */ - CUList* names = channel->GetUsers(); - for (CUListIter n = names->begin(); n != names->end(); ++n) + const UserMembList* names = channel->GetUsers(); + for (UserMembCIter n = names->begin(); n != names->end(); ++n) creator->OnText(n->first, channel, TYPE_CHANNEL, "", 0, empty); } channel->SetMode('D', adding); @@ -79,7 +78,7 @@ ModuleDelayJoin::~ModuleDelayJoin() Version ModuleDelayJoin::GetVersion() { - return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION); + return Version("$Id$", VF_COMMON | VF_VENDOR); } void ModuleDelayJoin::OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick) @@ -94,8 +93,9 @@ void ModuleDelayJoin::OnNamesListItem(User* issuer, User* user, Channel* channel if (issuer == user) return; + Membership* memb = channel->GetUser(user); /* If the user is hidden by delayed join, hide them from the NAMES list */ - if (user->GetExt("delayjoin_"+channel->name)) + if (memb && unjoined.get(memb)) nick.clear(); } @@ -107,79 +107,55 @@ void ModuleDelayJoin::OnUserJoin(User* user, Channel* channel, bool sync, bool & /* Because we silenced the event, make sure it reaches the user whos joining (but only them of course) */ user->WriteFrom(user, "JOIN %s", channel->name.c_str()); - /* This metadata tells the module the user is delayed join on this specific channel */ - user->Extend("delayjoin_"+channel->name); + Membership* memb = channel->GetUser(user); - /* This metadata tells the module the user is delayed join on at least one (or more) channels. - * It is only cleared when the user is no longer on ANY +D channels. - */ - if (!user->GetExt("delayjoin")) - user->Extend("delayjoin"); + unjoined.set(memb, 1); } } -void ModuleDelayJoin::CleanUser(User* user) -{ - /* Check if the user is hidden on any other +D channels, if so don't take away the - * metadata that says they're hidden on one or more channels - */ - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - if (user->GetExt("delayjoin_" + f->first->name)) - return; - - user->Shrink("delayjoin"); -} - void ModuleDelayJoin::OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent) { - if (!channel->IsModeSet('D')) - return; - if (user->GetExt("delayjoin_"+channel->name)) + Membership* memb = channel->GetUser(user); + if (unjoined.set(memb, 0)) { - user->Shrink("delayjoin_"+channel->name); silent = true; /* Because we silenced the event, make sure it reaches the user whos leaving (but only them of course) */ user->WriteFrom(user, "PART %s%s%s", channel->name.c_str(), partmessage.empty() ? "" : " :", partmessage.empty() ? "" : partmessage.c_str()); - CleanUser(user); } } void ModuleDelayJoin::OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent) { - if (!chan->IsModeSet('D')) - return; - /* Send silenced event only to the user being kicked and the user doing the kick */ - if (user->GetExt("delayjoin_"+chan->name)) + Membership* memb = chan->GetUser(user); + if (unjoined.set(memb, 0)) { - user->Shrink("delayjoin_"+chan->name); silent = true; user->WriteFrom(source, "KICK %s %s %s", chan->name.c_str(), user->nick.c_str(), reason.c_str()); - CleanUser(user); } } ModResult ModuleDelayJoin::OnHostCycle(User* user) { - return user->GetExt("delayjoin") ? MOD_RES_DENY : MOD_RES_PASSTHRU; + // TODO + return MOD_RES_DENY; } void ModuleDelayJoin::OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) { Command* parthandler = ServerInstance->Parser->GetHandler("PART"); - if (parthandler && user->GetExt("delayjoin")) + if (!parthandler) + return; + for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) { - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) + Channel* chan = *f; + Membership* memb = chan->GetUser(user); + if (memb && unjoined.get(memb)) { - Channel* chan = f->first; - if (user->GetExt("delayjoin_"+chan->name)) - { - std::vector<std::string> parameters; - parameters.push_back(chan->name); - /* Send a fake PART from the channel, which will be silent */ - parthandler->Handle(parameters, user); - } + std::vector<std::string> parameters; + parameters.push_back(chan->name); + /* Send a fake PART from the channel, which will be silent */ + parthandler->Handle(parameters, user); } - user->Shrink("delayjoin"); } } @@ -194,43 +170,16 @@ void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std: Channel* channel = (Channel*) dest; - if (!user->GetExt("delayjoin_"+channel->name)) + Membership* memb = channel->GetUser(user); + if (!memb || !unjoined.set(memb, 0)) return; /* Display the join to everyone else (the user who joined got it earlier) */ - this->WriteCommonFrom(user, channel, "JOIN %s", channel->name.c_str()); + channel->WriteAllExceptSender(user, false, 0, "JOIN %s", channel->name.c_str()); std::string n = this->ServerInstance->Modes->ModeString(user, channel); if (n.length() > 0) this->WriteCommonFrom(user, channel, "MODE %s +%s", channel->name.c_str(), n.c_str()); - - /* Shrink off the neccessary metadata for a specific channel */ - user->Shrink("delayjoin_"+channel->name); - CleanUser(user); -} - -// .. is there a real need to duplicate WriteCommonExcept? -void ModuleDelayJoin::WriteCommonFrom(User *user, Channel* channel, const char* text, ...) -{ - va_list argsPtr; - char textbuffer[MAXBUF]; - char tb[MAXBUF]; - - va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - snprintf(tb,MAXBUF,":%s %s",user->GetFullHost().c_str(), textbuffer); - - CUList *ulist = channel->GetUsers(); - - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) - { - /* User doesnt get a JOIN sent to themselves */ - if (user == i->first) - continue; - - i->first->Write(std::string(tb)); - } } MODULE_INIT(ModuleDelayJoin) diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index b5fdd8238..5e2bb838c 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -21,7 +21,8 @@ class DelayMsgMode : public ModeHandler private: CUList empty; public: - DelayMsgMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, Parent, 'd', 1, 0, false, MODETYPE_CHANNEL, false, 0, '@') {}; + LocalIntExt jointime; + DelayMsgMode(InspIRCd* Instance, Module* Parent) : ModeHandler(Instance, Parent, 'd', 1, 0, false, MODETYPE_CHANNEL, false, 0, '@'), jointime("delaymsg", Parent) {}; ModePair ModeSet(User*, User*, Channel* channel, const std::string ¶meter) { @@ -53,11 +54,12 @@ class ModuleDelayMsg : public Module { if (!ServerInstance->Modes->AddMode(&djm)) throw ModuleException("Could not add new modes!"); - Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnCleanup, I_OnUserPreMessage}; - ServerInstance->Modules->Attach(eventlist, this, 5); + Extensible::Register(&djm.jointime); + Implementation eventlist[] = { I_OnUserJoin, I_OnUserPreMessage}; + ServerInstance->Modules->Attach(eventlist, this, 2); } - virtual ~ModuleDelayMsg(); - virtual Version GetVersion(); + ~ModuleDelayMsg(); + Version GetVersion(); void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created); void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent); void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent); @@ -83,9 +85,9 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel /* * Clean up metadata */ - CUList* names = channel->GetUsers(); - for (CUListIter n = names->begin(); n != names->end(); ++n) - n->first->Shrink("delaymsg_" + channel->name); + const UserMembList* names = channel->GetUsers(); + for (UserMembCIter n = names->begin(); n != names->end(); ++n) + jointime.set(n->second, 0); } channel->SetModeParam('d', adding ? parameter : ""); return MODEACTION_ALLOW; @@ -104,29 +106,9 @@ Version ModuleDelayMsg::GetVersion() void ModuleDelayMsg::OnUserJoin(User* user, Channel* channel, bool sync, bool &silent, bool created) { if (channel->IsModeSet('d')) - user->Extend("delaymsg_"+channel->name, reinterpret_cast<char*>(ServerInstance->Time())); -} - -void ModuleDelayMsg::OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent) -{ - user->Shrink("delaymsg_"+channel->name); -} - -void ModuleDelayMsg::OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent) -{ - user->Shrink("delaymsg_"+chan->name); -} - -void ModuleDelayMsg::OnCleanup(int target_type, void* item) -{ - if (target_type == TYPE_USER) { - User* user = (User*)item; - for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - { - Channel* chan = f->first; - user->Shrink("delaymsg_"+chan->name); - } + Membership* memb = channel->GetUser(user); + djm.jointime.set(memb, ServerInstance->Time()); } } @@ -140,19 +122,21 @@ ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_ty return MOD_RES_PASSTHRU; Channel* channel = (Channel*) dest; + Membership* memb = channel->GetUser(user); - void* jointime_as_ptr; - - if (!user->GetExt("delaymsg_"+channel->name, jointime_as_ptr)) + if (!memb) return MOD_RES_PASSTHRU; + + time_t ts = djm.jointime.get(memb); - time_t jointime = reinterpret_cast<time_t>(jointime_as_ptr); + if (ts == 0) + return MOD_RES_PASSTHRU; std::string len = channel->GetModeParameter('d'); - if (jointime + atoi(len.c_str()) > ServerInstance->Time()) + if (ts + atoi(len.c_str()) > ServerInstance->Time()) { - if (channel->GetStatus(user) < STATUS_VOICE) + if (channel->GetPrefixValue(user) < VOICE_VALUE) { user->WriteNumeric(404, "%s %s :You must wait %s seconds after joining to send to channel (+d)", user->nick.c_str(), channel->name.c_str(), len.c_str()); @@ -162,7 +146,7 @@ ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_ty else { /* Timer has expired, we can stop checking now */ - user->Shrink("delaymsg_"+channel->name); + djm.jointime.set(memb, 0); } return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index d31807f59..3222903dc 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -116,18 +116,15 @@ class ModuleHttpStats : public Module data << "<channel>"; data << "<usercount>" << c->GetUsers()->size() << "</usercount><channelname>" << c->name << "</channelname>"; - data << "<channelops>" << c->GetOppedUsers()->size() << "</channelops>"; - data << "<channelhalfops>" << c->GetHalfoppedUsers()->size() << "</channelhalfops>"; - data << "<channelvoices>" << c->GetVoicedUsers()->size() << "</channelvoices>"; data << "<channeltopic>"; data << "<topictext>" << Sanitize(c->topic) << "</topictext>"; data << "<setby>" << Sanitize(c->setby) << "</setby>"; data << "<settime>" << c->topicset << "</settime>"; data << "</channeltopic>"; data << "<channelmodes>" << Sanitize(c->ChanModes(true)) << "</channelmodes>"; - CUList* ulist = c->GetUsers(); + const UserMembList* ulist = c->GetUsers(); - for (CUList::iterator x = ulist->begin(); x != ulist->end(); ++x) + for (UserMembCIter x = ulist->begin(); x != ulist->end(); ++x) { data << "<channelmember><uid>" << x->first->uuid << "</uid><privs>" << Sanitize(c->GetAllPrefixChars(x->first)) << "</privs></channelmember>"; } diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index 678b9cc49..7da3f2934 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -49,21 +49,21 @@ class InvisibleMode : public ModeHandler /* User appears to vanish or appear from nowhere */ for (UCListIter f = dest->chans.begin(); f != dest->chans.end(); f++) { - CUList *ulist = f->first->GetUsers(); + const UserMembList *ulist = (*f)->GetUsers(); char tb[MAXBUF]; - snprintf(tb,MAXBUF,":%s %s %s", dest->GetFullHost().c_str(), adding ? "PART" : "JOIN", f->first->name.c_str()); + snprintf(tb,MAXBUF,":%s %s %s", dest->GetFullHost().c_str(), adding ? "PART" : "JOIN", (*f)->name.c_str()); std::string out = tb; - std::string n = this->ServerInstance->Modes->ModeString(dest, f->first); + std::string n = this->ServerInstance->Modes->ModeString(dest, (*f)); - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { /* User only appears to vanish for non-opers */ if (IS_LOCAL(i->first) && !IS_OPER(i->first)) { i->first->Write(out); if (!n.empty() && !adding) - i->first->WriteServ("MODE %s +%s", f->first->name.c_str(), n.c_str()); + i->first->WriteServ("MODE %s +%s", (*f)->name.c_str(), n.c_str()); } } } @@ -186,7 +186,7 @@ void ModuleInvisible::OnUserQuit(User* user, const std::string &reason, const st if (parthandler) { for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) - to_leave.push_back(f->first->name); + to_leave.push_back((*f)->name); /* We cant do this neatly in one loop, as we are modifying the map we are iterating */ for (std::vector<std::string>::iterator n = to_leave.begin(); n != to_leave.end(); n++) { @@ -236,9 +236,9 @@ void ModuleInvisible::WriteCommonFrom(User *user, Channel* channel, const char* va_end(argsPtr); snprintf(tb,MAXBUF,":%s %s",user->GetFullHost().c_str(), textbuffer); - CUList *ulist = channel->GetUsers(); + const UserMembList *ulist = channel->GetUsers(); - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { /* User only appears to vanish for non-opers */ if (IS_LOCAL(i->first) && IS_OPER(i->first)) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 7d0f59481..db17ee09d 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -207,7 +207,7 @@ class ModuleMsgFlood : public Module ModResult ProcessMessages(User* user,Channel* dest, const std::string &text) { - if (!IS_LOCAL(user) || (CHANOPS_EXEMPT(ServerInstance, 'f') && dest->GetStatus(user) == STATUS_OP)) + if (!IS_LOCAL(user) || (CHANOPS_EXEMPT(ServerInstance, 'f') && dest->GetPrefixValue(user) == OP_VALUE)) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp index 0ac2e7ece..d1ba487a6 100644 --- a/src/modules/m_muteban.cpp +++ b/src/modules/m_muteban.cpp @@ -40,7 +40,7 @@ class ModuleQuietBan : public Module return MOD_RES_PASSTHRU; Channel* chan = static_cast<Channel*>(dest); - if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetStatus(user) < STATUS_VOICE) + if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE) { user->WriteNumeric(404, "%s %s :Cannot send to channel (you're muted)", user->nick.c_str(), chan->name.c_str()); return MOD_RES_DENY; diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 898c7358d..e2ec1e3ed 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -214,12 +214,12 @@ class ModuleNickFlood : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { - Channel *channel = i->first; + Channel *channel = *i; nickfloodsettings *f = nf.ext.get(channel); if (f) { - if (CHANOPS_EXEMPT(ServerInstance, 'F') && channel->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'F') && channel->GetPrefixValue(user) == OP_VALUE) continue; if (f->islocked()) @@ -251,12 +251,12 @@ class ModuleNickFlood : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); ++i) { - Channel *channel = i->first; + Channel *channel = *i; nickfloodsettings *f = nf.ext.get(channel); if (f) { - if (CHANOPS_EXEMPT(ServerInstance, 'F') && channel->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'F') && channel->GetPrefixValue(user) == OP_VALUE) return; /* moved this here to avoid incrementing the counter for nick diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 0dc004ee8..ce79a5ff6 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -80,7 +80,7 @@ class ModuleNoCTCP : public Module { Channel* c = (Channel*)dest; - if (CHANOPS_EXEMPT(ServerInstance, 'C') && c->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'C') && c->GetPrefixValue(user) == OP_VALUE) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index 029ae9d2e..31839c13a 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -84,9 +84,9 @@ class ModuleNoNickChange : public Module for (UCListIter i = user->chans.begin(); i != user->chans.end(); i++) { - Channel* curr = i->first; + Channel* curr = *i; - if (CHANOPS_EXEMPT(ServerInstance, 'N') && curr->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'N') && curr->GetPrefixValue(user) == OP_VALUE) continue; if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet('N'))) diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp index 72426646f..fab52ca2e 100644 --- a/src/modules/m_nonotice.cpp +++ b/src/modules/m_nonotice.cpp @@ -52,7 +52,7 @@ class ModuleNoNotice : public Module // ulines are exempt. return MOD_RES_PASSTHRU; } - else if (CHANOPS_EXEMPT(ServerInstance, 'T') && c->GetStatus(user) == STATUS_OP) + else if (CHANOPS_EXEMPT(ServerInstance, 'T') && c->GetPrefixValue(user) == OP_VALUE) { // channel ops are exempt if set in conf. return MOD_RES_PASSTHRU; diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index 4e9477af1..c03f2ad1f 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -115,14 +115,14 @@ class NetworkPrefix : public ModeHandler User* x = ServerInstance->FindNick(parameter); if (x) { - if (!channel->HasUser(x)) + Membership* m = channel->GetUser(x); + if (!m) { return std::make_pair(false, parameter); } else { - std::string item = "cm_network_"+std::string(channel->name); - if (x->GetExt(item)) + if (m->hasMode('Y')) { return std::make_pair(true, x->nick); } @@ -137,16 +137,15 @@ class NetworkPrefix : public ModeHandler void RemoveMode(Channel* channel, irc::modestacker* stack) { - CUList* cl = channel->GetUsers(); - std::string item = "cm_network_" + std::string(channel->name); + const UserMembList* cl = channel->GetUsers(); std::vector<std::string> mode_junk; mode_junk.push_back(channel->name); irc::modestacker modestack(ServerInstance, false); std::deque<std::string> stackresult; - for (CUList::iterator i = cl->begin(); i != cl->end(); i++) + for (UserMembCIter i = cl->begin(); i != cl->end(); i++) { - if (i->first->GetExt(item)) + if (i->second->hasMode('Y')) { if (stack) stack->Push(this->GetModeChar(), i->first->nick); @@ -179,22 +178,19 @@ class NetworkPrefix : public ModeHandler ModeAction HandleChange(User* source, User* theuser, bool adding, Channel* channel, std::string ¶meter) { - std::string item = "cm_network_" + std::string(channel->name); - - if (adding) + Membership* m = channel->GetUser(theuser); + if (m && adding) { - if (!theuser->GetExt(item)) + if (!m->hasMode('Y')) { - theuser->Extend(item); parameter = theuser->nick; return MODEACTION_ALLOW; } } - else + else if (m && !adding) { - if (theuser->GetExt(item)) + if (m->hasMode('Y')) { - theuser->Shrink(item); parameter = theuser->nick; return MODEACTION_ALLOW; } @@ -271,26 +267,15 @@ class ModuleOjoin : public Module { if (mycommand.active) { - if (NPrefix) - privs += NPrefix; - if (op && privs.find('@') == std::string::npos) - privs += '@'; + privs += 'Y'; + if (op) + privs += 'o'; return MOD_RES_ALLOW; } return MOD_RES_PASSTHRU; } - void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent) - { - user->Shrink("cm_network_"+std::string(chan->name)); - } - - void OnUserPart(User* user, Channel* channel, std::string &partreason, bool &silent) - { - user->Shrink("cm_network_"+std::string(channel->name)); - } - void OnRehash(User* user) { ConfigReader Conf(ServerInstance); @@ -321,12 +306,12 @@ class ModuleOjoin : public Module // If a ulined nickname, or a server is setting the mode, let it // do whatever it wants. if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server)) - return MOD_RES_ALLOW; + return MOD_RES_PASSTHRU; - std::string network("cm_network_"+channel->name); + Membership* m = channel->GetUser(dest); // Don't do anything if they're not +Y - if (!dest->GetExt(network)) + if (!m || !m->hasMode('Y')) return MOD_RES_PASSTHRU; // Let them do whatever they want to themselves. diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index aeea1ad19..e7a772432 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -21,33 +21,6 @@ #define OPERPREFIX_VALUE 1000000 -std::set<std::string>* SetupExt(User* user) -{ - std::set<std::string>* ext; - if (!user->GetExt("m_operprefix",ext)) - { - ext=new std::set<std::string>; - ext->clear(); - user->Extend("m_operprefix",ext); - } - return ext; -} - - -void DelPrefixChan(User* user, Channel* channel) -{ - std::set<std::string>* chans = SetupExt(user); - chans->erase(channel->name); -} - - -void AddPrefixChan(User* user, Channel* channel) -{ - std::set<std::string>* chans = SetupExt(user); - chans->insert(channel->name); -} - - class OperPrefixMode : public ModeHandler { public: @@ -73,28 +46,19 @@ 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 (!channel->HasUser(x)) + if (!m) { return std::make_pair(false, parameter); } else { - std::set<std::string>* ext; - if (x->GetExt("m_operprefix",ext)) - { - if (ext->find(channel->name)!=ext->end()) - { - return std::make_pair(true, x->nick); - } - else - return std::make_pair(false, parameter); - } + if (m->hasMode('y')) + return std::make_pair(true, x->nick); else - { - return std::make_pair(false, parameter); - } + return std::make_pair(false, parameter); } } return std::make_pair(false, parameter); @@ -117,19 +81,13 @@ class ModuleOperPrefixMode : public Module if ((!ServerInstance->Modes->AddMode(opm))) throw ModuleException("Could not add a new mode!"); - Implementation eventlist[] = { I_OnPostJoin, I_OnCleanup, I_OnUserQuit, I_OnUserKick, I_OnUserPart, I_OnOper }; - ServerInstance->Modules->Attach(eventlist, this, 6); + Implementation eventlist[] = { I_OnPostJoin, I_OnUserQuit, I_OnUserKick, I_OnUserPart, I_OnOper }; + ServerInstance->Modules->Attach(eventlist, this, 5); } - void PushChanMode(Channel* channel, User* user, bool negate = false) + void PushChanMode(Channel* channel, User* user) { - if (negate) - DelPrefixChan(user, channel); - else - AddPrefixChan(user, channel); char modeline[] = "+y"; - if (negate) - modeline[0] = '-'; std::vector<std::string> modechange; modechange.push_back(channel->name); modechange.push_back(modeline); @@ -137,7 +95,7 @@ class ModuleOperPrefixMode : public Module ServerInstance->SendMode(modechange,this->ServerInstance->FakeClient); } - virtual void OnPostJoin(User *user, Channel *channel) + void OnPostJoin(User *user, Channel *channel) { if (user && IS_OPER(user)) { @@ -151,7 +109,7 @@ class ModuleOperPrefixMode : public Module } // XXX: is there a better way to do this? - virtual ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string ¶m, bool adding, int pcnt) + ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string ¶m, bool adding, int pcnt) { /* force event propagation to its ModeHandler */ if (!IS_FAKE(user) && chan && (mode == 'y')) @@ -159,72 +117,24 @@ class ModuleOperPrefixMode : public Module return MOD_RES_PASSTHRU; } - virtual void OnOper(User *user, const std::string&) + void OnOper(User *user, const std::string&) { if (user && !user->IsModeSet('H')) { for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++) { - PushChanMode(v->first, user); + PushChanMode(*v, user); } } } - virtual ~ModuleOperPrefixMode() + ~ModuleOperPrefixMode() { ServerInstance->Modes->DelMode(opm); delete opm; } - void CleanUser(User* user, bool quitting) - { - - std::set<std::string>* ext; - if (user->GetExt("m_operprefix",ext)) - { - // Don't want to announce -mode when they're quitting anyway.. - if (!quitting) - { - for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++) - { - ModePair ms = opm->ModeSet(NULL, NULL , v->first, user->nick); - if (ms.first) - { - PushChanMode(v->first, user, true); - } - } - } - ext->clear(); - delete ext; - user->Shrink("m_operprefix"); - } - } - - virtual void OnCleanup(int target_type, void* item) - { - if (target_type == TYPE_USER) - { - User* user = (User*)item; - CleanUser(user, false); - } - } - - virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) - { - CleanUser(user,true); - } - - virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent) - { - DelPrefixChan(user, chan); - } - - virtual void OnUserPart(User* user, Channel* channel, std::string &partreason, bool &silent) - { - DelPrefixChan(user, channel); - } - - virtual Version GetVersion() + Version GetVersion() { return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION); } diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index d0ec5d8fe..0a445eff7 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -120,7 +120,7 @@ class ModuleOverride : public Module { if (IS_LOCAL(source) && IS_OPER(source) && CanOverride(source, "TOPIC")) { - if (!channel->HasUser(source) || (channel->IsModeSet('t') && channel->GetStatus(source) < STATUS_HOP)) + if (!channel->HasUser(source) || (channel->IsModeSet('t') && channel->GetPrefixValue(source) < HALFOP_VALUE)) { ServerInstance->SNO->WriteGlobalSno('G',std::string(source->nick)+" used oper override to change a topic on "+std::string(channel->name)); } @@ -137,7 +137,7 @@ class ModuleOverride : public Module if (IS_OPER(source) && CanOverride(source,"KICK")) { // If the kicker's status is less than the target's, or the kicker's status is less than or equal to voice - if ((chan->GetStatus(source) < chan->GetStatus(user)) || (chan->GetStatus(source) <= STATUS_VOICE)) + if ((chan->GetPrefixValue(source) < chan->GetPrefixValue(user)) || (chan->GetPrefixValue(source) <= VOICE_VALUE)) { ServerInstance->SNO->WriteGlobalSno('G',std::string(source->nick)+" used oper override to kick "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")"); } @@ -153,50 +153,50 @@ class ModuleOverride : public Module if (!source || !channel) return MOD_RES_PASSTHRU; - int mode = STATUS_NORMAL; + int mode = 0; if (channel->HasUser(source)) - mode = channel->GetStatus(source); + mode = channel->GetPrefixValue(source); bool over_this = false; switch (access_type) { case AC_DEOP: - if (mode < STATUS_OP && CanOverride(source,"MODEDEOP")) + if (mode < OP_VALUE && CanOverride(source,"MODEDEOP")) { over_this = true; OverDeops++; } break; case AC_OP: - if (mode < STATUS_OP && CanOverride(source,"MODEOP")) + if (mode < OP_VALUE && CanOverride(source,"MODEOP")) { over_this = true; OverOps++; } break; case AC_VOICE: - if (mode < STATUS_HOP && CanOverride(source,"MODEVOICE")) + if (mode < HALFOP_VALUE && CanOverride(source,"MODEVOICE")) { over_this = true; OverVoices++; } break; case AC_DEVOICE: - if (mode < STATUS_HOP && CanOverride(source,"MODEDEVOICE")) + if (mode < HALFOP_VALUE && CanOverride(source,"MODEDEVOICE")) { over_this = true; OverDevoices++; } break; case AC_HALFOP: - if (mode < STATUS_OP && CanOverride(source,"MODEHALFOP")) + if (mode < OP_VALUE && CanOverride(source,"MODEHALFOP")) { over_this = true; OverHalfops++; } break; case AC_DEHALFOP: - if (mode < STATUS_OP && CanOverride(source,"MODEDEHALFOP")) + if (mode < OP_VALUE && CanOverride(source,"MODEDEHALFOP")) { over_this = true; OverDehalfops++; @@ -207,7 +207,7 @@ class ModuleOverride : public Module std::string modes = ServerInstance->Modes->GetLastParse(); bool ohv_only = (modes.find_first_not_of("+-ohv") == std::string::npos); - if (mode < STATUS_HOP && (ohv_only || CanOverride(source,"OTHERMODE"))) + if (mode < HALFOP_VALUE && (ohv_only || CanOverride(source,"OTHERMODE"))) { over_this = true; if (!ohv_only) diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 9d19b0cf0..667ab307f 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -53,7 +53,7 @@ class Redirect : public ModeHandler parameter.clear(); return MODEACTION_DENY; } - else if (c->GetStatus(source) < STATUS_OP) + else if (c->GetPrefixValue(source) < OP_VALUE) { source->WriteNumeric(690, "%s :You must be opped on %s to set it as a redirect.",source->nick.c_str(),parameter.c_str()); parameter.clear(); diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index b2763d86a..d17deb742 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -34,49 +34,12 @@ class RemoveBase : public Command { } - enum ModeLevel { PEON = 0, HALFOP = 1, OP = 2, ADMIN = 3, OWNER = 4, ULINE = 5 }; - - /* This little function just converts a chanmode character (U ~ & @ & +) into an integer (5 4 3 2 1 0) */ - /* XXX - We should probably use the new mode prefix rank stuff - * for this instead now -- Brain */ - ModeLevel chartolevel(const std::string &privs) - { - if(privs.empty()) - { - return PEON; - } - - switch (privs[0]) - { - case 'U': - /* Ulined */ - return ULINE; - case '~': - /* Owner */ - return OWNER; - case '&': - /* Admin */ - return ADMIN; - case '@': - /* Operator */ - return OP; - case '%': - /* Halfop */ - return HALFOP; - default: - /* Peon */ - return PEON; - } - } - CmdResult HandleRMB(const std::vector<std::string>& parameters, User *user, bool neworder) { const char* channame; const char* username; User* target; Channel* channel; - ModeLevel tlevel; - ModeLevel ulevel; std::string reason; std::string protectkey; std::string founderkey; @@ -109,57 +72,20 @@ class RemoveBase : public Command return CMD_FAILURE; } - /* This is adding support for the +q and +a channel modes, basically if they are enabled, and the remover has them set. - * Then we change the @|%|+ to & if they are +a, or ~ if they are +q */ - protectkey = "cm_protect_" + std::string(channel->name); - founderkey = "cm_founder_" + std::string(channel->name); - - if (ServerInstance->ULine(user->server) || ServerInstance->ULine(user->nick.c_str())) - { - ulevel = chartolevel("U"); - } - if (user->GetExt(founderkey)) - { - ulevel = chartolevel("~"); - } - else if (user->GetExt(protectkey)) - { - ulevel = chartolevel("&"); - } - else - { - ulevel = chartolevel(channel->GetPrefixChar(user)); - } - - /* Now it's the same idea, except for the target. If they're ulined make sure they get a higher level than the sender can */ - if (ServerInstance->ULine(target->server) || ServerInstance->ULine(target->nick.c_str())) - { - tlevel = chartolevel("U"); - } - else if (target->GetExt(founderkey)) - { - tlevel = chartolevel("~"); - } - else if (target->GetExt(protectkey)) - { - tlevel = chartolevel("&"); - } - else - { - tlevel = chartolevel(channel->GetPrefixChar(target)); - } + int ulevel = channel->GetPrefixValue(user); + int tlevel = channel->GetPrefixValue(target); hasnokicks = (ServerInstance->Modules->Find("m_nokicks.so") && channel->IsModeSet('Q')); /* We support the +Q channel mode via. the m_nokicks module, if the module is loaded and the mode is set then disallow the /remove */ - if ((!IS_LOCAL(user)) || (!supportnokicks || !hasnokicks || (ulevel == ULINE))) + if ((!IS_LOCAL(user)) || (!supportnokicks || !hasnokicks)) { /* We'll let everyone remove their level and below, eg: * ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1) * a ulined target will get a higher level than it's possible for a /remover to get..so they're safe. * Nobody may remove a founder. */ - if ((!IS_LOCAL(user)) || ((ulevel > PEON) && (ulevel >= tlevel) && (tlevel != OWNER))) + if ((!IS_LOCAL(user)) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && (tlevel != 50000))) { // no you can't just go from a std::ostringstream to a std::string, Om. -nenolod // but you can do this, nenolod -brain diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 779cb541e..3b0709539 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -298,30 +298,15 @@ class ModuleSilence : public Module void OnBuildExemptList(MessageType message_type, Channel* chan, User* sender, char status, CUList &exempt_list, const std::string &text) { int public_silence = (message_type == MSG_PRIVMSG ? SILENCE_CHANNEL : SILENCE_CNOTICE); - CUList *ulist; - switch (status) - { - case '@': - ulist = chan->GetOppedUsers(); - break; - case '%': - ulist = chan->GetHalfoppedUsers(); - break; - case '+': - ulist = chan->GetVoicedUsers(); - break; - default: - ulist = chan->GetUsers(); - break; - } + const UserMembList *ulist = chan->GetUsers(); - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { if (IS_LOCAL(i->first)) { if (MatchPattern(i->first, sender, public_silence) == MOD_RES_ALLOW) { - exempt_list[i->first] = i->first->nick; + exempt_list.insert(i->first); } } } diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index abefad728..3ed85ea1e 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -96,11 +96,11 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) char* ptr = list + curlen; bool looped_once = false; - CUList *ulist = c->GetUsers(); + const UserMembList *ulist = c->GetUsers(); std::string modes; std::string params; - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { size_t ptrlen = 0; std::string modestr = this->ServerInstance->Modes->ModeString(i->first, c, false); diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 30b9cad3c..1550a1e37 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -194,9 +194,9 @@ void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &li /* returns a list of DIRECT servernames for a specific channel */ void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list) { - CUList *ulist = c->GetUsers(); + const UserMembList *ulist = c->GetUsers(); - for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) + for (UserMembCIter i = ulist->begin(); i != ulist->end(); i++) { if (IS_LOCAL(i->first)) continue; diff --git a/src/modules/m_spy.cpp b/src/modules/m_spy.cpp index 485c104b8..e964cb766 100644 --- a/src/modules/m_spy.cpp +++ b/src/modules/m_spy.cpp @@ -23,7 +23,7 @@ class ModuleSpy : public Module ServerInstance->Modules->Attach(I_OnUserList, this); } - virtual ModResult OnUserList(User* user, Channel* Ptr, CUList* &nameslist) + virtual ModResult OnUserList(User* user, Channel* Ptr) { /* User has priv and is NOT on the channel */ if (user->HasPrivPermission("channels/auspex") && !Ptr->HasUser(user)) diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index a07252069..396623eb9 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -31,8 +31,8 @@ class SSLMode : public ModeHandler { if (IS_LOCAL(source)) { - CUList* userlist = channel->GetUsers(); - for(CUList::iterator i = userlist->begin(); i != userlist->end(); i++) + const UserMembList* userlist = channel->GetUsers(); + for(UserMembCIter i = userlist->begin(); i != userlist->end(); i++) { BufferedSocketCertificateRequest req(i->first, creator, i->first->GetIOHook()); req.Send(); diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp index cbbef75c6..7abe4f7d2 100644 --- a/src/modules/m_stripcolor.cpp +++ b/src/modules/m_stripcolor.cpp @@ -115,7 +115,7 @@ class ModuleStripColor : public Module // check if we allow ops to bypass filtering, if we do, check if they're opped accordingly. // note: short circut logic here, don't wreck it. -- w00t - if (CHANOPS_EXEMPT(ServerInstance, 'S') && t->GetStatus(user) == STATUS_OP) + if (CHANOPS_EXEMPT(ServerInstance, 'S') && t->GetPrefixValue(user) == OP_VALUE) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 17e9cd50e..11ff23a12 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -44,8 +44,8 @@ class CommandTban : public Command Channel* channel = ServerInstance->FindChan(parameters[0]); if (channel) { - int cm = channel->GetStatus(user); - if ((cm == STATUS_HOP) || (cm == STATUS_OP)) + int cm = channel->GetPrefixValue(user); + if ((cm == HALFOP_VALUE) || (cm == OP_VALUE)) { if (!ServerInstance->IsValidMask(parameters[2])) { diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index 0e9b991a0..e659ffa23 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -47,9 +47,9 @@ class CommandUninvite : public Command if (IS_LOCAL(user)) { - if (c->GetStatus(user) < STATUS_HOP) + if (c->GetPrefixValue(user) < HALFOP_VALUE) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name.c_str(), c->GetStatus(u) == STATUS_HOP ? "" : "half-"); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name.c_str(), c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-"); return CMD_FAILURE; } } |