diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-04-10 12:44:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-04-10 12:44:19 +0000 |
commit | 984b2282806c29bc7ade875f26791b952d25d8de (patch) | |
tree | f5e268e7026c3d0c56e584838bfdf90f77e85b66 /src/mode.cpp | |
parent | bc0f60962214a0a5d306519b1b6e1f9b5edf205f (diff) |
Typo fixes, move some stuff about
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3862 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r-- | src/mode.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index 38b0bc20a..62c3d8d08 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -475,7 +475,7 @@ char* ModeParser::TakeBan(userrec *user,char *dest,chanrec *chan,int status) return NULL; } -void ModeParser::Process(char **parameters, int pcnt, userrec *user) +void ModeParser::Process(char **parameters, int pcnt, userrec *user, bool servermode) { std::string target = parameters[0]; ModeType type = MODETYPE_USER; @@ -532,11 +532,9 @@ void ModeParser::Process(char **parameters, int pcnt, userrec *user) continue; break; default: - if (state_change) - output_sequence.append(adding ? "+" : "-"); - handler_id = *modeletter-65; - state_change = false; + /* 65 is the ascii value of 'A' */ + handler_id = *modeletter - 65; if (modehandlers[handler_id]) { @@ -562,23 +560,48 @@ void ModeParser::Process(char **parameters, int pcnt, userrec *user) ModeAction ma = modehandlers[handler_id]->OnModeChange(user, targetuser, targetchannel, parameter, adding); if (ma == MODEACTION_ALLOW) { + /* We're about to output a valid mode letter - was there previously a pending state-change? */ + if (state_change) + output_sequence.append(adding ? "+" : "-"); + + /* Add the mode letter */ output_sequence = output_sequence + *modeletter; + /* Is there a valid parameter for this mode? If so add it to the parameter list */ if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter != "")) { parameter_list << " " << parameter; } + /* 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++) { (*watchers)->AfterMode(user, targetuser, targetchannel, parameter, adding, type); } + + /* Reset the state change flag */ + state_change = false; } } } break; } } + if (servermode) + { + 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) + { + 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())); + } + } } } |