summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mode.h2
-rw-r--r--src/mode.cpp26
2 files changed, 17 insertions, 11 deletions
diff --git a/include/mode.h b/include/mode.h
index 27b06087d..d09d62439 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -85,6 +85,8 @@ class ModeWatcher
virtual void AfterMode(userrec* source, userrec* dest, chanrec* channel, const std::string &parameter, bool adding, ModeType type);
};
+typedef std::vector<ModeWatcher*>::iterator ModeWatchIter;
+
class ModeParser
{
private:
diff --git a/src/mode.cpp b/src/mode.cpp
index 62c3d8d08..3842b01e6 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -539,7 +539,7 @@ void ModeParser::Process(char **parameters, int pcnt, userrec *user, bool server
if (modehandlers[handler_id])
{
bool abort = false;
- for (std::vector<ModeWatcher*>::iterator watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
+ for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
{
if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type) == MODEACTION_DENY)
abort = true;
@@ -574,7 +574,7 @@ void ModeParser::Process(char **parameters, int pcnt, userrec *user, bool server
}
/* Call all the AfterMode events in the mode watchers for this mode */
- for (std::vector<ModeWatcher*>::iterator watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
+ for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
{
(*watchers)->AfterMode(user, targetuser, targetchannel, parameter, adding, type);
}
@@ -587,19 +587,23 @@ void ModeParser::Process(char **parameters, int pcnt, userrec *user, bool server
break;
}
}
- if (servermode)
+ /* Was there at least one valid mode in the sequence? */
+ if (output_sequence != "")
{
- if (type == MODETYPE_CHANNEL)
+ if (servermode)
{
- WriteChannelWithServ(Config->ServerName,targetchannel,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
+ if (type == MODETYPE_CHANNEL)
+ {
+ WriteChannelWithServ(Config->ServerName,targetchannel,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
+ }
}
- }
- else
- {
- if (type == MODETYPE_CHANNEL)
+ else
{
- WriteChannel(targetchannel,user,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
- FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str()));
+ if (type == MODETYPE_CHANNEL)
+ {
+ WriteChannel(targetchannel,user,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
+ FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str()));
+ }
}
}
}