diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-04-21 02:15:48 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-04-21 02:15:48 +0000 |
commit | 508996215f22134ccb16ddf4fa0ec6d2941df789 (patch) | |
tree | e0228cfb7812de216347f7066aac3f8cbcd7c656 /src/core/cs_clear.c | |
parent | f87398b5320c2172e48d9a40d81c59830869d86e (diff) |
Fixed cs_clear ops to not deop users twice on Unreal and made it always use svsmode_ucmode if it can
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2902 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core/cs_clear.c')
-rw-r--r-- | src/core/cs_clear.c | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c index 0e8312f37..0ccc95629 100644 --- a/src/core/cs_clear.c +++ b/src/core/cs_clear.c @@ -28,15 +28,14 @@ class CommandCSClear : public Command const char *chan = params[0].c_str(); ci::string what = params[1]; Channel *c = findchan(chan); - ChannelInfo *ci; - ChannelMode *owner, *admin; + ChannelInfo *ci = c ? c->ci : NULL; std::string modebuf; - owner = ModeManager::FindChannelModeByName(CMODE_OWNER); - admin = ModeManager::FindChannelModeByName(CMODE_PROTECT); - - if (c) - ci = c->ci; + ChannelMode *owner = ModeManager::FindChannelModeByName(CMODE_OWNER); + ChannelMode *admin = ModeManager::FindChannelModeByName(CMODE_PROTECT); + ChannelMode *op = ModeManager::FindChannelModeByName(CMODE_OP); + ChannelMode *halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP); + ChannelMode *voice = ModeManager::FindChannelModeByName(CMODE_VOICE); if (!c) notice_lang(Config.s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); @@ -73,7 +72,6 @@ class CommandCSClear : public Command { if (ircd->svsmode_ucmode) { - ircdproto->SendSVSModeChan(c, "-o", NULL); if (owner) { modebuf = '-'; @@ -88,16 +86,12 @@ class CommandCSClear : public Command ircdproto->SendSVSModeChan(c, modebuf.c_str(), NULL); } - for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + if (op) { - UserContainer *uc = *it; + modebuf = "-"; + modebuf += op->ModeChar; - if (uc->Status->HasFlag(CMODE_OWNER)) - c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); - if (uc->Status->HasFlag(CMODE_PROTECT)) - c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); - if (uc->Status->HasFlag(CMODE_OP)) - c->RemoveMode(NULL, CMODE_OP, uc->user->nick); + ircdproto->SendSVSModeChan(c, modebuf.c_str(), NULL); } } else @@ -107,41 +101,40 @@ class CommandCSClear : public Command UserContainer *uc = *it; if (uc->Status->HasFlag(CMODE_OWNER)) - c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); + c->RemoveMode(NULL, owner, uc->user->nick); if (uc->Status->HasFlag(CMODE_PROTECT)) - c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); + c->RemoveMode(NULL, admin, uc->user->nick); if (uc->Status->HasFlag(CMODE_OP)) - c->RemoveMode(NULL, CMODE_OP, uc->user->nick); + c->RemoveMode(NULL, op, uc->user->nick); } } notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_OPS, chan); } - else if (ModeManager::FindChannelModeByName(CMODE_HALFOP) && what == "hops") + else if ((halfop && what == "hops") || (voice && what == "voices")) { - for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + ChannelMode *cm = (what == "hops" ? halfop : voice); + + if (ircd->svsmode_ucmode) { - UserContainer *uc = *it; + modebuf = "-"; + modebuf += cm->ModeChar; - if (uc->Status->HasFlag(CMODE_HALFOP)) - c->RemoveMode(NULL, CMODE_HALFOP, uc->user->nick); + ircdproto->SendSVSModeChan(c, modebuf.c_str(), NULL); } - - notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_HOPS, chan); - } - else if (what == "voices") - { - for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + else { - UserContainer *uc = *it; + for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it) + { + UserContainer *uc = *it; - if (uc->Status->HasFlag(CMODE_VOICE)) - c->RemoveMode(NULL, CMODE_VOICE, uc->user->nick); + if (uc->Status->HasFlag(cm->Name)) + c->RemoveMode(NULL, cm, uc->user->nick); + } } - - notice_lang(Config.s_ChanServ, u, CHAN_CLEARED_VOICES, chan); } - else if (what == "users") { + else if (what == "users") + { std::string buf = "CLEAR USERS command from " + u->nick; for (CUserList::iterator it = c->users.begin(); it != c->users.end();) |