]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Module priority 'shuffler' suggestion from Phoenix, needs some testing but works...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 Jun 2008 16:43:34 +0000 (16:43 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 24 Jun 2008 16:43:34 +0000 (16:43 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9933 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules.cpp

index a45ec21eca64ff7007b79827f9a1725ea07cb6db..9c608cb823493cc50138e6961fa5e025fc344c17 100644 (file)
@@ -332,7 +332,14 @@ bool ModuleManager::SetPriority(Module* mod, Implementation i, PriorityState s,
 
        /* Do we need to swap? */
        if (swap && (swap_pos != source))
-               std::swap(EventHandlers[i][swap_pos], EventHandlers[i][source]);
+       {
+               /* 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)
+                       std::swap(EventHandlers[i][j], EventHandlers[i][j+incrmnt]);
+       }
 
        return true;
 }