diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-12-29 23:16:10 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-12-29 23:16:10 +0000 |
commit | 7665af27cd8317bd4fc017d78e3d1b89d6b0a823 (patch) | |
tree | ea4f8e4bf15dcf91ba0622ff0a8b036b0a91f8ef /src | |
parent | df107dac1f50e721493aaf0657f85cba5ef8b35f (diff) |
Chnaged ChannelModeSet/Unset events to be able to block checks such as secureops and mlock, and made it so you can't set a mode already set or unset a mode already unset so the modestacker doesn't send modes it doesn't need to
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2719 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.c | 14 | ||||
-rw-r--r-- | src/core/os_defcon.c | 18 | ||||
-rw-r--r-- | src/users.c | 4 |
3 files changed, 23 insertions, 13 deletions
diff --git a/src/channels.c b/src/channels.c index 85028b584..d90bdf94f 100644 --- a/src/channels.c +++ b/src/channels.c @@ -214,12 +214,13 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string ¶m, bool En Params.insert(std::make_pair(cm->Name, param)); } - FOREACH_MOD(I_OnChannelModeSet, OnChannelModeSet(this, cm->Name)); + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnChannelModeSet, OnChannelModeSet(this, cm->Name)); /* Check for mlock */ /* Non registered channel, no mlock */ - if (!ci || !EnforceMLock) + if (!ci || !EnforceMLock || MOD_RESULT == EVENT_STOP) return; /* If this channel has this mode locked negative */ @@ -333,12 +334,13 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string ¶m, bool } } - FOREACH_MOD(I_OnChannelModeUnset, OnChannelModeUnset(this, cm->Name)); + EventReturn MOD_RESULT; + FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, cm->Name)); /* Check for mlock */ /* Non registered channel, no mlock */ - if (!ci || !EnforceMLock) + if (!ci || !EnforceMLock || MOD_RESULT == EVENT_STOP) return; /* This channel has this the mode locked on */ @@ -368,7 +370,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string ¶m, bool */ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const std::string ¶m, bool EnforceMLock) { - if (!cm) + if (!cm || HasMode(cm->Name)) return; ModeManager::StackerAdd(bi, this, cm, true, param); @@ -407,7 +409,7 @@ void Channel::SetMode(BotInfo *bi, char Mode, const std::string ¶m, bool Enf */ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const std::string ¶m, bool EnforceMLock) { - if (!cm) + if (!cm || !HasMode(cm->Name)) return; ModeManager::StackerAdd(bi, this, cm, false, param); diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c index 804839bf8..e336ad6fa 100644 --- a/src/core/os_defcon.c +++ b/src/core/os_defcon.c @@ -180,17 +180,21 @@ class OSDEFCON : public Module return EVENT_CONTINUE; } - void OnChannelModeSet(Channel *c, ChannelModeName Name) + EventReturn OnChannelModeSet(Channel *c, ChannelModeName Name) { ChannelMode *cm = ModeManager::FindChannelModeByName(Name); if (CheckDefCon(DEFCON_FORCE_CHAN_MODES) && cm && DefConModesOff.HasFlag(Name)) { - c->RemoveMode(NULL, Name); + c->RemoveMode(findbot(Config.s_OperServ), Name); + + return EVENT_STOP; } + + return EVENT_CONTINUE; } - void OnChannelModeUnset(Channel *c, ChannelModeName Name) + EventReturn OnChannelModeUnset(Channel *c, ChannelModeName Name) { ChannelMode *cm = ModeManager::FindChannelModeByName(Name); @@ -200,12 +204,16 @@ class OSDEFCON : public Module if (GetDefConParam(Name, ¶m)) { - c->SetMode(NULL, Name, param); + c->SetMode(findbot(Config.s_OperServ), Name, param); } else - c->SetMode(NULL, Name); + c->SetMode(findbot(Config.s_OperServ), Name); + + return EVENT_STOP; } + + return EVENT_CONTINUE; } EventReturn OnPreCommandRun(const char *service, User *u, const char *cmd, Command *c) diff --git a/src/users.c b/src/users.c index 1a02e5344..96c95bbfb 100644 --- a/src/users.c +++ b/src/users.c @@ -512,7 +512,7 @@ void User::RemoveModeInternal(UserMode *um) */ void User::SetMode(BotInfo *bi, UserMode *um, const std::string &Param) { - if (!um) + if (!um || HasMode(um->Name)) return; ModeManager::StackerAdd(bi, this, um, true, Param); @@ -545,7 +545,7 @@ void User::SetMode(BotInfo *bi, char ModeChar, const std::string &Param) */ void User::RemoveMode(BotInfo *bi, UserMode *um) { - if (!um) + if (!um || !HasMode(um->Name)) return; ModeManager::StackerAdd(bi, this, um, false); |