diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-30 19:41:48 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-30 19:41:48 +0000 |
commit | 6d2fc8eac05b76126f78e063778bfc800ffa88e7 (patch) | |
tree | df4e5734b45c41383383398366e553fe92fb909b | |
parent | 2779810ff0d1b66f0fca1a62d6164d70f5c86d06 (diff) |
Fix bug #310 reported by Smartys, and optimize mode.cpp a bit (was using string comparison to identify an empty string, e.g. somestr == "", when we can use the much faster somestr.empty())
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7191 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/mode.cpp | 8 | ||||
-rw-r--r-- | src/modes/umode_n.cpp | 13 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index 8b91f7af5..874d8bef4 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -496,7 +496,6 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++) { - ServerInstance->Log(DEBUG,"Call mode watcher"); if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type) == false) { abort = true; @@ -543,7 +542,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool /* Call the handler for the mode */ ModeAction ma = modehandlers[handler_id]->OnModeChange(user, targetuser, targetchannel, parameter, adding); - if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter == "")) + if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter.empty())) { /* The handler nuked the parameter and they are supposed to have one. * We CANT continue now, even if they actually returned MODEACTION_ALLOW, @@ -566,7 +565,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool output_sequence.push_back(modechar); /* Is there a valid parameter for this mode? If so add it to the parameter list */ - if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter != "")) + if ((modehandlers[handler_id]->GetNumParams(adding)) && (!parameter.empty())) { parameter_list << " " << parameter; parameter_count++; @@ -605,8 +604,9 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool break; } } + /* Was there at least one valid mode in the sequence? */ - if (output_sequence != "") + if (!output_sequence.empty()) { if (servermode) { diff --git a/src/modes/umode_n.cpp b/src/modes/umode_n.cpp index 98b97094e..c9c9e312e 100644 --- a/src/modes/umode_n.cpp +++ b/src/modes/umode_n.cpp @@ -30,6 +30,10 @@ ModeAction ModeUserServerNoticeMask::OnModeChange(userrec* source, userrec* dest /* Set the bitfields */ if (adding) { + /* Fix for bug #310 reported by Smartys */ + if (!dest->modes[UM_SNOMASK]) + memset(dest->snomasks, 0, sizeof(dest->snomasks)); + parameter = dest->ProcessNoticeMasks(parameter.c_str()); dest->modes[UM_SNOMASK] = true; if (!dest->modes[UM_SERVERNOTICE]) @@ -39,10 +43,13 @@ ModeAction ModeUserServerNoticeMask::OnModeChange(userrec* source, userrec* dest } return MODEACTION_ALLOW; } - else if (dest->modes[UM_SNOMASK] != false) + else { - dest->modes[UM_SNOMASK] = false; - return MODEACTION_ALLOW; + if (dest->modes[UM_SNOMASK] != false) + { + dest->modes[UM_SNOMASK] = false; + return MODEACTION_ALLOW; + } } /* Allow the change */ |