-/**
- * This #define allows us to call a method in all
- * loaded modules in a readable simple way and pass
- * an instance pointer to the macro. e.g.:
- * 'FOREACH_MOD_I(Instance, OnConnect, OnConnect(user));'
- */
-#define FOREACH_MOD_I(z,y,x) do { \
- EventHandlerIter safei; \
- for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ) \
- { \
- safei = _i; \
- ++safei; \
- try \
- { \
- (*_i)->x ; \
- } \
- catch (CoreException& modexcept) \
- { \
- z->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
- } \
- _i = safei; \
- } \
-} while (0);
-
-/**
- * This define is similar to the one above but returns a result in MOD_RESULT.
- * The first module to return a nonzero result is the value to be accepted,
- * and any modules after are ignored.
- */
-#define FOREACH_RESULT(y,x) \
-do { \
- EventHandlerIter safei; \
- MOD_RESULT = 0; \
- for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ) \
- { \
- safei = _i; \
- ++safei; \
- try \
- { \
- int res = (*_i)->x ; \
- if (res != 0) { \
- MOD_RESULT = res; \
- break; \
- } \
- } \
- catch (CoreException& modexcept) \
- { \
- ServerInstance->Logs->Log("MODULE",DEFAULT,"Exception caught: %s",modexcept.GetReason()); \
- } \
- _i = safei; \
- } \
-} while(0);
-
-
-/**
- * This define is similar to the one above but returns a result in MOD_RESULT.
- * The first module to return a nonzero result is the value to be accepted,
- * and any modules after are ignored.
- */
-#define FOREACH_RESULT_I(z,y,x) \
-do { \
- EventHandlerIter safei; \
- MOD_RESULT = 0; \
- for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ) \
- { \
- safei = _i; \
- ++safei; \
- try \
- { \
- int res = (*_i)->x ; \
- if (res != 0) { \
- MOD_RESULT = res; \
- break; \
- } \
- } \
- catch (CoreException& modexcept) \
- { \
- z->Logs->Log("MODULE",DEBUG,"Exception caught: %s",modexcept.GetReason()); \
- } \
- _i = safei; \
- } \
-} while (0);
-