From 91df762e93212958db487d8517addba1a63a4ddd Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 13 Sep 2009 20:30:47 +0000 Subject: Membership* changes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11697 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modes/cmode_b.cpp | 2 +- src/modes/cmode_h.cpp | 31 ++++++++++++++----------------- src/modes/cmode_o.cpp | 29 +++++++++++++---------------- src/modes/cmode_v.cpp | 29 +++++++++++++---------------- 4 files changed, 41 insertions(+), 50 deletions(-) (limited to 'src/modes') diff --git a/src/modes/cmode_b.cpp b/src/modes/cmode_b.cpp index 36078f4b2..9c9c2129c 100644 --- a/src/modes/cmode_b.cpp +++ b/src/modes/cmode_b.cpp @@ -31,7 +31,7 @@ ModeChannelBan::ModeChannelBan(InspIRCd* Instance) : ModeHandler(Instance, NULL, ModeAction ModeChannelBan::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) { - int status = channel->GetStatus(source); + int status = channel->GetPrefixValue(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) { diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 54ab139ce..480d69f0a 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -33,13 +33,14 @@ ModePair ModeChannelHalfOp::ModeSet(User*, User*, Channel* channel, const std::s User* x = ServerInstance->FindNick(parameter); if (x) { - if (channel->GetStatusFlags(x) & UCMODE_HOP) + Membership* memb = channel->GetUser(x); + if (memb && memb->hasMode('h')) { return std::make_pair(true, x->nick); } else { - return std::make_pair(false, parameter); + return std::make_pair(false, x->nick); } } return std::make_pair(false, parameter); @@ -47,16 +48,9 @@ ModePair ModeChannelHalfOp::ModeSet(User*, User*, Channel* channel, const std::s void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack) { - CUList* clist = channel->GetHalfoppedUsers(); - CUList copy; + const UserMembList* clist = channel->GetUsers(); - for (CUList::iterator i = clist->begin(); i != clist->end(); i++) - { - User* n = i->first; - copy.insert(std::make_pair(n,n->nick)); - } - - for (CUList::iterator i = copy.begin(); i != copy.end(); i++) + for (UserMembCIter i = clist->begin(); i != clist->end(); i++) { if (stack) { @@ -64,7 +58,10 @@ void ModeChannelHalfOp::RemoveMode(Channel* channel, irc::modestacker* stack) } else { - std::vector parameters; parameters.push_back(channel->name); parameters.push_back("-h"); parameters.push_back(i->first->nick); + std::vector parameters; + parameters.push_back(channel->name); + parameters.push_back("-h"); + parameters.push_back(i->first->nick); ServerInstance->SendMode(parameters, ServerInstance->FakeClient); } } @@ -77,7 +74,7 @@ void ModeChannelHalfOp::RemoveMode(User*, irc::modestacker* stack) ModeAction ModeChannelHalfOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) { - int status = channel->GetStatus(source); + int status = channel->GetPrefixValue(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) @@ -114,7 +111,7 @@ std::string ModeChannelHalfOp::AddHalfOp(User *user,const char* dest,Channel *ch return ""; if (MOD_RESULT == MOD_RES_PASSTHRU) { - if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) + if ((status < OP_VALUE) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You're not a channel operator",user->nick.c_str(), chan->name.c_str()); return ""; @@ -122,7 +119,7 @@ std::string ModeChannelHalfOp::AddHalfOp(User *user,const char* dest,Channel *ch } } - return ServerInstance->Modes->Grant(d,chan,UCMODE_HOP); + return d->nick; } return ""; } @@ -142,7 +139,7 @@ std::string ModeChannelHalfOp::DelHalfOp(User *user,const char *dest,Channel *ch return ""; if (MOD_RESULT == MOD_RES_PASSTHRU) { - if ((user != d) && ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))) + if ((user != d) && ((status < OP_VALUE) && (!ServerInstance->ULine(user->server)))) { user->WriteServ("482 %s %s :You are not a channel operator",user->nick.c_str(), chan->name.c_str()); return ""; @@ -150,7 +147,7 @@ std::string ModeChannelHalfOp::DelHalfOp(User *user,const char *dest,Channel *ch } } - return ServerInstance->Modes->Revoke(d,chan,UCMODE_HOP); + return d->nick; } return ""; } diff --git a/src/modes/cmode_o.cpp b/src/modes/cmode_o.cpp index 908eb698c..9da9fa478 100644 --- a/src/modes/cmode_o.cpp +++ b/src/modes/cmode_o.cpp @@ -33,7 +33,8 @@ ModePair ModeChannelOp::ModeSet(User*, User*, Channel* channel, const std::strin User* x = ServerInstance->FindNick(parameter); if (x) { - if (channel->GetStatusFlags(x) & UCMODE_OP) + Membership* memb = channel->GetUser(x); + if (memb && memb->hasMode('o')) { return std::make_pair(true, x->nick); } @@ -48,22 +49,18 @@ ModePair ModeChannelOp::ModeSet(User*, User*, Channel* channel, const std::strin void ModeChannelOp::RemoveMode(Channel* channel, irc::modestacker* stack) { - CUList* clist = channel->GetOppedUsers(); - CUList copy; + const UserMembList* clist = channel->GetUsers(); - for (CUList::iterator i = clist->begin(); i != clist->end(); i++) - { - User* n = i->first; - copy.insert(std::make_pair(n,n->nick)); - } - - for (CUList::iterator i = copy.begin(); i != copy.end(); i++) + for (UserMembCIter i = clist->begin(); i != clist->end(); i++) { if (stack) stack->Push(this->GetModeChar(), i->first->nick); else { - std::vector parameters; parameters.push_back(channel->name); parameters.push_back("-o"); parameters.push_back(i->first->nick); + std::vector parameters; + parameters.push_back(channel->name); + parameters.push_back("-o"); + parameters.push_back(i->first->nick); ServerInstance->SendMode(parameters, ServerInstance->FakeClient); } } @@ -75,7 +72,7 @@ void ModeChannelOp::RemoveMode(User*, irc::modestacker* stack) ModeAction ModeChannelOp::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) { - int status = channel->GetStatus(source); + int status = channel->GetPrefixValue(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) @@ -112,7 +109,7 @@ std::string ModeChannelOp::AddOp(User *user,const char* dest,Channel *chan,int s return ""; if (MOD_RESULT == MOD_RES_PASSTHRU) { - if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) + if ((status < OP_VALUE) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You're not a channel operator",user->nick.c_str(), chan->name.c_str()); return ""; @@ -120,7 +117,7 @@ std::string ModeChannelOp::AddOp(User *user,const char* dest,Channel *chan,int s } } - return ServerInstance->Modes->Grant(d,chan,UCMODE_OP); + return d->nick; } return ""; } @@ -140,7 +137,7 @@ std::string ModeChannelOp::DelOp(User *user,const char *dest,Channel *chan,int s return ""; if (MOD_RESULT == MOD_RES_PASSTHRU) { - if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)) && (IS_LOCAL(user))) + if ((status < OP_VALUE) && (!ServerInstance->ULine(user->server)) && (IS_LOCAL(user))) { user->WriteServ("482 %s %s :You are not a channel operator",user->nick.c_str(), chan->name.c_str()); return ""; @@ -148,7 +145,7 @@ std::string ModeChannelOp::DelOp(User *user,const char *dest,Channel *chan,int s } } - return ServerInstance->Modes->Revoke(d,chan,UCMODE_OP); + return d->nick; } return ""; } diff --git a/src/modes/cmode_v.cpp b/src/modes/cmode_v.cpp index 03dbb5a33..031cefb7f 100644 --- a/src/modes/cmode_v.cpp +++ b/src/modes/cmode_v.cpp @@ -34,7 +34,8 @@ ModePair ModeChannelVoice::ModeSet(User*, User*, Channel* channel, const std::st User* x = ServerInstance->FindNick(parameter); if (x) { - if (channel->GetStatusFlags(x) & UCMODE_VOICE) + Membership* memb = channel->GetUser(x); + if (memb && memb->hasMode('v')) { return std::make_pair(true, x->nick); } @@ -48,22 +49,18 @@ ModePair ModeChannelVoice::ModeSet(User*, User*, Channel* channel, const std::st void ModeChannelVoice::RemoveMode(Channel* channel, irc::modestacker* stack) { - CUList* clist = channel->GetVoicedUsers(); - CUList copy; + const UserMembList* clist = channel->GetUsers(); - for (CUList::iterator i = clist->begin(); i != clist->end(); i++) - { - User* n = i->first; - copy.insert(std::make_pair(n,n->nick)); - } - - for (CUList::iterator i = copy.begin(); i != copy.end(); i++) + for (UserMembCIter i = clist->begin(); i != clist->end(); i++) { if (stack) stack->Push(this->GetModeChar(), i->first->nick); else { - std::vector parameters; parameters.push_back(channel->name); parameters.push_back("-v"); parameters.push_back(i->first->nick); + std::vector parameters; + parameters.push_back(channel->name); + parameters.push_back("-v"); + parameters.push_back(i->first->nick); ServerInstance->SendMode(parameters, ServerInstance->FakeClient); } } @@ -75,7 +72,7 @@ void ModeChannelVoice::RemoveMode(User*, irc::modestacker* stack) ModeAction ModeChannelVoice::OnModeChange(User* source, User*, Channel* channel, std::string ¶meter, bool adding) { - int status = channel->GetStatus(source); + int status = channel->GetPrefixValue(source); /* Call the correct method depending on wether we're adding or removing the mode */ if (adding) @@ -112,7 +109,7 @@ std::string ModeChannelVoice::AddVoice(User *user,const char* dest,Channel *chan return ""; if (MOD_RESULT == MOD_RES_PASSTHRU) { - if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) + if ((status < HALFOP_VALUE) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You're not a channel (half)operator",user->nick.c_str(), chan->name.c_str()); return ""; @@ -120,7 +117,7 @@ std::string ModeChannelVoice::AddVoice(User *user,const char* dest,Channel *chan } } - return ServerInstance->Modes->Grant(d,chan,UCMODE_VOICE); + return d->nick; } return ""; } @@ -140,7 +137,7 @@ std::string ModeChannelVoice::DelVoice(User *user,const char *dest,Channel *chan return ""; if (MOD_RESULT == MOD_RES_PASSTHRU) { - if ((status < STATUS_HOP) && (!ServerInstance->ULine(user->server))) + if ((status < HALFOP_VALUE) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You are not a channel (half)operator",user->nick.c_str(), chan->name.c_str()); return ""; @@ -148,7 +145,7 @@ std::string ModeChannelVoice::DelVoice(User *user,const char *dest,Channel *chan } } - return ServerInstance->Modes->Revoke(d,chan,UCMODE_VOICE); + return d->nick; } return ""; } -- cgit v1.2.3