diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-04-10 20:43:03 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-04-10 20:43:03 +0000 |
commit | 129416e519319360c336cb3905210fdb9b531ae2 (patch) | |
tree | 02588526c258321b185b9d03818aa057552f0e41 | |
parent | ecb76110fda5f1b126ae718ae44df2f9312d46c4 (diff) |
Typedef an ugly iterator, dont send mode string if no modes were in the output sequence
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3867 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/mode.h | 2 | ||||
-rw-r--r-- | src/mode.cpp | 26 |
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 ¶meter, 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())); + } } } } |