From 129416e519319360c336cb3905210fdb9b531ae2 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 10 Apr 2006 20:43:03 +0000 Subject: 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 --- include/mode.h | 2 ++ 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::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::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::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())); + } } } } -- cgit v1.2.3