From: brain Date: Tue, 24 Jun 2008 17:17:59 +0000 (+0000) Subject: Module priority 'shuffler' fix from Phoenix, bounds checks X-Git-Tag: v2.0.23~2996 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=024ef0c621c6353bac7346f3ae9e457cc1fd4463;p=user%2Fhenk%2Fcode%2Finspircd.git Module priority 'shuffler' fix from Phoenix, bounds checks git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9934 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/src/modules.cpp b/src/modules.cpp index 9c608cb82..57790cd1b 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -335,10 +335,17 @@ bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s, { /* Suggestion from Phoenix, "shuffle" the modules to better retain call order */ int incrmnt = 1; + if (source > swap_pos) incrmnt = -1; + for (unsigned int j = source; j != swap_pos; j += incrmnt) + { + if (( j + incrmnt > EventHandlers[i].size() - 1) || (j - incrmnt < 0)) + continue; + std::swap(EventHandlers[i][j], EventHandlers[i][j+incrmnt]); + } } return true;