diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-09-03 15:05:56 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-09-03 15:05:56 +0200 |
commit | c6c43eaf60b966870acaf152721e89b5289281b3 (patch) | |
tree | fce4987962e9a972e2cb7cc1e3a6950ebeec5005 | |
parent | 05022b58f2da1a6b0d1d7134a86fa566bada4232 (diff) |
Make it possible to resume processing a partially processed Modes::ChangeList
Return number of processed mode changes from ModeParser::ProcessSingle() and add a begin index parameter
-rw-r--r-- | include/mode.h | 7 | ||||
-rw-r--r-- | src/mode.cpp | 9 |
2 files changed, 12 insertions, 4 deletions
diff --git a/include/mode.h b/include/mode.h index 66f003b99..fbc880129 100644 --- a/include/mode.h +++ b/include/mode.h @@ -681,7 +681,7 @@ class CoreExport ModeParser : public fakederef<ModeParser> void Process(const std::vector<std::string>& parameters, User* user, ModeProcessFlag flags = MODE_NONE); /** Process a single MODE line's worth of mode changes, taking max modes and line length limits - * into consideration. + * into consideration. Return value indicates how many modes were processed. * @param user The source of the mode change, can be a server user. * @param targetchannel Channel to apply the mode change on. NULL if changing modes on a channel. * @param targetuser User to apply the mode change on. NULL if changing modes on a user. @@ -689,8 +689,11 @@ class CoreExport ModeParser : public fakederef<ModeParser> * the entire list due to MODE line length and max modes limitations. * @param flags Optional flags controlling how the mode change is processed, * defaults to MODE_NONE. + * @param beginindex Index of the first element in changelist to process. Mode changes before + * the element with this index are ignored. + * @return Number of mode changes processed from changelist. */ - void ProcessSingle(User* user, Channel* targetchannel, User* targetuser, Modes::ChangeList& changelist, ModeProcessFlag flags = MODE_NONE); + unsigned int ProcessSingle(User* user, Channel* targetchannel, User* targetuser, Modes::ChangeList& changelist, ModeProcessFlag flags = MODE_NONE, unsigned int beginindex = 0); /** Turn a list of parameters compatible with the format of the MODE command into * Modes::ChangeList form. All modes are processed, regardless of max modes. Unknown modes diff --git a/src/mode.cpp b/src/mode.cpp index 9b27a3d13..c44942bd6 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -486,18 +486,21 @@ static bool ShouldApplyMergedMode(Channel* chan, Modes::Change& item) return mh->ResolveModeConflict(item.param, ours, chan); } -void ModeParser::ProcessSingle(User* user, Channel* targetchannel, User* targetuser, Modes::ChangeList& changelist, ModeProcessFlag flags) +unsigned int ModeParser::ProcessSingle(User* user, Channel* targetchannel, User* targetuser, Modes::ChangeList& changelist, ModeProcessFlag flags, unsigned int beginindex) { LastParse.clear(); LastChangeList.clear(); + unsigned int modes_processed = 0; std::string output_mode; std::string output_parameters; char output_pm = '\0'; // current output state, '+' or '-' Modes::ChangeList::List& list = changelist.getlist(); - for (Modes::ChangeList::List::iterator i = list.begin(); i != list.end(); ++i) + for (Modes::ChangeList::List::iterator i = list.begin()+beginindex; i != list.end(); ++i) { + modes_processed++; + Modes::Change& item = *i; ModeHandler* mh = item.mh; @@ -557,6 +560,8 @@ void ModeParser::ProcessSingle(User* user, Channel* targetchannel, User* targetu FOREACH_MOD(OnMode, (user, targetuser, targetchannel, LastChangeList, flags, output_mode)); } + + return modes_processed; } void ModeParser::DisplayListModes(User* user, Channel* chan, const std::string& mode_sequence) |