diff options
author | Adam <Adam@anope.org> | 2013-05-27 19:36:37 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-27 19:36:37 -0400 |
commit | 37b3535543b81c3d75c8f62b83d422f0d2fbced0 (patch) | |
tree | 8a062415c91d352e4b6bd180cbf238d1f159802d | |
parent | c21e8d9204f9b671177a63d4daa21957bffc1d9f (diff) |
Initially attach all modules to all events, and detach them as the events are run if they are not implemented per module
120 files changed, 440 insertions, 672 deletions
diff --git a/include/modules.h b/include/modules.h index 3f99a9114..5463c2ad6 100644 --- a/include/modules.h +++ b/include/modules.h @@ -56,49 +56,56 @@ /** * This #define allows us to call a method in all * loaded modules in a readable simple way, e.g.: - * 'FOREACH_MOD(I_OnConnect,OnConnect(user));' + * + * FOREACH_MOD(OnUserConnect, (user, exempt)); */ -#define FOREACH_MOD(y, x) \ +#define FOREACH_MOD(ename, args) \ if (true) \ { \ - std::vector<Module *>::iterator safei; \ - for (std::vector<Module *>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \ + static std::vector<Module *> &_modules = ModuleManager::GetEventHandlers(#ename); \ + for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \ { \ - safei = _i; \ - ++safei; \ try \ { \ - (*_i)->x ; \ + (*_i)->ename args; \ } \ catch (const ModuleException &modexcept) \ { \ Log() << "Exception caught: " << modexcept.GetReason(); \ } \ - _i = safei; \ + catch (const NotImplementedException &) \ + { \ + Log(LOG_DEBUG_2) << "Detaching event " << #ename << " from " << (*_i)->name; \ + _i = _modules.erase(_i); \ + continue; \ + } \ + ++_i; \ } \ } \ else \ static_cast<void>(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. + * This define is similar to the one above but returns a result. + * The first module to return a result other than EVENT_CONTINUE is the value to be accepted, + * and any modules after are ignored. This is used like: + * + * EventReturn MOD_RESULT; + * FOREACH_RESULT(OnUserConnect, MOD_RESULT, (user, exempt)); */ -#define FOREACH_RESULT(y, x) \ +#define FOREACH_RESULT(ename, ret, args) \ if (true) \ { \ - std::vector<Module *>::iterator safei; \ - MOD_RESULT = EVENT_CONTINUE; \ - for (std::vector<Module *>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \ + ret = EVENT_CONTINUE; \ + static std::vector<Module *> &_modules = ModuleManager::GetEventHandlers(#ename); \ + for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \ { \ - safei = _i; \ - ++safei; \ try \ { \ - EventReturn res = (*_i)->x ; \ - if (res != EVENT_CONTINUE) { \ - MOD_RESULT = res; \ + EventReturn res = (*_i)->ename args; \ + if (res != EVENT_CONTINUE) \ + { \ + ret = res; \ break; \ } \ } \ @@ -106,12 +113,19 @@ if (true) \ { \ Log() << "Exception caught: " << modexcept.GetReason(); \ } \ - _i = safei; \ + catch (const NotImplementedException &) \ + { \ + Log(LOG_DEBUG_2) << "Detaching event " << #ename << " from " << (*_i)->name; \ + _i = _modules.erase(_i); \ + continue; \ + } \ + ++_i; \ } \ } \ else \ static_cast<void>(0) + /** Possible return types from events. */ enum EventReturn @@ -195,6 +209,7 @@ class ModuleVersion int GetPatch() const; }; +class NotImplementedException : public CoreException { }; /** Every module in Anope is actually a class. */ @@ -281,7 +296,7 @@ class CoreExport Module : public Extensible * @param cu The user, channel, and status of the user being kicked * @param kickmsg The reason for the kick. */ - virtual void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) { } + virtual void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) { throw NotImplementedException(); } /** Called when a user has been kicked from a channel. * @param source The kicker @@ -290,13 +305,13 @@ class CoreExport Module : public Extensible * @param status The status the kicked user had on the channel before they were kicked * @param kickmsg The reason for the kick. */ - virtual void OnUserKicked(MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { } + virtual void OnUserKicked(MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); } /** Called when Services' configuration is being (re)loaded. * @param conf The config that is being built now and will replace the global Config object * @throws A ConfigException to abort the config (re)loading process. */ - virtual void OnReload(Configuration::Conf *conf) { } + virtual void OnReload(Configuration::Conf *conf) { throw NotImplementedException(); } /** Called before a bot is assigned to a channel. * @param sender The user assigning the bot @@ -304,48 +319,48 @@ class CoreExport Module : public Extensible * @param bi The bot being assigned. * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the assign. */ - virtual EventReturn OnPreBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { return EVENT_CONTINUE; } + virtual EventReturn OnPreBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); } /** Called when a bot is assigned ot a channel */ - virtual void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { } + virtual void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); } /** Called before a bot is unassigned from a channel. * @param sender The user unassigning the bot * @param ci The channel the bot is being removed from * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the unassign. */ - virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { return EVENT_CONTINUE; } + virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { throw NotImplementedException(); } /** Called when a new user connects to the network. * @param u The connecting user. * @param exempt set to true/is true if the user should be excepted from bans etc */ - virtual void OnUserConnect(User *u, bool &exempt) { } + virtual void OnUserConnect(User *u, bool &exempt) { throw NotImplementedException(); } /** Called when a new server connects to the network. * @param s The server that has connected to the network */ - virtual void OnNewServer(Server *s) { } + virtual void OnNewServer(Server *s) { throw NotImplementedException(); } /** Called after a user changed the nick * @param u The user. * @param oldnick The old nick of the user */ - virtual void OnUserNickChange(User *u, const Anope::string &oldnick) { } + virtual void OnUserNickChange(User *u, const Anope::string &oldnick) { throw NotImplementedException(); } /** Called when someone uses the generic/help command * @param source Command source * @param params Params * @return EVENT_STOP to stop processing */ - virtual EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) { return EVENT_CONTINUE; } + virtual EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); } /** Called when someone uses the generic/help command * @param source Command source * @param params Params */ - virtual void OnPostHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) { } + virtual void OnPostHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); } /** Called before a command is due to be executed. * @param source The source of the command @@ -353,29 +368,29 @@ class CoreExport Module : public Extensible * @param params The parameters the user is sending * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) { return EVENT_CONTINUE; } + virtual EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) { throw NotImplementedException(); } /** Called after a command has been executed. * @param source The source of the command * @param command The command the user executed * @param params The parameters the user sent */ - virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) { } + virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); } /** Called when the databases are saved */ - virtual void OnSaveDatabase() { } + virtual void OnSaveDatabase() { throw NotImplementedException(); } /** Called when the databases are loaded * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop */ - virtual EventReturn OnLoadDatabase() { return EVENT_CONTINUE; } + virtual EventReturn OnLoadDatabase() { throw NotImplementedException(); } /** Called when anope needs to check passwords against encryption * see src/encrypt.c for detailed informations */ - virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) { return EVENT_CONTINUE; } - virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) { return EVENT_CONTINUE; } + virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); } + virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); } /** Called on fantasy command * @param source The source of the command @@ -384,7 +399,7 @@ class CoreExport Module : public Extensible * @param params The params * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed */ - virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { return EVENT_CONTINUE; } + virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); } /** Called on fantasy command without access * @param source The source of the command @@ -393,31 +408,31 @@ class CoreExport Module : public Extensible * @param params The params * @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed */ - virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { return EVENT_CONTINUE; } + virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); } /** Called when a bot places a ban * @param u User being banned * @param ci Channel the ban is placed on * @param mask The mask being banned */ - virtual void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) { } + virtual void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) { throw NotImplementedException(); } /** Called before a badword is added to the badword list * @param ci The channel * @param bw The badword */ - virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { } + virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); } /** Called before a badword is deleted from a channel * @param ci The channel * @param bw The badword */ - virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { } + virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); } /** Called when a bot is created or destroyed */ - virtual void OnCreateBot(BotInfo *bi) { } - virtual void OnDelBot(BotInfo *bi) { } + virtual void OnCreateBot(BotInfo *bi) { throw NotImplementedException(); } + virtual void OnDelBot(BotInfo *bi) { throw NotImplementedException(); } /** Called before a bot kicks a user * @param bi The bot sending the kick @@ -426,7 +441,7 @@ class CoreExport Module : public Extensible * @param reason The reason * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnBotKick(BotInfo *bi, Channel *c, User *u, const Anope::string &reason) { return EVENT_CONTINUE; } + virtual EventReturn OnBotKick(BotInfo *bi, Channel *c, User *u, const Anope::string &reason) { throw NotImplementedException(); } /** Called before a user parts a channel * @param u The user @@ -440,90 +455,90 @@ class CoreExport Module : public Extensible * @param channel The channel name * @param msg The part reason */ - virtual void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) { } + virtual void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) { throw NotImplementedException(); } /** Called when a user leaves a channel. * From either parting, being kicked, or quitting/killed! * @param u The user * @param c The channel */ - virtual void OnLeaveChannel(User *u, Channel *c) { } + virtual void OnLeaveChannel(User *u, Channel *c) { throw NotImplementedException(); } /** Called when a user joins a channel * @param u The user * @param channel The channel */ - virtual void OnJoinChannel(User *u, Channel *c) { } + virtual void OnJoinChannel(User *u, Channel *c) { throw NotImplementedException(); } /** Called when a new topic is set * @param c The channel * @param setter The user who set the new topic * @param topic The new topic */ - virtual void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) { } + virtual void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) { throw NotImplementedException(); } /** Called before a channel expires * @param ci The channel * @param expire Set to true to allow the chan to expire */ - virtual void OnPreChanExpire(ChannelInfo *ci, bool &expire) { } + virtual void OnPreChanExpire(ChannelInfo *ci, bool &expire) { throw NotImplementedException(); } /** Called before a channel expires * @param ci The channel */ - virtual void OnChanExpire(ChannelInfo *ci) { } + virtual void OnChanExpire(ChannelInfo *ci) { throw NotImplementedException(); } /** Called before Anope connecs to its uplink */ - virtual void OnPreServerConnect() { } + virtual void OnPreServerConnect() { throw NotImplementedException(); } /** Called when Anope connects to its uplink */ - virtual void OnServerConnect() { } + virtual void OnServerConnect() { throw NotImplementedException(); } /** Called when we are almost done synching with the uplink, just before we send the EOB */ - virtual void OnPreUplinkSync(Server *serv) { } + virtual void OnPreUplinkSync(Server *serv) { throw NotImplementedException(); } /** Called when Anope disconnects from its uplink, before it tries to reconnect */ - virtual void OnServerDisconnect() { } + virtual void OnServerDisconnect() { throw NotImplementedException(); } /** Called when services restart */ - virtual void OnRestart() { } + virtual void OnRestart() { throw NotImplementedException(); } /** Called when services shutdown */ - virtual void OnShutdown() { } + virtual void OnShutdown() { throw NotImplementedException(); } /** Called before a nick expires * @param na The nick * @param expire Set to true to allow the nick to expire */ - virtual void OnPreNickExpire(NickAlias *na, bool &expire) { } + virtual void OnPreNickExpire(NickAlias *na, bool &expire) { throw NotImplementedException(); } /** Called when a nick drops * @param na The nick */ - virtual void OnNickExpire(NickAlias *na) { } + virtual void OnNickExpire(NickAlias *na) { throw NotImplementedException(); } /** Called when defcon level changes * @param level The level */ - virtual void OnDefconLevel(int level) { } + virtual void OnDefconLevel(int level) { throw NotImplementedException(); } /** Called after an exception has been added * @param ex The exception * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnExceptionAdd(Exception *ex) { return EVENT_CONTINUE; } + virtual EventReturn OnExceptionAdd(Exception *ex) { throw NotImplementedException(); } /** Called before an exception is deleted * @param source The source deleting it * @param ex The exceotion */ - virtual void OnExceptionDel(CommandSource &source, Exception *ex) { } + virtual void OnExceptionDel(CommandSource &source, Exception *ex) { throw NotImplementedException(); } /** Called before a XLine is added * @param source The source of the XLine @@ -531,31 +546,31 @@ class CoreExport Module : public Extensible * @param xlm The xline manager it was added to * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it */ - virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; } + virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); } /** Called before a XLine is deleted * @param source The source of the XLine * @param x The XLine * @param xlm The xline manager it was deleted from */ - virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { } + virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); } /** Called when a user is checked for whether they are a services oper * @param u The user * @return EVENT_ALLOW to allow, anything else to deny */ - virtual EventReturn IsServicesOper(User *u) { return EVENT_CONTINUE; } + virtual EventReturn IsServicesOper(User *u) { throw NotImplementedException(); } /** Called when a server quits * @param server The server */ - virtual void OnServerQuit(Server *server) { } + virtual void OnServerQuit(Server *server) { throw NotImplementedException(); } /** Called when a user quits, or is killed * @param u The user * @param msg The quit message */ - virtual void OnUserQuit(User *u, const Anope::string &msg) { } + virtual void OnUserQuit(User *u, const Anope::string &msg) { throw NotImplementedException(); } /** Called when a user is quit, before and after being internally removed from * This is different from OnUserQuit, which takes place at the time of the quit. @@ -563,43 +578,43 @@ class CoreExport Module : public Extensible * all lists (channels, user list, etc) * @param u The user */ - virtual void OnPreUserLogoff(User *u) { } - virtual void OnPostUserLogoff(User *u) { } + virtual void OnPreUserLogoff(User *u) { throw NotImplementedException(); } + virtual void OnPostUserLogoff(User *u) { throw NotImplementedException(); } /** Called when a new bot is made * @param bi The bot */ - virtual void OnBotCreate(BotInfo *bi) { } + virtual void OnBotCreate(BotInfo *bi) { throw NotImplementedException(); } /** Called when a bot is changed * @param bi The bot */ - virtual void OnBotChange(BotInfo *bi) { } + virtual void OnBotChange(BotInfo *bi) { throw NotImplementedException(); } /** Called when a bot is deleted * @param bi The bot */ - virtual void OnBotDelete(BotInfo *bi) { } + virtual void OnBotDelete(BotInfo *bi) { throw NotImplementedException(); } /** Called when access is deleted from a channel * @param ci The channel * @param source The source of the command * @param access The access entry being removed */ - virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { } + virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { throw NotImplementedException(); } /** Called when access is added * @param ci The channel * @param source The source of the command * @param access The access changed */ - virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { } + virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { throw NotImplementedException(); } /** Called when the access list is cleared * @param ci The channel * @param u The user who cleared the access */ - virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) { } + virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) { throw NotImplementedException(); } /** Called when a level for a channel is changed * @param source The source of the command @@ -607,62 +622,62 @@ class CoreExport Module : public Extensible * @param priv The privilege changed * @param what The new level */ - virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) { } + virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) { throw NotImplementedException(); } /** Called right before a channel is dropped * @param ci The channel */ - virtual void OnChanDrop(ChannelInfo *ci) { } + virtual void OnChanDrop(ChannelInfo *ci) { throw NotImplementedException(); } /** Called when a channel is registered * @param ci The channel */ - virtual void OnChanRegistered(ChannelInfo *ci) { } + virtual void OnChanRegistered(ChannelInfo *ci) { throw NotImplementedException(); } /** Called when a channel is suspended * @param ci The channel */ - virtual void OnChanSuspend(ChannelInfo *ci) { } + virtual void OnChanSuspend(ChannelInfo *ci) { throw NotImplementedException(); } /** Called when a channel is unsuspended * @param ci The channel */ - virtual void OnChanUnsuspend(ChannelInfo *ci) { } + virtual void OnChanUnsuspend(ChannelInfo *ci) { throw NotImplementedException(); } /** Called when a channel is being created, for any reason * @param ci The channel */ - virtual void OnCreateChan(ChannelInfo *ci) { } + virtual void OnCreateChan(ChannelInfo *ci) { throw NotImplementedException(); } /** Called when a channel is being deleted, for any reason * @param ci The channel */ - virtual void OnDelChan(ChannelInfo *ci) { } + virtual void OnDelChan(ChannelInfo *ci) { throw NotImplementedException(); } /** Called when a new channel is created * Note that this channel may not be introduced to the uplink at this point. * @param c The channel */ - virtual void OnChannelCreate(Channel *c) { } + virtual void OnChannelCreate(Channel *c) { throw NotImplementedException(); } /** Called when a channel is deleted * @param c The channel */ - virtual void OnChannelDelete(Channel *c) { } + virtual void OnChannelDelete(Channel *c) { throw NotImplementedException(); } /** Called after adding an akick to a channel * @param source The source of the command * @param ci The channel * @param ak The akick */ - virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { } + virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { throw NotImplementedException(); } /** Called before removing an akick from a channel * @param source The source of the command * @param ci The channel * @param ak The akick */ - virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { } + virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { throw NotImplementedException(); } /** Called after a user join a channel when we decide whether to kick them or not * @param u The user @@ -672,7 +687,7 @@ class CoreExport Module : public Extensible * @param reason The reason for the kick * @return EVENT_STOP to prevent the user from joining by kicking/banning the user */ - virtual EventReturn OnCheckKick(User *u, ChannelInfo *ci, Anope::string &mask, Anope::string &reason) { return EVENT_CONTINUE; } + virtual EventReturn OnCheckKick(User *u, ChannelInfo *ci, Anope::string &mask, Anope::string &reason) { throw NotImplementedException(); } /** Called when a user requests info for a channel * @param source The user requesting info @@ -680,124 +695,124 @@ class CoreExport Module : public Extensible * @param info Data to show the user requesting information * @param show_hidden true if we should show the user everything */ - virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) { } + virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) { throw NotImplementedException(); } /** Checks if access has the channel privilege 'priv'. * @param access THe access struct * @param priv The privilege being checked for * @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing */ - virtual EventReturn OnCheckPriv(ChanAccess *access, const Anope::string &priv) { return EVENT_CONTINUE; } + virtual EventReturn OnCheckPriv(ChanAccess *access, const Anope::string &priv) { throw NotImplementedException(); } /** Check whether an access group has a privilege * @param group The group * @param priv The privilege * @return MOD_ALLOW to allow, MOD_STOP to stop */ - virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) { return EVENT_CONTINUE; } + virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) { throw NotImplementedException(); } /** Called when a nick is dropped * @param source The source of the command * @param na The nick */ - virtual void OnNickDrop(CommandSource &source, NickAlias *na) { } + virtual void OnNickDrop(CommandSource &source, NickAlias *na) { throw NotImplementedException(); } /** Called when a nick is forbidden * @param na The nick alias of the forbidden nick */ - virtual void OnNickForbidden(NickAlias *na) { } + virtual void OnNickForbidden(NickAlias *na) { throw NotImplementedException(); } /** Called when a user groups their nick * @param u The user grouping * @param target The target they're grouping to */ - virtual void OnNickGroup(User *u, NickAlias *target) { } + virtual void OnNickGroup(User *u, NickAlias *target) { throw NotImplementedException(); } /** Called when a user identifies to a nick * @param u The user */ - virtual void OnNickIdentify(User *u) { } + virtual void OnNickIdentify(User *u) { throw NotImplementedException(); } /** Called when a user is logged into an account * @param u The user */ - virtual void OnUserLogin(User *u) { } + virtual void OnUserLogin(User *u) { throw NotImplementedException(); } /** Called when a nick logs out * @param u The nick */ - virtual void OnNickLogout(User *u) { } + virtual void OnNickLogout(User *u) { throw NotImplementedException(); } /** Called when a nick is registered * @param user The user registering the nick, of any * @param The nick */ - virtual void OnNickRegister(User *user, NickAlias *na) { } + virtual void OnNickRegister(User *user, NickAlias *na) { throw NotImplementedException(); } /** Called when a nick is suspended * @param na The nick alias */ - virtual void OnNickSuspend(NickAlias *na) { } + virtual void OnNickSuspend(NickAlias *na) { throw NotImplementedException(); } /** Called when a nick is unsuspneded * @param na The nick alias */ - virtual void OnNickUnsuspended(NickAlias *na) { } + virtual void OnNickUnsuspended(NickAlias *na) { throw NotImplementedException(); } /** Called on delnick() * @ param na pointer to the nickalias */ - virtual void OnDelNick(NickAlias *na) { } + virtual void OnDelNick(NickAlias *na) { throw NotImplementedException(); } /** Called when a nickcore is created * @param nc The nickcore */ - virtual void OnNickCoreCreate(NickCore *nc) { } + virtual void OnNickCoreCreate(NickCore *nc) { throw NotImplementedException(); } /** Called on delcore() * @param nc pointer to the NickCore */ - virtual void OnDelCore(NickCore *nc) { } + virtual void OnDelCore(NickCore *nc) { throw NotImplementedException(); } /** Called on change_core_display() * @param nc pointer to the NickCore * @param newdisplay the new display */ - virtual void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) { } + virtual void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) { throw NotImplementedException(); } /** called from NickCore::ClearAccess() * @param nc pointer to the NickCore */ - virtual void OnNickClearAccess(NickCore *nc) { } + virtual void OnNickClearAccess(NickCore *nc) { throw NotImplementedException(); } /** Called when a user adds an entry to their access list * @param nc The nick * @param entry The entry */ - virtual void OnNickAddAccess(NickCore *nc, const Anope::string &entry) { } + virtual void OnNickAddAccess(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); } /** Called from NickCore::EraseAccess() * @param nc pointer to the NickCore * @param entry The access mask */ - virtual void OnNickEraseAccess(NickCore *nc, const Anope::string &entry) { } + virtual void OnNickEraseAccess(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); } /** called from NickCore::ClearCert() * @param nc pointer to the NickCore */ - virtual void OnNickClearCert(NickCore *nc) { } + virtual void OnNickClearCert(NickCore *nc) { throw NotImplementedException(); } /** Called when a user adds an entry to their cert list * @param nc The nick * @param entry The entry */ - virtual void OnNickAddCert(NickCore *nc, const Anope::string &entry) { } + virtual void OnNickAddCert(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); } /** Called from NickCore::EraseCert() * @param nc pointer to the NickCore * @param entry The fingerprint */ - virtual void OnNickEraseCert(NickCore *nc, const Anope::string &entry) { } + virtual void OnNickEraseCert(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); } /** Called when a user requests info for a nick * @param source The user requesting info @@ -805,46 +820,46 @@ class CoreExport Module : public Extensible * @param info Data to show the user requesting information * @param show_hidden true if we should show the user everything */ - virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) { } + virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) { throw NotImplementedException(); } /** Check whether a username and password is correct * @param u The user trying to identify, if applicable. * @param req The login request */ - virtual void OnCheckAuthentication(User *u, IdentifyRequest *req) { } + virtual void OnCheckAuthentication(User *u, IdentifyRequest *req) { throw NotImplementedException(); } /** Called when a user does /ns update * @param u The user */ - virtual void OnNickUpdate(User *u) { } + virtual void OnNickUpdate(User *u) { throw NotImplementedException(); } /** Called when we get informed about a users SSL fingerprint * when we call this, the fingerprint should already be stored in the user struct * @param u pointer to the user */ - virtual void OnFingerprint(User *u) { } + virtual void OnFingerprint(User *u) { throw NotImplementedException(); } /** Called when a user becomes (un)away * @param message The message, is .empty() if unaway */ - virtual void OnUserAway(User *u, const Anope::string &message) { } + virtual void OnUserAway(User *u, const Anope::string &message) { throw NotImplementedException(); } /** Called when a user invites one of our users to a channel * @param source The user doing the inviting * @param c The channel the user is inviting to * @param targ The user being invited */ - virtual void OnInvite(User *source, Channel *c, User *targ) { } + virtual void OnInvite(User *source, Channel *c, User *targ) { throw NotImplementedException(); } /** Called when a vhost is deleted * @param na The nickalias of the vhost */ - virtual void OnDeleteVhost(NickAlias *na) { } + virtual void OnDeleteVhost(NickAlias *na) { throw NotImplementedException(); } /** Called when a vhost is set * @param na The nickalias of the vhost */ - virtual void OnSetVhost(NickAlias *na) { } + virtual void OnSetVhost(NickAlias *na) { throw NotImplementedException(); } /** Called when a memo is sent * @param source The source of the memo @@ -852,21 +867,21 @@ class CoreExport Module : public Extensible * @param mi Memo info for target * @param m The memo */ - virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) { } + virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) { throw NotImplementedException(); } /** Called when a memo is deleted * @param nc The nickcore of the memo being deleted * @param mi The memo info * @param m The memo */ - virtual void OnMemoDel(NickCore *nc, MemoInfo *mi, const Memo *m) { } + virtual void OnMemoDel(NickCore *nc, MemoInfo *mi, const Memo *m) { throw NotImplementedException(); } /** Called when a memo is deleted * @param ci The channel of the memo being deleted * @param mi The memo info * @param m The memo */ - virtual void OnMemoDel(ChannelInfo *ci, MemoInfo *mi, const Memo *m) { } + virtual void OnMemoDel(ChannelInfo *ci, MemoInfo *mi, const Memo *m) { throw NotImplementedException(); } /** Called when a mode is set on a channel * @param c The channel @@ -875,7 +890,7 @@ class CoreExport Module : public Extensible * @param param The mode param, if there is one * @return EVENT_STOP to make mlock/secureops etc checks not happen */ - virtual EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) { return EVENT_CONTINUE; } + virtual EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) { throw NotImplementedException(); } /** Called when a mode is unset on a channel * @param c The channel @@ -884,65 +899,65 @@ class CoreExport Module : public Extensible * @param param The mode param, if there is one * @return EVENT_STOP to make mlock/secureops etc checks not happen */ - virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) { return EVENT_CONTINUE; } + virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) { throw NotImplementedException(); } /** Called when a mode is set on a user * @param u The user * @param mname The mode name */ - virtual void OnUserModeSet(User *u, const Anope::string &mname) { } + virtual void OnUserModeSet(User *u, const Anope::string &mname) { throw NotImplementedException(); } /** Called when a mode is unset from a user * @param u The user * @param mname The mode name */ - virtual void OnUserModeUnset(User *u, const Anope::string &mname) { } + virtual void OnUserModeUnset(User *u, const Anope::string &mname) { throw NotImplementedException(); } /** Called when a channel mode is introducted into Anope * @param cm The mode */ - virtual void OnChannelModeAdd(ChannelMode *cm) { } + virtual void OnChannelModeAdd(ChannelMode *cm) { throw NotImplementedException(); } /** Called when a user mode is introducted into Anope * @param um The mode */ - virtual void OnUserModeAdd(UserMode *um) { } + virtual void OnUserModeAdd(UserMode *um) { throw NotImplementedException(); } /** Called when a mode is about to be mlocked * @param ci The channel the mode is being locked on * @param lock The mode lock * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock. */ - virtual EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) { return EVENT_CONTINUE; } + virtual EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) { throw NotImplementedException(); } /** Called when a mode is about to be unlocked * @param ci The channel the mode is being unlocked from * @param lock The mode lock * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock. */ - virtual EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) { return EVENT_CONTINUE; } + virtual EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) { throw NotImplementedException(); } /** Called after a module is loaded * @param u The user loading the module, can be NULL * @param m The module */ - virtual void OnModuleLoad(User *u, Module *m) { } + virtual void OnModuleLoad(User *u, Module *m) { throw NotImplementedException(); } /** Called before a module is unloaded * @param u The user, can be NULL * @param m The module */ - virtual void OnModuleUnload(User *u, Module *m) { } + virtual void OnModuleUnload(User *u, Module *m) { throw NotImplementedException(); } /** Called when a server is synced * @param s The server, can be our uplink server */ - virtual void OnServerSync(Server *s) { } + virtual void OnServerSync(Server *s) { throw NotImplementedException(); } /** Called when we sync with our uplink * @param s Our uplink */ - virtual void OnUplinkSync(Server *s) { } + virtual void OnUplinkSync(Server *s) { throw NotImplementedException(); } /** Called when we receive a PRIVMSG for one of our clients * @param u The user sending the PRIVMSG @@ -950,39 +965,39 @@ class CoreExport Module : public Extensible * @param message The message * @return EVENT_STOP to halt processing */ - virtual EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) { return EVENT_CONTINUE; } + virtual EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) { throw NotImplementedException(); } /** Called when we receive a PRIVMSG for a registered channel we are in * @param u The source of the message * @param c The channel * @param msg The message */ - virtual void OnPrivmsg(User *u, Channel *c, Anope::string &msg) { } + virtual void OnPrivmsg(User *u, Channel *c, Anope::string &msg) { throw NotImplementedException(); } /** Called when a message is logged * @param l The log message */ - virtual void OnLog(Log *l) { } + virtual void OnLog(Log *l) { throw NotImplementedException(); } /** Called when a DNS request (question) is recieved. * @param req The dns request * @param reply The reply that will be sent */ - virtual void OnDnsRequest(DNS::Query &req, DNS::Query *reply) { } + virtual void OnDnsRequest(DNS::Query &req, DNS::Query *reply) { throw NotImplementedException(); } /** Called when a channels modes are being checked to see if they are allowed, * mostly to ensure mlock/+r are set. * @param c The channel * @return EVENT_STOP to stop checking modes */ - virtual EventReturn OnCheckModes(Channel *c) { return EVENT_CONTINUE; } + virtual EventReturn OnCheckModes(Channel *c) { throw NotImplementedException(); } /** Called when a channel is synced. * Channels are synced after a sjoin is finished processing * for a newly created channel to set the correct modes, topic, * set. */ - virtual void OnChannelSync(Channel *c) { } + virtual void OnChannelSync(Channel *c) { throw NotImplementedException(); } /** Called to set the correct modes on the user on the given channel * @param user The user @@ -991,13 +1006,13 @@ class CoreExport Module : public Extensible * @param give_modes If giving modes is desired * @param take_modes If taking modes is desired */ - virtual void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) { } + virtual void OnSetCorrectModes(User *user, Channel *chan, AccessGroup &access, bool &give_modes, bool &take_modes) { throw NotImplementedException(); } - virtual void OnSerializeCheck(Serialize::Type *) { } - virtual void OnSerializableConstruct(Serializable *) { } - virtual void OnSerializableDestruct(Serializable *) { } - virtual void OnSerializableUpdate(Serializable *) { } - virtual void OnSerializeTypeCreate(Serialize::Type *) { } + virtual void OnSerializeCheck(Serialize::Type *) { throw NotImplementedException(); } + virtual void OnSerializableConstruct(Serializable *) { throw NotImplementedException(); } + virtual void OnSerializableDestruct(Serializable *) { throw NotImplementedException(); } + virtual void OnSerializableUpdate(Serializable *) { throw NotImplementedException(); } + virtual void OnSerializeTypeCreate(Serialize::Type *) { throw NotImplementedException(); } /** Called when a chanserv/set command is used * @param source The source of the command @@ -1006,7 +1021,7 @@ class CoreExport Module : public Extensible * @param setting The setting passed to the command. Probably ON/OFF. * @return EVENT_ALLOW to bypass access checks, EVENT_STOP to halt immediately. */ - virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) { return EVENT_CONTINUE; } + virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChannelInfo *ci, const Anope::string &setting) { throw NotImplementedException(); } /** Called when a nickserv/set command is used. * @param source The source of the command @@ -1015,7 +1030,7 @@ class CoreExport Module : public Extensible * @param setting The setting passed to the command. Probably ON/OFF. * @return EVENT_STOP to halt immediately */ - virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickCore *nc, const Anope::string &setting) { return EVENT_CONTINUE; } + virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickCore *nc, const Anope::string &setting) { throw NotImplementedException(); } /** Called whenever a message is received from the uplink * @param source The source of the message @@ -1023,100 +1038,43 @@ class CoreExport Module : public Extensible * @param params Parameters * @return EVENT_STOP to prevent the protocol module from processing this message */ - virtual EventReturn OnMessage(MessageSource &source, Anope::string &command, std::vector<Anope::string> ¶m) { return EVENT_CONTINUE; } + virtual EventReturn OnMessage(MessageSource &source, Anope::string &command, std::vector<Anope::string> ¶m) { throw NotImplementedException(); } /** Called to determine if a chnanel mode can be set by a user * @param u The user * @param cm The mode */ - virtual EventReturn OnCanSet(User *u, const ChannelMode *cm) { return EVENT_CONTINUE; } + virtual EventReturn OnCanSet(User *u, const ChannelMode *cm) { throw NotImplementedException(); } - virtual EventReturn OnCheckDelete(Channel *) { return EVENT_CONTINUE; } + virtual EventReturn OnCheckDelete(Channel *) { throw NotImplementedException(); } /** Called every options:expiretimeout seconds. Should be used to expire nicks, * channels, etc. */ - virtual void OnExpireTick() { } -}; - -/** Implementation-specific flags which may be set in ModuleManager::Attach() - */ -enum Implementation -{ - I_BEGIN, - /* NickServ */ - I_OnPreNickExpire, I_OnNickExpire, I_OnNickForbidden, I_OnNickGroup, I_OnNickLogout, I_OnNickIdentify, I_OnNickDrop, - I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended, I_OnDelNick, I_OnNickCoreCreate, I_OnDelCore, I_OnChangeCoreDisplay, - I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess, I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert, - I_OnNickInfo, I_OnCheckAuthentication, I_OnNickUpdate, I_OnSetNickOption, I_OnUserLogin, - - /* ChanServ */ - I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, - I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate, - I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes, - I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv, I_OnSetChannelOption, I_OnSetCorrectModes, - - /* BotServ */ - I_OnCreateBot, I_OnDelBot, - I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnPreBotAssign, I_OnBotAssign, I_OnBotUnAssign, - I_OnPreUserKicked, I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBadWordAdd, I_OnBadWordDel, - - /* HostServ */ - I_OnSetVhost, I_OnDeleteVhost, - - /* MemoServ */ - I_OnMemoSend, I_OnMemoDel, - - /* Channels */ - I_OnChannelModeSet, I_OnChannelModeUnset, I_OnChannelDelete, I_OnChannelSync, I_OnCheckDelete, - - /* Users */ - I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnPreUserLogoff, I_OnPostUserLogoff, - I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnLeaveChannel, I_OnFingerprint, I_OnUserAway, I_OnInvite, - - /* OperServ */ - I_OnDefconLevel, I_OnAddAkill, I_OnDelAkill, I_OnExceptionAdd, I_OnExceptionDel, - I_OnAddXLine, I_OnDelXLine, I_IsServicesOper, - - /* Database */ - I_OnSaveDatabase, I_OnLoadDatabase, - - /* Modules */ - I_OnModuleLoad, I_OnModuleUnload, - - /* Other */ - I_OnReload, I_OnNewServer, I_OnPreServerConnect, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, - I_OnPreHelp, I_OnPostHelp, I_OnPreCommand, I_OnPostCommand, I_OnRestart, I_OnShutdown, - I_OnServerQuit, I_OnTopicUpdated, - I_OnEncrypt, I_OnDecrypt, - I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd, - I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog, I_OnDnsRequest, - I_OnMessage, I_OnCanSet, I_OnExpireTick, - - I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate, I_OnSerializeTypeCreate, - I_END + virtual void OnExpireTick() { throw NotImplementedException(); } }; /** Used to manage modules. */ class CoreExport ModuleManager { + /** Event handler hooks. + */ + static std::map<Anope::string, std::vector<Module *> > EventHandlers; + public: /** List of all modules loaded in Anope */ static std::list<Module *> Modules; - /** Event handler hooks. - * This needs to be public to be used by FOREACH_MOD and friends. - */ - static std::vector<Module *> EventHandlers[I_END]; - #ifdef _WIN32 /** Clean up the module runtime directory */ static void CleanupRuntimeDirectory(); #endif + static std::vector<Module *> &GetEventHandlers(const Anope::string &name); + /** Loads a given module. * @param m the module to load * @param u the user who loaded it, NULL for auto-load @@ -1166,7 +1124,7 @@ class CoreExport ModuleManager * @param sz The number of modules being passed for PRIO_BEFORE and PRIO_AFTER. Defaults to 1, as most of the time you will only want to prioritize your module * to be before or after one other module. */ - static bool SetPriority(Module *mod, Implementation i, Priority s, Module **modules = NULL, size_t sz = 1); + static bool SetPriority(Module *mod, const Anope::string &event, Priority s, Module **modules = NULL, size_t sz = 1); /** Change the priority of all events in a module. * @param mod The module to set the priority of @@ -1176,33 +1134,11 @@ class CoreExport ModuleManager */ static bool SetPriority(Module *mod, Priority s); - /** Attach an event to a module. - * You may later detatch the event with ModuleManager::Detach(). If your module is unloaded, all events are automatically detatched. - * @param i Event type to attach - * @param mod Module to attach event to - * @return True if the event was attached - */ - static bool Attach(Implementation i, Module *mod); - - /** Detatch an event from a module. - * This is not required when your module unloads, as the core will automatically detatch your module from all events it is attached to. - * @param i Event type to detach - * @param mod Module to detach event from - * @param Detach true if the event was detached - */ - static bool Detach(Implementation i, Module *mod); - /** Detach all events from a module (used on unload) * @param mod Module to detach from */ static void DetachAll(Module *mod); - /** Attach an array of events to a module - * @param i Event types (array) to attach - * @param mod Module to attach events to - */ - static void Attach(Implementation *i, Module *mod, size_t sz); - /** Unloading all modules except the protocol module. */ static void UnloadAll(); diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp index ae60f5b5a..41aecd8af 100644 --- a/modules/bs_autoassign.cpp +++ b/modules/bs_autoassign.cpp @@ -14,8 +14,6 @@ class BSAutoAssign : public Module public: BSAutoAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) { - Implementation i[] = { I_OnChanRegistered }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnChanRegistered(ChannelInfo *ci) anope_override diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index 9a0b638c7..7b241f09e 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -154,8 +154,6 @@ class BSAssign : public Module BSAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandbsassign(this), commandbsunassign(this) { - Implementation i[] = { I_OnInvite }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnInvite(User *source, Channel *c, User *targ) anope_override diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index aa3cf378d..020044aef 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -81,7 +81,7 @@ class CommandBSBot : public Command source.Reply(_("%s!%s@%s (%s) added to the bot list."), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); - FOREACH_MOD(I_OnBotCreate, OnBotCreate(bi)); + FOREACH_MOD(OnBotCreate, (bi)); return; } @@ -220,7 +220,7 @@ class CommandBSBot : public Command source.Reply(_("Bot \002%s\002 has been changed to %s!%s@%s (%s)."), oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; - FOREACH_MOD(I_OnBotChange, OnBotChange(bi)); + FOREACH_MOD(OnBotChange, (bi)); return; } @@ -247,7 +247,7 @@ class CommandBSBot : public Command return; } - FOREACH_MOD(I_OnBotDelete, OnBotDelete(bi)); + FOREACH_MOD(OnBotDelete, (bi)); Log(LOG_ADMIN, source, this) << "DEL " << bi->nick; diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 4b869421d..50d4a0e5f 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -771,7 +771,7 @@ class BSKick : public Module Anope::string mask = ci->GetIdealBan(u); ci->c->SetMode(NULL, "BAN", mask); - FOREACH_MOD(I_OnBotBan, OnBotBan(u, ci, mask)); + FOREACH_MOD(OnBotBan, (u, ci, mask)); } } @@ -802,8 +802,6 @@ class BSKick : public Module { me = this; - Implementation i[] = { I_OnPrivmsg }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~BSKick() diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index 95500ac94..fa2bd716f 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -495,7 +495,6 @@ class BSSet : public Module commandbsset(this), commandbssetbanexpire(this), commandbssetdontkickops(this), commandbssetdontkickvoices(this), commandbssetfantasy(this), commandbssetgreet(this), commandbssetnobot(this), commandbssetprivate(this) { - ModuleManager::Attach(I_OnBotBan, this); } void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) anope_override diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 64b2386fb..8562efeb4 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -175,7 +175,7 @@ class CommandCSAccess : public Command access->created = Anope::CurTime; ci->AddAccess(access); - FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access)); + FOREACH_MOD(OnAccessAdd, (ci, source, access)); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level; source.Reply(_("\002%s\002 added to %s access list at level \002%d\002."), access->mask.c_str(), ci->name.c_str(), level); @@ -258,7 +258,7 @@ class CommandCSAccess : public Command else Nicks = access->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); + FOREACH_MOD(OnAccessDel, (ci, source, access)); ci->EraseAccess(Number - 1); } @@ -284,7 +284,7 @@ class CommandCSAccess : public Command bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); + FOREACH_MOD(OnAccessDel, (ci, source, access)); delete access; } return; @@ -429,7 +429,7 @@ class CommandCSAccess : public Command source.Reply(ACCESS_DENIED); else { - FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source)); + FOREACH_MOD(OnAccessClear, (ci, source)); ci->ClearAccess(); @@ -597,7 +597,7 @@ class CommandCSLevels : public Command else { ci->SetLevel(p->name, level); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, level)); + FOREACH_MOD(OnLevelChange, (source, ci, p->name, level)); bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; @@ -621,7 +621,7 @@ class CommandCSLevels : public Command if (p != NULL) { ci->SetLevel(p->name, ACCESS_INVALID); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, ACCESS_INVALID)); + FOREACH_MOD(OnLevelChange, (source, ci, p->name, ACCESS_INVALID)); bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name; @@ -673,7 +673,7 @@ class CommandCSLevels : public Command void DoReset(CommandSource &source, ChannelInfo *ci) { reset_levels(ci); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, "ALL", 0)); + FOREACH_MOD(OnLevelChange, (source, ci, "ALL", 0)); bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels"; @@ -791,8 +791,6 @@ class CSAccess : public Module { this->SetPermanent(true); - Implementation i[] = { I_OnReload, I_OnCreateChan, I_OnGroupCheckPriv }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 1cce6afbe..b54fca191 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -160,7 +160,7 @@ class CommandCSAKick : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; - FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(source, ci, akick)); + FOREACH_MOD(OnAkickAdd, (source, ci, akick)); source.Reply(_("\002%s\002 added to %s autokick list."), mask.c_str(), ci->name.c_str()); @@ -210,7 +210,7 @@ class CommandCSAKick : public Command if (!number || number > ci->GetAkickCount()) return; - FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(number - 1))); + FOREACH_MOD(OnAkickDel, (source, ci, ci->GetAkick(number - 1))); ++deleted; ci->EraseAkick(number - 1); @@ -241,7 +241,7 @@ class CommandCSAKick : public Command bool override = !source.AccessFor(ci).HasPriv("AKICK"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; - FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(i))); + FOREACH_MOD(OnAkickDel, (source, ci, ci->GetAkick(i))); ci->EraseAkick(i); @@ -512,8 +512,6 @@ class CSAKick : public Module CSAKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsakick(this) { - Implementation i[] = { I_OnCheckKick }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnCheckKick(User *u, ChannelInfo *ci, Anope::string &mask, Anope::string &reason) anope_override diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index d7045123f..d9ba97894 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -85,7 +85,7 @@ public: else target_ci->last_topic_setter = source.service->nick; - FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(target_ci)); + FOREACH_MOD(OnChanRegistered, (target_ci)); source.Reply(_("All settings from \002%s\002 have been cloned to \002%s\002."), channel.c_str(), target.c_str()); } diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index 998dd8ab0..3f14aea65 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -52,7 +52,7 @@ class CommandCSDrop : public Command bool override = (ci->HasExt("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")"; - FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci)); + FOREACH_MOD(OnChanDrop, (ci)); Reference<Channel> c = ci->c; delete ci; diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index c5e31f122..f94aca44c 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -272,8 +272,6 @@ class CSEntryMessage : public Module CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), entrymsg_type("EntryMsg", EntryMsg::Unserialize), commandentrymsg(this) { - Implementation i[] = { I_OnJoinChannel }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnJoinChannel(User *u, Channel *c) anope_override diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index a7324bf9f..d54ed4a92 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -71,8 +71,6 @@ class CSStats : public Module { me = this; - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index ca2e67ab9..bc08c4c9d 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -96,8 +96,6 @@ class CSTop : public Module { me = this; - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index 4867b9029..23e6914d3 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -178,7 +178,7 @@ class CommandCSFlags : public Command { if (current != NULL) { - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, current)); + FOREACH_MOD(OnAccessDel, (ci, source, current)); delete current; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; source.Reply(_("\002%s\002 removed from the %s access list."), mask.c_str(), ci->name.c_str()); @@ -206,7 +206,7 @@ class CommandCSFlags : public Command ci->AddAccess(access); - FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access)); + FOREACH_MOD(OnAccessAdd, (ci, source, access)); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->AccessSerialize(); source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->AccessSerialize().c_str()); @@ -285,7 +285,7 @@ class CommandCSFlags : public Command { ci->ClearAccess(); - FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source)); + FOREACH_MOD(OnAccessClear, (ci, source)); source.Reply(_("Channel %s access list has been cleared."), ci->name.c_str()); @@ -391,8 +391,6 @@ class CSFlags : public Module { this->SetPermanent(true); - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, 1); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index 3f9a014bb..0d3623c00 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -105,7 +105,7 @@ class CommandCSInfo : public Command info["Expires on"] = Anope::strftime(ci->last_used + chanserv_expire); } - FOREACH_MOD(I_OnChanInfo, OnChanInfo(source, ci, info, show_all)); + FOREACH_MOD(OnChanInfo, (source, ci, info, show_all)); std::vector<Anope::string> replies; info.Process(replies); diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index a7987a740..969ebe5ab 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -186,8 +186,6 @@ class CSLog : public Module MSService("MemoServService", "MemoServ"), commandcslog(this) { - Implementation i[] = { I_OnLog }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnLog(Log *l) anope_override diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index 4d4bc9353..135f833be 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -75,7 +75,7 @@ class CommandCSRegister : public Command c->SetCorrectModes(u, true); } - FOREACH_MOD(I_OnChanRegistered, OnChanRegistered(ci)); + FOREACH_MOD(OnChanRegistered, (ci)); } } diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index aacd3c168..877fc31b7 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -296,15 +296,6 @@ class CSSeen : public Module public: CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this) { - - Implementation eventlist[] = { I_OnExpireTick, - I_OnUserConnect, - I_OnUserNickChange, - I_OnUserQuit, - I_OnJoinChannel, - I_OnPartChannel, - I_OnPreUserKicked }; - ModuleManager::Attach(eventlist, this, sizeof(eventlist) / sizeof(Implementation)); } void OnExpireTick() anope_override diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 45373e254..1211c5ed0 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -73,7 +73,7 @@ class CommandCSSetAutoOp : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -130,7 +130,7 @@ class CommandCSSetBanType : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -191,7 +191,7 @@ class CommandCSSetChanstats : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -245,7 +245,7 @@ class CommandCSSetDescription : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -300,7 +300,7 @@ class CommandCSSetFounder : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -363,7 +363,7 @@ class CommandCSSetKeepTopic : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -420,7 +420,7 @@ class CommandCSSetPeace : public Command return; } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -479,7 +479,7 @@ class CommandCSSetPersist : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -627,7 +627,7 @@ class CommandCSSetPrivate : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -689,7 +689,7 @@ class CommandCSSetRestricted : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -745,7 +745,7 @@ class CommandCSSetSecure : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -803,7 +803,7 @@ class CommandCSSetSecureFounder : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -861,7 +861,7 @@ class CommandCSSetSecureOps : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -917,7 +917,7 @@ class CommandCSSetSignKick : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -988,7 +988,7 @@ class CommandCSSetSuccessor : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -1128,10 +1128,6 @@ class CSSet : public Module commandcssetsecure(this), commandcssetsecurefounder(this), commandcssetsecureops(this), commandcssetsignkick(this), commandcssetsuccessor(this), commandcssetnoexpire(this) { - - Implementation i[] = { I_OnCheckKick, I_OnDelChan, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnCheckDelete, I_OnJoinChannel, - I_OnSetCorrectModes }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnCheckKick(User *u, ChannelInfo *ci, Anope::string &mask, Anope::string &reason) anope_override diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 5f1359f18..21ebec815 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -85,7 +85,7 @@ class CommandCSSetMisc : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, params[1])); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); if (MOD_RESULT == EVENT_STOP) return; @@ -136,8 +136,6 @@ class CSSetMisc : public Module CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), csmiscdata_type("CSMiscData", CSMiscData::Unserialize), commandcssetmisc(this) { - Implementation i[] = { I_OnReload, I_OnChanInfo }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 88a369e58..98015a1f3 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -74,7 +74,7 @@ class CommandCSSuspend : public Command Log(LOG_ADMIN, source, this, ci) << (!reason.empty() ? reason : "No reason") << ", expires in " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Channel \002%s\002 is now suspended."), ci->name.c_str()); - FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); + FOREACH_MOD(OnChanSuspend, (ci)); return; } @@ -136,7 +136,7 @@ class CommandCSUnSuspend : public Command source.Reply(_("Channel \002%s\002 is now released."), ci->name.c_str()); - FOREACH_MOD(I_OnChanUnsuspend, OnChanUnsuspend(ci)); + FOREACH_MOD(OnChanUnsuspend, (ci)); return; } @@ -161,8 +161,6 @@ class CSSuspend : public Module commandcssuspend(this), commandcsunsuspend(this) { - Implementation i[] = { I_OnChanInfo, I_OnPreChanExpire, I_OnCheckKick }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) anope_override diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index 64e710017..294689864 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -16,7 +16,7 @@ class CommandCSTopic : public Command void Lock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, "topiclock on")); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, "topiclock on")); if (MOD_RESULT == EVENT_STOP) return; @@ -27,7 +27,7 @@ class CommandCSTopic : public Command void Unlock(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetChannelOption, OnSetChannelOption(source, this, ci, "topiclock off")); + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, "topiclock off")); if (MOD_RESULT == EVENT_STOP) return; diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 192eb4529..253dde884 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -182,7 +182,7 @@ class CommandCSXOP : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask; - FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, acc)); + FOREACH_MOD(OnAccessAdd, (ci, source, acc)); source.Reply(_("\002%s\002 added to %s %s list."), acc->mask.c_str(), ci->name.c_str(), source.command.c_str()); } @@ -287,7 +287,7 @@ class CommandCSXOP : public Command else nicks = caccess->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, caccess)); + FOREACH_MOD(OnAccessDel, (ci, source, caccess)); ci->EraseAccess(number - 1); } @@ -307,7 +307,7 @@ class CommandCSXOP : public Command source.Reply(_("\002%s\002 deleted from %s %s list."), a->mask.c_str(), ci->name.c_str(), source.command.c_str()); - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, a)); + FOREACH_MOD(OnAccessDel, (ci, source, a)); delete a; return; @@ -431,7 +431,7 @@ class CommandCSXOP : public Command ci->EraseAccess(i - 1); } - FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source)); + FOREACH_MOD(OnAccessClear, (ci, source)); source.Reply(_("Channel %s %s list has been cleared."), ci->name.c_str(), source.command.c_str()); } @@ -554,8 +554,6 @@ class CSXOP : public Module { this->SetPermanent(true); - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index 47ce98825..ac8c98b09 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -37,7 +37,7 @@ class CommandHelp : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreHelp, OnPreHelp(source, params)); + FOREACH_RESULT(OnPreHelp, MOD_RESULT, (source, params)); if (MOD_RESULT == EVENT_STOP) return; @@ -184,7 +184,7 @@ class CommandHelp : public Command source.Reply(_("No help available for \002%s\002."), params[0].c_str()); } - FOREACH_MOD(I_OnPostHelp, OnPostHelp(source, params)); + FOREACH_MOD(OnPostHelp, (source, params)); return; } diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index 1fa4f7b31..cf1a0d84a 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -27,7 +27,7 @@ class CommandHSDel : public Command if (na) { Log(LOG_ADMIN, source, this) << "for user " << na->nick; - FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); + FOREACH_MOD(OnDeleteVhost, (na)); na->RemoveVhost(); source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str()); } @@ -60,7 +60,7 @@ class CommandHSDelAll : public Command NickAlias *na = NickAlias::Find(nick); if (na) { - FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); + FOREACH_MOD(OnDeleteVhost, (na)); const NickCore *nc = na->nc; for (unsigned i = 0; i < nc->aliases->size(); ++i) { diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index d12973e01..6cd2b314f 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -190,7 +190,7 @@ class CommandHSActivate : public Command if (req) { na->SetVhost(req->ident, req->host, source.GetNick(), req->time); - FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); + FOREACH_MOD(OnSetVhost, (na)); if (Config->GetModule(this->owner)->Get<bool>("memouser") && memoserv) memoserv->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 834ac5fc1..5e7f9f2af 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -80,7 +80,7 @@ class CommandHSSet : public Command Log(LOG_ADMIN, source, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; na->SetVhost(user, host, source.GetNick()); - FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); + FOREACH_MOD(OnSetVhost, (na)); if (!user.empty()) source.Reply(_("VHost for \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), user.c_str(), host.c_str()); else @@ -182,7 +182,7 @@ class CommandHSSetAll : public Command na->SetVhost(user, host, source.GetNick()); this->Sync(na); - FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); + FOREACH_MOD(OnSetVhost, (na)); if (!user.empty()) source.Reply(_("VHost for group \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), user.c_str(), host.c_str()); else diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index cf1a0809f..18ddcfa09 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -41,9 +41,9 @@ class CommandMSCancel : public Command if (mi->GetMemo(i)->unread && source.nc->display.equals_ci(mi->GetMemo(i)->sender)) { if (ischan) - FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(i))); + FOREACH_MOD(OnMemoDel, (ci, mi, mi->GetMemo(i))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(na->nc, mi, mi->GetMemo(i))); + FOREACH_MOD(OnMemoDel, (na->nc, mi, mi->GetMemo(i))); mi->Del(i); source.Reply(_("Last memo to \002%s\002 has been cancelled."), nname.c_str()); return; diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index dac5ae43e..c789e697b 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -27,9 +27,9 @@ class MemoDelCallback : public NumberList return; if (ci) - FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(number - 1))); + FOREACH_MOD(OnMemoDel, (ci, mi, mi->GetMemo(number - 1))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(number - 1))); + FOREACH_MOD(OnMemoDel, (source.nc, mi, mi->GetMemo(number - 1))); mi->Del(number - 1); source.Reply(_("Memo %d has been deleted."), number); @@ -97,9 +97,9 @@ class CommandMSDel : public Command { /* Delete last memo. */ if (ci) - FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(mi->memos->size() - 1))); + FOREACH_MOD(OnMemoDel, (ci, mi, mi->GetMemo(mi->memos->size() - 1))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(mi->memos->size() - 1))); + FOREACH_MOD(OnMemoDel, (source.nc, mi, mi->GetMemo(mi->memos->size() - 1))); mi->Del(mi->memos->size() - 1); source.Reply(_("Memo %d has been deleted."), mi->memos->size() + 1); } @@ -109,9 +109,9 @@ class CommandMSDel : public Command for (unsigned i = 0, end = mi->memos->size(); i < end; ++i) { if (ci) - FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(i))); + FOREACH_MOD(OnMemoDel, (ci, mi, mi->GetMemo(i))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(i))); + FOREACH_MOD(OnMemoDel, (source.nc, mi, mi->GetMemo(i))); delete mi->GetMemo(i); } mi->memos->clear(); diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index 4fa3a2074..d42ef5bc6 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -180,8 +180,6 @@ class NSAccess : public Module NSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnsaccess(this) { - Implementation i[] = { I_OnNickRegister }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnNickRegister(User *u, NickAlias *na) anope_override diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index 0de8b43ff..836e0cf6d 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -242,8 +242,6 @@ class NSAJoin : public Module if (!IRCD->CanSVSJoin) throw ModuleException("Your IRCd does not support SVSJOIN"); - Implementation i[] = { I_OnNickIdentify }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnNickIdentify(User *u) anope_override diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index 022d803ea..dc877e467 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -225,8 +225,6 @@ class NSCert : public Module if (!IRCD || !IRCD->CanCertFP) throw ModuleException("Your IRCd does not support ssl client certificates"); - Implementation i[] = { I_OnFingerprint }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp index a21cac709..1cb83994e 100644 --- a/modules/commands/ns_drop.cpp +++ b/modules/commands/ns_drop.cpp @@ -45,7 +45,7 @@ class CommandNSDrop : public Command source.Reply(_("You may not drop other Services Operators' nicknames.")); else { - FOREACH_MOD(I_OnNickDrop, OnNickDrop(source, na)); + FOREACH_MOD(OnNickDrop, (source, na)); Log(!is_mine ? LOG_ADMIN : LOG_COMMAND, source, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; delete na; diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index 9b202b31c..989fc1385 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -31,7 +31,7 @@ class NSGroupRequest : public IdentifyRequest /* If the nick is already registered, drop it. */ if (na) { - FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(na->nc, u->nick)); + FOREACH_MOD(OnChangeCoreDisplay, (na->nc, u->nick)); delete na; } @@ -44,7 +44,7 @@ class NSGroupRequest : public IdentifyRequest u->Login(target->nc); IRCD->SendLogin(u); - FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); + FOREACH_MOD(OnNickGroup, (u, target)); Log(LOG_COMMAND, source, cmd) << "makes " << nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; source.Reply(_("You are now in the group of \002%s\002."), target->nick.c_str()); @@ -147,7 +147,7 @@ class CommandNSGroup : public Command if (ok == false && !pass.empty()) { NSGroupRequest *req = new NSGroupRequest(owner, source, this, u->nick, target, pass); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req)); + FOREACH_MOD(OnCheckAuthentication, (source.GetUser(), req)); req->Dispatch(); } else diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index aec43c1be..d66913851 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -82,7 +82,7 @@ class CommandNSIdentify : public Command else { NSIdentifyRequest *req = new NSIdentifyRequest(owner, source, this, na ? na->nc->display : nick, pass); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(u, req)); + FOREACH_MOD(OnCheckAuthentication, (u, req)); req->Dispatch(); } return; diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index f1de95275..864136cd8 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -135,7 +135,7 @@ class CommandNSInfo : public Command } } - FOREACH_MOD(I_OnNickInfo, OnNickInfo(source, na, info, show_hidden)); + FOREACH_MOD(OnNickInfo, (source, na, info, show_hidden)); std::vector<Anope::string> replies; info.Process(replies); diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index d5765b0f6..28559d314 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -54,7 +54,7 @@ class CommandNSLogout : public Command u2->Logout(); /* Send out an event */ - FOREACH_MOD(I_OnNickLogout, OnNickLogout(u2)); + FOREACH_MOD(OnNickLogout, (u2)); } return; } diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index 33bc9d19e..224b4e2ed 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -169,7 +169,7 @@ class CommandNSRecover : public Command if (ok == false && !pass.empty()) { NSRecoverRequest *req = new NSRecoverRequest(owner, source, this, na->nick, pass); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req)); + FOREACH_MOD(OnCheckAuthentication, (source.GetUser(), req)); req->Dispatch(); } else @@ -209,8 +209,6 @@ class NSRecover : public Module if (Config->GetBlock("options")->Get<bool>("nonicknameownership")) throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); - Implementation i[] = { I_OnUserNickChange, I_OnJoinChannel, I_OnShutdown, I_OnRestart }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~NSRecover() diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index ac1c55696..4064ce924 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -194,7 +194,7 @@ class CommandNSRegister : public Command Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; - FOREACH_MOD(I_OnNickRegister, OnNickRegister(source.GetUser(), na)); + FOREACH_MOD(OnNickRegister, (source.GetUser(), na)); if (na->nc->GetAccessCount()) source.Reply(_("Nickname \002%s\002 registered under your user@host-mask: %s"), u_nick.c_str(), na->nc->GetAccess(0).c_str()); diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index 44d941662..9b15e53ac 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -71,7 +71,6 @@ class NSResetPass : public Module throw ModuleException("Not using mail."); - ModuleManager::Attach(I_OnPreCommand, this); } ~NSResetPass() diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index fd32fb2be..4b2dfe684 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -224,7 +224,7 @@ class CommandNSSetAutoOp : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -306,7 +306,7 @@ class CommandNSSetChanstats : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, na->nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, na->nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -395,7 +395,7 @@ class CommandNSSetDisplay : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, user_na->nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, user_na->nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -510,7 +510,7 @@ class CommandNSSetEmail : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -599,7 +599,7 @@ class CommandNSSetGreet : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -682,7 +682,7 @@ class CommandNSSetHide : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -811,7 +811,7 @@ class CommandNSSetKill : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -937,7 +937,7 @@ class CommandNSSetLanguage : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -1045,7 +1045,7 @@ class CommandNSSetMessage : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -1134,7 +1134,7 @@ class CommandNSSetPrivate : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -1223,7 +1223,7 @@ class CommandNSSetSecure : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -1399,8 +1399,6 @@ class NSSet : public Module commandnssasetnoexpire(this) { - Implementation i[] = { I_OnPreCommand, I_OnSetCorrectModes }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 753450414..15fb0ed33 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -87,7 +87,7 @@ class CommandNSSetMisc : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param)); + FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); if (MOD_RESULT == EVENT_STOP) return; @@ -155,8 +155,6 @@ class NSSetMisc : public Module NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), nsmiscdata_type("NSMiscData", NSMiscData::Unserialize), commandnssetmisc(this), commandnssasetmisc(this) { - Implementation i[] = { I_OnReload, I_OnNickInfo }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index eadb35d7d..0db7cd951 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -94,7 +94,7 @@ class CommandNSSuspend : public Command Log(LOG_ADMIN, source, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires in " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Nick %s is now suspended."), nick.c_str()); - FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na)); + FOREACH_MOD(OnNickSuspend, (na)); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -150,7 +150,7 @@ class CommandNSUnSuspend : public Command Log(LOG_ADMIN, source, this) << "for " << na->nick; source.Reply(_("Nick %s is now released."), nick.c_str()); - FOREACH_MOD(I_OnNickUnsuspended, OnNickUnsuspended(na)); + FOREACH_MOD(OnNickUnsuspended, (na)); return; } @@ -173,8 +173,6 @@ class NSSuspend : public Module NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandnssuspend(this), commandnsunsuspend(this) { - Implementation i[] = { I_OnPreNickExpire, I_OnNickInfo }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) anope_override diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp index b56f8eded..2676c886f 100644 --- a/modules/commands/ns_update.cpp +++ b/modules/commands/ns_update.cpp @@ -31,7 +31,7 @@ class CommandNSUpdate : public Command na->last_seen = Anope::CurTime; } - FOREACH_MOD(I_OnNickUpdate, OnNickUpdate(u)); + FOREACH_MOD(OnNickUpdate, (u)); source.Reply(_("Status updated (memos, vhost, chmodes, flags).")); } diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index 34e6dbd2b..ef783c8af 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -180,7 +180,7 @@ class CommandOSAKill : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, akills)); + FOREACH_RESULT(OnAddXLine, MOD_RESULT, (source, x, akills)); if (MOD_RESULT == EVENT_STOP) { delete x; @@ -231,7 +231,7 @@ class CommandOSAKill : public Command do { - FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, x, akills)); + FOREACH_MOD(OnDelXLine, (source, x, akills)); source.Reply(_("\002%s\002 deleted from the AKILL list."), x->mask.c_str()); AkillDelCallback::DoDel(source, x); @@ -353,7 +353,7 @@ class CommandOSAKill : public Command for (unsigned i = akills->GetCount(); i > 0; --i) { XLine *x = akills->GetEntry(i - 1); - FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, x, akills)); + FOREACH_MOD(OnDelXLine, (source, x, akills)); akills->DelXLine(x); } diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index ba695649d..8bea10d0f 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -125,7 +125,7 @@ class DefConTimeout : public Timer if (DConfig.defaultlevel != level) { DConfig.defaultlevel = level; - FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level)); + FOREACH_MOD(OnDefconLevel, (level)); Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level; if (DConfig.globalondefcon) @@ -203,7 +203,7 @@ class CommandOSDefcon : public Command DConfig.defaultlevel = newLevel; - FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(newLevel)); + FOREACH_MOD(OnDefconLevel, (newLevel)); delete timeout; @@ -333,8 +333,6 @@ class OSDefcon : public Module OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), session_service("SessionService", "session"), akills("XLineManager", "xlinemanager/sgline"), commandosdefcon(this) { - Implementation i[] = { I_OnReload, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelSync }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index 32e6be59d..c71b1f887 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -656,8 +656,6 @@ class ModuleDNS : public Module zone_type("DNSZone", DNSZone::Unserialize), dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this) { - Implementation i[] = { I_OnReload, I_OnNewServer, I_OnServerQuit, I_OnUserConnect, I_OnPreUserLogoff, I_OnDnsRequest }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); for (unsigned j = 0; j < dns_servers->size(); ++j) { diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index a56d08219..bd837919c 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -251,8 +251,6 @@ class OSForbid : public Module forbiddata_type("ForbidData", ForbidData::Unserialize), forbidService(this), commandosforbid(this) { - Implementation i[] = { I_OnUserConnect, I_OnUserNickChange, I_OnJoinChannel, I_OnPreCommand }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnUserConnect(User *u, bool &exempt) anope_override diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index 56c784856..60c1bd8bf 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -320,8 +320,6 @@ class OSIgnore : public Module ignoredata_type("IgnoreData", IgnoreData::Unserialize), osignoreservice(this), commandosignore(this) { - Implementation i[] = { I_OnBotPrivmsg }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp index 573379236..9d666188a 100644 --- a/modules/commands/os_login.cpp +++ b/modules/commands/os_login.cpp @@ -116,7 +116,6 @@ class OSLogin : public Module commandoslogin(this), commandoslogout(this) { - ModuleManager::Attach(I_IsServicesOper, this); } ~OSLogin() diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index 1d55df843..cb6a9fcfa 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -385,8 +385,6 @@ class OSNews : public Module OSNews(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), newsitem_type("NewsItem", NewsItem::Unserialize), newsservice(this), commandoslogonnews(this), commandosopernews(this), commandosrandomnews(this) { - Implementation i[] = { I_OnUserModeSet, I_OnUserConnect }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnUserModeSet(User *u, const Anope::string &mname) anope_override diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp index 239b09a32..171b11c94 100644 --- a/modules/commands/os_noop.cpp +++ b/modules/commands/os_noop.cpp @@ -82,7 +82,6 @@ class OSNOOP : public Module commandosnoop(this) { - ModuleManager::Attach(I_OnUserModeSet, this); } void OnUserModeSet(User *u, const Anope::string &mname) anope_override diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index af6a547f5..9496090db 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -156,7 +156,7 @@ class ExceptionDelCallback : public NumberList static void DoDel(CommandSource &source, unsigned index) { Exception *e = session_service->GetExceptions()[index]; - FOREACH_MOD(I_OnExceptionDel, OnExceptionDel(source, e)); + FOREACH_MOD(OnExceptionDel, (source, e)); session_service->DelException(e); delete e; @@ -360,7 +360,7 @@ class CommandOSException : public Command exception->expires = expires; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnExceptionAdd, OnExceptionAdd(exception)); + FOREACH_RESULT(OnExceptionAdd, MOD_RESULT, (exception)); if (MOD_RESULT == EVENT_STOP) delete exception; else @@ -619,8 +619,6 @@ class OSSession : public Module { this->SetPermanent(true); - Implementation i[] = { I_OnReload, I_OnUserConnect, I_OnUserQuit, I_OnExpireTick }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); ModuleManager::SetPriority(this, PRIORITY_FIRST); } diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index d12237c93..7cd3c12ca 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -91,7 +91,7 @@ class CommandOSSXLineBase : public Command return; } - FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, x, this->xlm())); + FOREACH_MOD(OnDelXLine, (source, x, this->xlm())); SXLineDelCallback::DoDel(this->xlm(), source, x); source.Reply(_("\002%s\002 deleted from the %s list."), mask.c_str(), source.command.c_str()); @@ -198,7 +198,7 @@ class CommandOSSXLineBase : public Command void OnClear(CommandSource &source) { - FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, NULL, this->xlm())); + FOREACH_MOD(OnDelXLine, (source, NULL, this->xlm())); for (unsigned i = this->xlm()->GetCount(); i > 0; --i) { @@ -370,7 +370,7 @@ class CommandOSSNLine : public CommandOSSXLineBase } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, this->xlm())); + FOREACH_RESULT(OnAddXLine, MOD_RESULT, (source, x, this->xlm())); if (MOD_RESULT == EVENT_STOP) { delete x; @@ -576,7 +576,7 @@ class CommandOSSQLine : public CommandOSSXLineBase } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, this->xlm())); + FOREACH_RESULT(OnAddXLine, MOD_RESULT, (source, x, this->xlm())); if (MOD_RESULT == EVENT_STOP) { delete x; diff --git a/modules/cs_statusupdate.cpp b/modules/cs_statusupdate.cpp index bdb6c73d0..b4294fbd6 100644 --- a/modules/cs_statusupdate.cpp +++ b/modules/cs_statusupdate.cpp @@ -13,8 +13,6 @@ class StatusUpdate : public Module StatusUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) { - Implementation i[] = { I_OnAccessAdd, I_OnAccessDel }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnAccessAdd(ChannelInfo *ci, CommandSource &, ChanAccess *access) anope_override diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 27b6ce1a2..e7ea2f262 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -164,8 +164,6 @@ class DBFlatFile : public Module, public Pipe DBFlatFile(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), last_day(0), loaded(false) { - Implementation i[] = { I_OnLoadDatabase, I_OnSaveDatabase, I_OnSerializeTypeCreate }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnNotify() anope_override diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index b901d879a..053a49110 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -1093,8 +1093,6 @@ class DBOld : public Module DBOld(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) { - Implementation i[] = { I_OnLoadDatabase, I_OnUplinkSync }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); hashm = Config->GetModule(this)->Get<const Anope::string>("hash"); diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp index a2c8d4274..1e4586a11 100644 --- a/modules/database/db_plain.cpp +++ b/modules/database/db_plain.cpp @@ -380,7 +380,7 @@ static void ReadDatabase(Module *m = NULL) /*if (m) MOD_RESULT = m->OnDatabaseRead(params); else - FOREACH_RESULT(I_OnDatabaseRead, OnDatabaseRead(params)); + FOREACH_RESULT(OnDatabaseRead, MOD_RESULT, (params)); if (MOD_RESULT == EVENT_STOP) continue;*/ OnDatabaseRead(params); @@ -587,8 +587,6 @@ class DBPlain : public Module public: DBPlain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) { - Implementation i[] = { I_OnReload, I_OnLoadDatabase, I_OnSaveDatabase }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); LastDay = 0; } @@ -645,9 +643,6 @@ class DBPlain : public Module { ReadDatabase(); - /* No need to ever reload this again, although this should never be trigged again */ - ModuleManager::Detach(I_OnLoadDatabase, this); - return EVENT_STOP; } @@ -702,7 +697,7 @@ class DBPlain : public Module } for (unsigned k = 0, end = mi->ignores.size(); k < end; ++k) db_buffer << "MD MIG " << Anope::string(mi->ignores[k]) << endl; - //FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nc)); + //FOREACH_MOD(OnDatabaseWriteMetadata, (WriteMetadata, nc)); } for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) @@ -727,7 +722,7 @@ class DBPlain : public Module if (na->HasVhost()) db_buffer << "MD VHOST " << na->GetVhostCreator() << " " << na->GetVhostCreated() << " " << na->GetVhostHost() << " :" << na->GetVhostIdent() << endl; - //FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na)); + //FOREACH_MOD(OnDatabaseWriteMetadata, (WriteMetadata, na)); } for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) @@ -836,7 +831,7 @@ class DBPlain : public Module db_buffer << "MD BI BADWORD " << (ci->GetBadWord(k)->type == BW_ANY ? "ANY " : "") << (ci->GetBadWord(k)->type == BW_SINGLE ? "SINGLE " : "") << (ci->GetBadWord(k)->type == BW_START ? "START " : "") << (ci->GetBadWord(k)->type == BW_END ? "END " : "") << ":" << ci->GetBadWord(k)->word << endl; - //FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, ci)); + //FOREACH_MOD(OnDatabaseWriteMetadata, (WriteMetadata, ci)); } db_buffer << "OS STATS " << MaxUserCount << " " << MaxUserTime << endl; @@ -858,7 +853,7 @@ class DBPlain : public Module db_buffer << "OS EXCEPTION " << e->mask << " " << e->limit << " " << e->who << " " << e->time << " " << e->expires << " " << e->reason << endl; } - //FOREACH_MOD(I_OnDatabaseWrite, OnDatabaseWrite(Write)); + //FOREACH_MOD(OnDatabaseWrite, (Write)); std::fstream db; db.open(DatabaseFile.c_str(), std::ios_base::out | std::ios_base::trunc); diff --git a/modules/database/db_redis.cpp b/modules/database/db_redis.cpp index 122248f95..e78134857 100644 --- a/modules/database/db_redis.cpp +++ b/modules/database/db_redis.cpp @@ -132,8 +132,6 @@ class DatabaseRedis : public Module, public Pipe { me = this; - Implementation i[] = { I_OnReload, I_OnLoadDatabase, I_OnSerializeTypeCreate, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } /* Insert or update an object */ diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index bb4d5277b..b575d3fd1 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -92,8 +92,6 @@ class DBSQL : public Module, public Pipe DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), sql("", ""), sqlinterface(this), shutting_down(false), loading_databases(false), loaded(false), imported(false) { - Implementation i[] = { I_OnReload, I_OnShutdown, I_OnRestart, I_OnLoadDatabase, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate, I_OnSerializeTypeCreate }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); if (ModuleManager::FindModule("db_sql_live") != NULL) throw ModuleException("db_sql can not be loaded after db_sql_live"); diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index 992a15471..02e8a355f 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -70,8 +70,6 @@ class DBMySQL : public Module, public Pipe this->ro = false; this->init = false; - Implementation i[] = { I_OnReload, I_OnShutdown, I_OnLoadDatabase, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializeCheck, I_OnSerializableUpdate }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); if (ModuleManager::FindFirstOf(DATABASE) != this) throw ModuleException("If db_sql_live is loaded it must be the first database module loaded."); diff --git a/modules/encryption/enc_md5.cpp b/modules/encryption/enc_md5.cpp index e19931800..a352e8dec 100644 --- a/modules/encryption/enc_md5.cpp +++ b/modules/encryption/enc_md5.cpp @@ -346,8 +346,6 @@ class EMD5 : public Module md5provider(this) { - Implementation i[] = { I_OnEncrypt, I_OnCheckAuthentication }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override diff --git a/modules/encryption/enc_none.cpp b/modules/encryption/enc_none.cpp index 5f219000c..9754c0c4f 100644 --- a/modules/encryption/enc_none.cpp +++ b/modules/encryption/enc_none.cpp @@ -15,8 +15,6 @@ class ENone : public Module ENone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR) { - Implementation i[] = { I_OnEncrypt, I_OnDecrypt, I_OnCheckAuthentication }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override diff --git a/modules/encryption/enc_old.cpp b/modules/encryption/enc_old.cpp index 037a2fffc..eee9b25b6 100644 --- a/modules/encryption/enc_old.cpp +++ b/modules/encryption/enc_old.cpp @@ -49,8 +49,6 @@ class EOld : public Module if (!md5) throw ModuleException("Unable to find md5 reference"); - Implementation i[] = { I_OnEncrypt, I_OnCheckAuthentication }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override diff --git a/modules/encryption/enc_sha1.cpp b/modules/encryption/enc_sha1.cpp index c1f032874..4ef3e51fe 100644 --- a/modules/encryption/enc_sha1.cpp +++ b/modules/encryption/enc_sha1.cpp @@ -201,8 +201,6 @@ class ESHA1 : public Module sha1provider(this) { - Implementation i[] = { I_OnEncrypt, I_OnCheckAuthentication }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) anope_override diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp index 85fbaf223..099b778dd 100644 --- a/modules/encryption/enc_sha256.cpp +++ b/modules/encryption/enc_sha256.cpp @@ -277,8 +277,6 @@ class ESHA256 : public Module sha256provider(this) { - Implementation i[] = { I_OnEncrypt, I_OnCheckAuthentication }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); use_iv = false; } diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp index 3d3430752..9a3c5dfaf 100644 --- a/modules/extra/m_chanstats.cpp +++ b/modules/extra/m_chanstats.cpp @@ -336,17 +336,6 @@ class MChanstats : public Module MChanstats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), sql("", ""), sqlinterface(this) { - - Implementation i[] = { I_OnPrivmsg, - I_OnPreUserKicked, - I_OnChannelModeSet, - I_OnChannelModeUnset, - I_OnTopicUpdated, - I_OnDelCore, - I_OnChangeCoreDisplay, - I_OnChanDrop, - I_OnReload}; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/extra/m_httpd.cpp b/modules/extra/m_httpd.cpp index 212abfa4f..6524a87b5 100644 --- a/modules/extra/m_httpd.cpp +++ b/modules/extra/m_httpd.cpp @@ -334,8 +334,6 @@ class HTTPD : public Module HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), sslref("SSLService", "ssl") { - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~HTTPD() diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp index 17ad60213..61410d274 100644 --- a/modules/extra/m_ldap.cpp +++ b/modules/extra/m_ldap.cpp @@ -407,8 +407,6 @@ class ModuleLDAP : public Module, public Pipe { me = this; - Implementation i[] = { I_OnReload, I_OnModuleUnload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~ModuleLDAP() diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index 617929380..d64987ed6 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -103,7 +103,7 @@ class IdentifyInterface : public LDAPInterface if (na == NULL) { na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount())); - FOREACH_MOD(I_OnNickRegister, OnNickRegister(ii->user, na)); + FOREACH_MOD(OnNickRegister, (ii->user, na)); BotInfo *NickServ = Config->GetClient("NickServ"); if (ii->user && NickServ) ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); @@ -217,8 +217,6 @@ class NSIdentifyLDAP : public Module me = this; - Implementation i[] = { I_OnReload, I_OnPreCommand, I_OnCheckAuthentication, I_OnNickIdentify, I_OnNickRegister }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); ModuleManager::SetPriority(this, PRIORITY_FIRST); } diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp index 43ee81408..3e16d75e6 100644 --- a/modules/extra/m_ldap_oper.cpp +++ b/modules/extra/m_ldap_oper.cpp @@ -89,8 +89,6 @@ class LDAPOper : public Module Module(modname, creator, EXTRA | VENDOR), ldap("LDAPProvider", "ldap/main"), iinterface(this) { - Implementation i[] = { I_OnReload, I_OnNickIdentify, I_OnDelCore }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 8cf12ca79..c42d82ee6 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -169,8 +169,6 @@ class ModuleSQL : public Module, public Pipe { me = this; - Implementation i[] = { I_OnReload, I_OnModuleUnload }; - ModuleManager::Attach(i, this, 2); DThread = new DispatcherThread(); DThread->Start(); diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index fb5f96758..7f8adb60e 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -221,8 +221,6 @@ class ModuleProxyScan : public Module connectionTimeout(this, 5) { - Implementation i[] = { I_OnReload, I_OnUserConnect }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); this->listener = NULL; } diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index 648dc22c2..bbd4e8b23 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -42,7 +42,7 @@ class SQLAuthenticationResult : public SQL::Interface if (na == NULL) { na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount())); - FOREACH_MOD(I_OnNickRegister, OnNickRegister(user, na)); + FOREACH_MOD(OnNickRegister, (user, na)); if (user && NickServ) user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } @@ -78,8 +78,6 @@ class ModuleSQLAuthentication : public Module { me = this; - Implementation i[] = { I_OnReload, I_OnPreCommand, I_OnCheckAuthentication }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp index 6f9f05004..772d484c6 100644 --- a/modules/extra/m_sql_oper.cpp +++ b/modules/extra/m_sql_oper.cpp @@ -98,8 +98,6 @@ class ModuleSQLOper : public Module ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { - Implementation i[] = { I_OnReload, I_OnNickIdentify }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp index bea4d8d95..b306ccfcf 100644 --- a/modules/extra/m_sqlite.cpp +++ b/modules/extra/m_sqlite.cpp @@ -66,8 +66,6 @@ class ModuleSQLite : public Module public: ModuleSQLite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~ModuleSQLite() diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 19b0aaf8f..10d1b5807 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -117,8 +117,6 @@ class SSLModule : public Module SSL_CTX_set_session_id_context(client_ctx, reinterpret_cast<const unsigned char *>(context_name.c_str()), context_name.length()); SSL_CTX_set_session_id_context(server_ctx, reinterpret_cast<const unsigned char *>(context_name.c_str()), context_name.length()); - ModuleManager::Attach(I_OnReload, this); - ModuleManager::Attach(I_OnPreServerConnect, this); } ~SSLModule() diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp index 66e2db9ac..3c16f997e 100644 --- a/modules/extra/m_xmlrpc.cpp +++ b/modules/extra/m_xmlrpc.cpp @@ -168,8 +168,6 @@ class ModuleXMLRPC : public Module throw ModuleException("Unable to find http reference, is m_httpd loaded?"); httpref->RegisterPage(&xmlrpcinterface); - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~ModuleXMLRPC() diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index b697a2c8c..c1db97603 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -117,7 +117,7 @@ class MyXMLRPCEvent : public XMLRPCEvent else { XMLRPCIdentifyRequest *req = new XMLRPCIdentifyRequest(me, request, client, iface, username, password); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); + FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); return false; } diff --git a/modules/extra/webcpanel/pages/index.cpp b/modules/extra/webcpanel/pages/index.cpp index 4449f5f60..51b908b13 100644 --- a/modules/extra/webcpanel/pages/index.cpp +++ b/modules/extra/webcpanel/pages/index.cpp @@ -87,7 +87,7 @@ bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page // Rate limit check. WebpanelRequest *req = new WebpanelRequest(me, reply, message, server, page_name, client, replacements, user, pass); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); + FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); return false; } diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp index ea64da92f..422d035b3 100644 --- a/modules/m_dns.cpp +++ b/modules/m_dns.cpp @@ -779,7 +779,7 @@ class MyManager : public Manager, public Timer } } - FOREACH_MOD(I_OnDnsRequest, OnDnsRequest(recv_packet, packet)); + FOREACH_MOD(OnDnsRequest, (recv_packet, packet)); for (unsigned i = 0; i < recv_packet.questions.size(); ++i) { @@ -940,8 +940,6 @@ class ModuleDNS : public Module ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), manager(this) { - Implementation i[] = { I_OnReload, I_OnModuleUnload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/m_dnsbl.cpp b/modules/m_dnsbl.cpp index 4a3b7dddc..8a238889f 100644 --- a/modules/m_dnsbl.cpp +++ b/modules/m_dnsbl.cpp @@ -92,8 +92,6 @@ class ModuleDNSBL : public Module ModuleDNSBL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) { - Implementation i[] = { I_OnReload, I_OnUserConnect }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/m_helpchan.cpp b/modules/m_helpchan.cpp index a3003e59f..7739fbcd5 100644 --- a/modules/m_helpchan.cpp +++ b/modules/m_helpchan.cpp @@ -12,8 +12,6 @@ class HelpChannel : public Module public: HelpChannel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) { - Implementation i[] = { I_OnChannelModeSet }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, const Anope::string &mname, const Anope::string ¶m) anope_override diff --git a/modules/m_redis.cpp b/modules/m_redis.cpp index 03f6f8547..2237f8709 100644 --- a/modules/m_redis.cpp +++ b/modules/m_redis.cpp @@ -529,8 +529,6 @@ class ModuleRedis : public Module public: ModuleRedis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { - Implementation i[] = { I_OnReload, I_OnModuleUnload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~ModuleRedis() diff --git a/modules/m_rewrite.cpp b/modules/m_rewrite.cpp index f2f3c8690..8eec06d6e 100644 --- a/modules/m_rewrite.cpp +++ b/modules/m_rewrite.cpp @@ -155,8 +155,6 @@ class ModuleRewrite : public Module public: ModuleRewrite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), cmdrewrite(this) { - Implementation i[] = { I_OnReload }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index ecea98329..d65c24d65 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -554,7 +554,6 @@ class ProtoBahamut : public Module this->AddModes(); - ModuleManager::Attach(I_OnUserNickChange, this); } void OnUserNickChange(User *u, const Anope::string &) anope_override diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index 368c79eac..9b87f3230 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -171,7 +171,7 @@ struct IRCDMessageEncap : IRCDMessage if (params[1] == "CERTFP") { u->fingerprint = params[2]; - FOREACH_MOD(I_OnFingerprint, OnFingerprint(u)); + FOREACH_MOD(OnFingerprint, (u)); } /* * Received: :42X ENCAP * SASL 42XAAAAAH * S PLAIN @@ -257,7 +257,7 @@ struct IRCDMessageEncap : IRCDMessage return; IdentifyRequest *req = new CharybdisSASLIdentifyRequest(this->owner, source, params[2], acc, pass); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); + FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); } } @@ -419,8 +419,6 @@ class ProtoCharybdis : public Module { - Implementation i[] = { I_OnReload, I_OnChannelSync, I_OnMLock, I_OnUnMLock }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); if (ModuleManager::LoadModule("ratbox", User::Find(creator)) != MOD_ERR_OK) throw ModuleException("Unable to load ratbox"); diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index 4649f3cf6..ecdaff456 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -610,7 +610,6 @@ public: { this->AddModes(); - ModuleManager::Attach(I_OnUserNickChange, this); if (Me->GetSID() == Me->GetName()) Me->SetSID(Servers::TS6_SID_Retrieve()); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index f4a29bc50..cc1c5eb4c 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -953,7 +953,7 @@ struct IRCDMessageMetadata : IRCDMessage if ((pos2 - pos1) >= 32) // inspircd supports md5 and sha1 fingerprint hashes -> size 32 or 40 bytes. { u->fingerprint = data.substr(pos1, pos2 - pos1); - FOREACH_MOD(I_OnFingerprint, OnFingerprint(u)); + FOREACH_MOD(OnFingerprint, (u)); } } } @@ -1213,8 +1213,6 @@ class ProtoInspIRCd : public Module message_setident(this), message_server(this), message_time(this), message_uid(this) { - Implementation i[] = { I_OnUserNickChange }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); Servers::Capab.insert("NOQUIT"); diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 2d7b4ef29..673836d93 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -699,7 +699,7 @@ struct IRCDMessageEncap : IRCDMessage return; IdentifyRequest *req = new InspIRCDSASLIdentifyRequest(this->owner, params[2], acc, pass); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); + FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); } } @@ -790,8 +790,6 @@ class ProtoInspIRCd : public Module throw ModuleException("No protocol interface for insp12"); ModuleManager::DetachAll(m_insp12); - Implementation i[] = { I_OnReload, I_OnUserNickChange, I_OnChannelSync, I_OnChanRegistered, I_OnDelChan, I_OnMLock, I_OnUnMLock, I_OnSetChannelOption }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~ProtoInspIRCd() diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 139c7e5c4..a8ddeed30 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -656,8 +656,6 @@ class ProtongIRCd : public Module this->AddModes(); - Implementation i[] = { I_OnUserNickChange }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnUserNickChange(User *u, const Anope::string &) anope_override diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 9f7e094a2..e3efdc6e6 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -202,7 +202,7 @@ struct IRCDMessageEncap : IRCDMessage if (u) { u->fingerprint = params[3]; - FOREACH_MOD(I_OnFingerprint, OnFingerprint(u)); + FOREACH_MOD(OnFingerprint, (u)); } } return; diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 6cf07342e..fa6dc15ed 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -920,7 +920,7 @@ struct IRCDMessageSASL : IRCDMessage return; IdentifyRequest *req = new UnrealSASLIdentifyRequest(this->owner, params[1], acc, pass); - FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); + FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); } } @@ -1211,8 +1211,6 @@ class ProtoUnreal : public Module this->AddModes(); - Implementation i[] = { I_OnReload, I_OnUserNickChange, I_OnChannelSync, I_OnChanRegistered, I_OnDelChan, I_OnMLock, I_OnUnMLock }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); ModuleManager::SetPriority(this, PRIORITY_FIRST); } diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index 828f3b0e2..8322ad3c3 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -18,9 +18,6 @@ class BotServCore : public Module public: BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) { - Implementation i[] = { I_OnReload, I_OnSetCorrectModes, I_OnBotAssign, I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel, - I_OnPreHelp, I_OnPostHelp, I_OnChannelModeSet, I_OnCreateChan, I_OnUserKicked, I_OnCreateBot }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override @@ -148,11 +145,11 @@ class BotServCore : public Module EventReturn MOD_RESULT; if (c->ci->AccessFor(u).HasPriv("FANTASIA")) { - FOREACH_RESULT(I_OnBotFantasy, OnBotFantasy(source, cmd, c->ci, params)); + FOREACH_RESULT(OnBotFantasy, MOD_RESULT, (source, cmd, c->ci, params)); } else { - FOREACH_RESULT(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(source, cmd, c->ci, params)); + FOREACH_RESULT(OnBotNoFantasyAccess, MOD_RESULT, (source, cmd, c->ci, params)); } if (MOD_RESULT == EVENT_STOP || !c->ci->AccessFor(u).HasPriv("FANTASIA")) @@ -161,7 +158,7 @@ class BotServCore : public Module if (MOD_RESULT != EVENT_ALLOW && !info.permission.empty() && !source.HasCommand(info.permission)) return; - FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, cmd, params)); + FOREACH_RESULT(OnPreCommand, MOD_RESULT, (source, cmd, params)); if (MOD_RESULT == EVENT_STOP) return; @@ -169,7 +166,7 @@ class BotServCore : public Module cmd->Execute(source, params); if (!nc_reference) source.nc = NULL; - FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, cmd, params)); + FOREACH_MOD(OnPostCommand, (source, cmd, params)); } void OnJoinChannel(User *user, Channel *c) anope_override diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index 5a1fed00b..116d5a5ac 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -20,11 +20,6 @@ class ChanServCore : public Module, public ChanServService ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), ChanServService(this) { - Implementation i[] = { I_OnReload, I_OnBotDelete, I_OnBotPrivmsg, I_OnDelCore, - I_OnPreHelp, I_OnPostHelp, I_OnCheckModes, I_OnCreateChan, I_OnCanSet, - I_OnChannelSync, I_OnBotKick, I_OnExpireTick, I_OnCheckDelete, I_OnPreUplinkSync, - I_OnChanRegistered, I_OnTopicUpdated }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void Hold(Channel *c) anope_override @@ -360,7 +355,7 @@ class ChanServCore : public Module, public ChanServService if (ci->HasExt("NO_EXPIRE")) expire = false; - FOREACH_MOD(I_OnPreChanExpire, OnPreChanExpire(ci, expire)); + FOREACH_MOD(OnPreChanExpire, (ci, expire)); if (expire) { @@ -369,7 +364,7 @@ class ChanServCore : public Module, public ChanServService extra = "suspended "; Log(LOG_NORMAL, "chanserv/expire") << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")"; - FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci)); + FOREACH_MOD(OnChanExpire, (ci)); delete ci; } } diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index 224cbeea1..1500ebb17 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -27,8 +27,6 @@ class GlobalCore : public Module, public GlobalService GlobalCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), GlobalService(this) { - Implementation i[] = { I_OnReload, I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) anope_override diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp index 7c98c7344..31b623895 100644 --- a/modules/pseudoclients/hostserv.cpp +++ b/modules/pseudoclients/hostserv.cpp @@ -17,13 +17,8 @@ class HostServCore : public Module public: HostServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) { - if (!IRCD || !IRCD->CanSetVHost) throw ModuleException("Your IRCd does not support vhosts"); - - Implementation i[] = { I_OnReload, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp, - I_OnSetVhost, I_OnDeleteVhost }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnReload(Configuration::Conf *conf) anope_override diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp index 5136e2af0..e2fa0b0d1 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv.cpp @@ -39,8 +39,6 @@ class MemoServCore : public Module, public MemoServService MemoServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), MemoServService(this) { - Implementation i[] = { I_OnNickCoreCreate, I_OnCreateChan, I_OnReload, I_OnBotDelete, I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force) anope_override @@ -76,7 +74,7 @@ class MemoServCore : public Module, public MemoServService m->text = message; m->unread = true; - FOREACH_MOD(I_OnMemoSend, OnMemoSend(source, target, mi, m)); + FOREACH_MOD(OnMemoSend, (source, target, mi, m)); if (ischan) { diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index 642b22f2d..2e80211b0 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -114,10 +114,6 @@ class NickServCore : public Module, public NickServService public: NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), NickServService(this) { - Implementation i[] = { I_OnReload, I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup, - I_OnNickUpdate, I_OnUserConnect, I_OnPostUserLogoff, I_OnServerSync, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp, - I_OnNickCoreCreate, I_OnUserQuit, I_OnExpireTick, I_OnUserLogin }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void Validate(User *u) anope_override @@ -285,7 +281,7 @@ class NickServCore : public Module, public NickServService IRCD->SendLogout(user); user->RemoveMode(NickServ, "REGISTERED"); user->Logout(); - FOREACH_MOD(I_OnNickLogout, OnNickLogout(user)); + FOREACH_MOD(OnNickLogout, (user)); } nc->users.clear(); } @@ -510,7 +506,7 @@ class NickServCore : public Module, public NickServService if (na->HasExt("NO_EXPIRE")) expire = false; - FOREACH_MOD(I_OnPreNickExpire, OnPreNickExpire(na, expire)); + FOREACH_MOD(OnPreNickExpire, (na, expire)); if (expire) { @@ -518,7 +514,7 @@ class NickServCore : public Module, public NickServService if (na->nc->HasExt("SUSPENDED")) extra = "suspended "; Log(LOG_NORMAL, "expire") << "Expiring " << extra << "nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; - FOREACH_MOD(I_OnNickExpire, OnNickExpire(na)); + FOREACH_MOD(OnNickExpire, (na)); delete na; } } diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index 85984327c..e0d3ea979 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -159,8 +159,6 @@ class OperServCore : public Module OperServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), sglines(this), sqlines(this), snlines(this) { - Implementation i[] = { I_OnReload, I_OnBotPrivmsg, I_OnServerQuit, I_OnUserModeSet, I_OnUserModeUnset, I_OnUserConnect, I_OnUserNickChange, I_OnPreHelp, I_OnLog }; - ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); /* Yes, these are in this order for a reason. Most violent->least violent. */ XLineManager::RegisterXLineManager(&sglines); diff --git a/src/access.cpp b/src/access.cpp index a8da63c50..b0c98b9db 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -308,13 +308,13 @@ bool AccessGroup::HasPriv(const Anope::string &name) const else if (this->founder) return true; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnGroupCheckPriv, OnGroupCheckPriv(this, name)); + FOREACH_RESULT(OnGroupCheckPriv, MOD_RESULT, (this, name)); if (MOD_RESULT != EVENT_CONTINUE) return MOD_RESULT == EVENT_ALLOW; for (unsigned i = this->size(); i > 0; --i) { ChanAccess *access = this->at(i - 1); - FOREACH_RESULT(I_OnCheckPriv, OnCheckPriv(access, name)); + FOREACH_RESULT(OnCheckPriv, MOD_RESULT, (access, name)); if (MOD_RESULT == EVENT_ALLOW || access->HasPriv(name)) return true; } diff --git a/src/bots.cpp b/src/bots.cpp index 3ea2ef485..74cf0d9e4 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -31,7 +31,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A if (!this->uid.empty()) (*BotListByUID)[this->uid] = this; - FOREACH_MOD(I_OnCreateBot, OnCreateBot(this)); + FOREACH_MOD(OnCreateBot, (this)); // If we're synchronised with the uplink already, send the bot. if (Me && Me->IsSynced()) @@ -49,7 +49,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A BotInfo::~BotInfo() { - FOREACH_MOD(I_OnDelBot, OnDelBot(this)); + FOREACH_MOD(OnDelBot, (this)); // If we're synchronised with the uplink already, send the bot. if (Me && Me->IsSynced()) @@ -133,8 +133,8 @@ const std::set<ChannelInfo *> &BotInfo::GetChannels() const void BotInfo::Assign(User *u, ChannelInfo *ci) { - EventReturn MOD_RESULT = EVENT_CONTINUE; - FOREACH_RESULT(I_OnPreBotAssign, OnPreBotAssign(u, ci, this)); + EventReturn MOD_RESULT; + FOREACH_RESULT(OnPreBotAssign, MOD_RESULT, (u, ci, this)); if (MOD_RESULT == EVENT_STOP) return; @@ -144,13 +144,13 @@ void BotInfo::Assign(User *u, ChannelInfo *ci) ci->bi = this; this->channels->insert(ci); - FOREACH_MOD(I_OnBotAssign, OnBotAssign(u, ci, this)); + FOREACH_MOD(OnBotAssign, (u, ci, this)); } void BotInfo::UnAssign(User *u, ChannelInfo *ci) { - EventReturn MOD_RESULT = EVENT_CONTINUE; - FOREACH_RESULT(I_OnBotUnAssign, OnBotUnAssign(u, ci)); + EventReturn MOD_RESULT; + FOREACH_RESULT(OnBotUnAssign, MOD_RESULT, (u, ci)); if (MOD_RESULT == EVENT_STOP) return; diff --git a/src/channels.cpp b/src/channels.cpp index d774b8c8d..8e391699e 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -45,12 +45,12 @@ Channel::Channel(const Anope::string &nname, time_t ts) if (Me && Me->IsSynced()) Log(NULL, this, "create"); - FOREACH_MOD(I_OnChannelCreate, OnChannelCreate(this)); + FOREACH_MOD(OnChannelCreate, (this)); } Channel::~Channel() { - FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(this)); + FOREACH_MOD(OnChannelDelete, (this)); ModeManager::StackerDel(this); @@ -87,7 +87,7 @@ void Channel::Reset() void Channel::Sync() { - FOREACH_MOD(I_OnChannelSync, OnChannelSync(this)); + FOREACH_MOD(OnChannelSync, (this)); } void Channel::CheckModes() @@ -104,7 +104,7 @@ void Channel::CheckModes() } EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnCheckModes, OnCheckModes(this)); + FOREACH_RESULT(OnCheckModes, MOD_RESULT, (this)); if (MOD_RESULT == EVENT_STOP) return; @@ -164,7 +164,7 @@ bool Channel::CheckDelete() return false; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnCheckDelete, OnCheckDelete(this)); + FOREACH_RESULT(OnCheckDelete, MOD_RESULT, (this)); return MOD_RESULT != EVENT_STOP && this->users.empty(); } @@ -174,7 +174,7 @@ ChanUserContainer* Channel::JoinUser(User *user) if (user->server && user->server->IsSynced()) Log(user, this, "join"); - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(user, this)); + FOREACH_MOD(OnJoinChannel, (user, this)); ChanUserContainer *cuc = new ChanUserContainer(user, this); user->chans[this] = cuc; @@ -188,7 +188,7 @@ void Channel::DeleteUser(User *user) if (user->server && user->server->IsSynced() && !user->Quitting()) Log(user, this, "leave"); - FOREACH_MOD(I_OnLeaveChannel, OnLeaveChannel(user, this)); + FOREACH_MOD(OnLeaveChannel, (user, this)); ChanUserContainer *cu = user->FindChannel(this); if (!this->users.erase(user)) @@ -311,7 +311,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop if (cc) cc->status.AddMode(cm->mchar); - FOREACH_RESULT(I_OnChannelModeSet, OnChannelModeSet(this, setter, cm->name, param)); + FOREACH_RESULT(OnChannelModeSet, MOD_RESULT, (this, setter, cm->name, param)); /* Enforce secureops, etc */ if (enforce_mlock && MOD_RESULT != EVENT_STOP) @@ -335,7 +335,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *cm, const Anop cml->OnAdd(this, param); } - FOREACH_RESULT(I_OnChannelModeSet, OnChannelModeSet(this, setter, cm->name, param)); + FOREACH_RESULT(OnChannelModeSet, MOD_RESULT, (this, setter, cm->name, param)); /* Check if we should enforce mlock */ if (!enforce_mlock || MOD_RESULT == EVENT_STOP) @@ -376,7 +376,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A if (cc) cc->status.DelMode(cm->mchar); - FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, setter, cm->name, param)); + FOREACH_RESULT(OnChannelModeUnset, MOD_RESULT, (this, setter, cm->name, param)); if (enforce_mlock && MOD_RESULT != EVENT_STOP) this->SetCorrectModes(u, false); @@ -403,7 +403,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A cml->OnDel(this, param); } - FOREACH_RESULT(I_OnChannelModeUnset, OnChannelModeUnset(this, setter, cm->name, param)); + FOREACH_RESULT(OnChannelModeUnset, MOD_RESULT, (this, setter, cm->name, param)); /* Check for mlock */ if (!enforce_mlock || MOD_RESULT == EVENT_STOP) @@ -752,9 +752,9 @@ void Channel::KickInternal(MessageSource &source, const Anope::string &nick, con Anope::string this_name = this->name; ChannelStatus status = cu->status; - FOREACH_MOD(I_OnPreUserKicked, OnPreUserKicked(source, cu, reason)); + FOREACH_MOD(OnPreUserKicked, (source, cu, reason)); this->DeleteUser(target); /* This can delete this; */ - FOREACH_MOD(I_OnUserKicked, OnUserKicked(source, target, this_name, status, reason)); + FOREACH_MOD(OnUserKicked, (source, target, this_name, status, reason)); } bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...) @@ -777,7 +777,7 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...) bi = this->ci->WhoSends(); EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnBotKick, OnBotKick(bi, this, u, buf)); + FOREACH_RESULT(OnBotKick, MOD_RESULT, (bi, this, u, buf)); if (MOD_RESULT == EVENT_STOP) return false; IRCD->SendKick(bi, this, u, "%s", buf); @@ -797,7 +797,7 @@ void Channel::ChangeTopicInternal(const Anope::string &user, const Anope::string Log(LOG_DEBUG) << "Topic of " << this->name << " changed by " << (u ? u->nick : user) << " to " << newtopic; - FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, user, this->topic)); + FOREACH_MOD(OnTopicUpdated, (this, user, this->topic)); } void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts) @@ -813,7 +813,7 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop /* Now that the topic is set update the time set. This is *after* we set it so the protocol modules are able to tell the old last set time */ this->topic_time = Anope::CurTime; - FOREACH_MOD(I_OnTopicUpdated, OnTopicUpdated(this, user, this->topic)); + FOREACH_MOD(OnTopicUpdated, (this, user, this->topic)); } void Channel::SetCorrectModes(User *user, bool give_modes) @@ -836,7 +836,7 @@ void Channel::SetCorrectModes(User *user, bool give_modes) */ bool take_modes = (registered && !this->HasMode("REGISTERED")) || (!registered && this->syncing && user->server->IsSynced()); - FOREACH_MOD(I_OnSetCorrectModes, OnSetCorrectModes(user, this, u_access, give_modes, take_modes)); + FOREACH_MOD(OnSetCorrectModes, (user, this, u_access, give_modes, take_modes)); /* Never take modes from ulines */ take_modes &= !user->server->IsULined(); diff --git a/src/command.cpp b/src/command.cpp index 421c90b93..c3131bda2 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -259,7 +259,7 @@ void Command::Run(CommandSource &source, const Anope::string &message) source.permission = info.permission; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreCommand, OnPreCommand(source, c, params)); + FOREACH_RESULT(OnPreCommand, MOD_RESULT, (source, c, params)); if (MOD_RESULT == EVENT_STOP) return; @@ -279,7 +279,7 @@ void Command::Run(CommandSource &source, const Anope::string &message) } c->Execute(source, params); - FOREACH_MOD(I_OnPostCommand, OnPostCommand(source, c, params)); + FOREACH_MOD(OnPostCommand, (source, c, params)); } bool Command::FindCommandFromService(const Anope::string &command_service, BotInfo* &bot, Anope::string &name) diff --git a/src/config.cpp b/src/config.cpp index d90c9728c..e560a6896 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -130,7 +130,7 @@ Conf::Conf() : Block("") this->LoadConf(f); } - FOREACH_MOD(I_OnReload, OnReload(this)); + FOREACH_MOD(OnReload, (this)); /* Check for modified values that aren't allowed to be modified */ if (Config) diff --git a/src/init.cpp b/src/init.cpp index 0a93c07f5..3cd27cddd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -463,7 +463,7 @@ void Anope::Init(int ac, char **av) /* Load up databases */ Log() << "Loading databases..."; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnLoadDatabase, OnLoadDatabase()); + FOREACH_RESULT(OnLoadDatabase, MOD_RESULT, ()); static_cast<void>(MOD_RESULT); Log() << "Databases loaded"; diff --git a/src/logger.cpp b/src/logger.cpp index 3873c1dee..f5b7ff55c 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -129,7 +129,7 @@ Log::~Log() else if (this->type == LOG_TERMINAL) std::cout << this->BuildPrefix() << this->buf.str() << std::endl; - FOREACH_MOD(I_OnLog, OnLog(this)); + FOREACH_MOD(OnLog, (this)); if (Config) for (unsigned i = 0; i < Config->LogInfos.size(); ++i) diff --git a/src/main.cpp b/src/main.cpp index 576df28a6..d799d9a21 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -60,7 +60,7 @@ class ExpireTimer : public Timer void Tick(time_t) anope_override { - FOREACH_MOD(I_OnExpireTick, OnExpireTick()); + FOREACH_MOD(OnExpireTick, ()); } }; @@ -70,7 +70,7 @@ void Anope::SaveDatabases() return; Log(LOG_DEBUG) << "Saving databases"; - FOREACH_MOD(I_OnSaveDatabase, OnSaveDatabase()); + FOREACH_MOD(OnSaveDatabase, ()); } /** The following comes from InspIRCd to get the full path of the Anope executable @@ -181,11 +181,11 @@ int main(int ac, char **av, char **envp) if (Anope::Restarting) { - FOREACH_MOD(I_OnRestart, OnRestart()); + FOREACH_MOD(OnRestart, ()); } else { - FOREACH_MOD(I_OnShutdown, OnShutdown()); + FOREACH_MOD(OnShutdown, ()); } if (Anope::QuitReason.empty()) diff --git a/src/messages.cpp b/src/messages.cpp index d9a89ef46..f651b7352 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -25,7 +25,7 @@ using namespace Message; void Away::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { - FOREACH_MOD(I_OnUserAway, OnUserAway(source.GetUser(), params.empty() ? "" : params[0])); + FOREACH_MOD(OnUserAway, (source.GetUser(), params.empty() ? "" : params[0])); } void Capab::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -57,7 +57,7 @@ void Invite::Run(MessageSource &source, const std::vector<Anope::string> ¶ms if (!targ || targ->server != Me || !c || c->FindUser(targ)) return; - FOREACH_MOD(I_OnInvite, OnInvite(source.GetUser(), c, targ)); + FOREACH_MOD(OnInvite, (source.GetUser(), c, targ)); } void Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) @@ -79,9 +79,9 @@ void Join::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) ++it; Anope::string channame = cc->chan->name; - FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, cc->chan)); + FOREACH_MOD(OnPrePartChannel, (user, cc->chan)); cc->chan->DeleteUser(user); - FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, Channel::Find(channame), channame, "")); + FOREACH_MOD(OnPartChannel, (user, Channel::Find(channame), channame, "")); } continue; } @@ -261,10 +261,10 @@ void Part::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) continue; Log(u, c, "part") << "Reason: " << (!reason.empty() ? reason : "No reason"); - FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(u, c)); + FOREACH_MOD(OnPrePartChannel, (u, c)); Anope::string ChannelName = c->name; c->DeleteUser(u); - FOREACH_MOD(I_OnPartChannel, OnPartChannel(u, c, ChannelName, !reason.empty() ? reason : "")); + FOREACH_MOD(OnPartChannel, (u, c, ChannelName, !reason.empty() ? reason : "")); } } @@ -285,7 +285,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m Channel *c = Channel::Find(receiver); if (c) { - FOREACH_MOD(I_OnPrivmsg, OnPrivmsg(u, c, message)); + FOREACH_MOD(OnPrivmsg, (u, c, message)); } } else @@ -316,7 +316,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m if (bi) { EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnBotPrivmsg, OnBotPrivmsg(u, bi, message)); + FOREACH_RESULT(OnBotPrivmsg, MOD_RESULT, (u, bi, message)); if (MOD_RESULT == EVENT_STOP) return; @@ -364,7 +364,7 @@ void SQuit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) return; } - FOREACH_MOD(I_OnServerQuit, OnServerQuit(s)); + FOREACH_MOD(OnServerQuit, (s)); s->Delete(s->GetName() + " " + s->GetUplink()->GetName()); } diff --git a/src/misc.cpp b/src/misc.cpp index 6fb9e8c91..fd08ffb2a 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -477,7 +477,7 @@ bool Anope::Match(const Anope::string &str, const Anope::string &mask, bool case void Anope::Encrypt(const Anope::string &src, Anope::string &dest) { EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnEncrypt, OnEncrypt(src, dest)); + FOREACH_RESULT(OnEncrypt, MOD_RESULT, (src, dest)); static_cast<void>(MOD_RESULT); } @@ -492,7 +492,7 @@ bool Anope::Decrypt(const Anope::string &src, Anope::string &dest) Anope::string hashm(src.begin(), src.begin() + pos); EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnDecrypt, OnDecrypt(hashm, src, dest)); + FOREACH_RESULT(OnDecrypt, MOD_RESULT, (hashm, src, dest)); if (MOD_RESULT == EVENT_ALLOW) return true; diff --git a/src/modes.cpp b/src/modes.cpp index 2e9a49f09..8eab97480 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -140,7 +140,7 @@ ChannelMode::~ChannelMode() bool ChannelMode::CanSet(User *u) const { EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnCanSet, OnCanSet(u, this)); + FOREACH_RESULT(OnCanSet, MOD_RESULT, (u, this)); return MOD_RESULT != EVENT_STOP; } @@ -350,7 +350,7 @@ bool ModeManager::AddUserMode(UserMode *um) UserModesByName[um->name] = um; - FOREACH_MOD(I_OnUserModeAdd, OnUserModeAdd(um)); + FOREACH_MOD(OnUserModeAdd, (um)); return true; } @@ -384,7 +384,7 @@ bool ModeManager::AddChannelMode(ChannelMode *cm) ChannelModesByName[cm->name] = cm; - FOREACH_MOD(I_OnChannelModeAdd, OnChannelModeAdd(cm)); + FOREACH_MOD(OnChannelModeAdd, (cm)); return true; } diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 211304cae..a3719b412 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -22,7 +22,7 @@ #endif std::list<Module *> ModuleManager::Modules; -std::vector<Module *> ModuleManager::EventHandlers[I_END]; +std::map<Anope::string, std::vector<Module *> > ModuleManager::EventHandlers; #ifdef _WIN32 void ModuleManager::CleanupRuntimeDirectory() @@ -112,6 +112,19 @@ static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &out } #endif +std::vector<Module *> &ModuleManager::GetEventHandlers(const Anope::string &name) +{ + std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.find(name); + if (it != EventHandlers.end()) + return it->second; + + std::vector<Module *> &modules = EventHandlers[name]; + /* Populate initial vector */ + std::copy(Modules.begin(), Modules.end(), std::back_inserter(modules)); + + return modules; +} + /* This code was found online at http://www.linuxjournal.com/article/3687#comment-26593 * * This function will take a pointer from either dlsym or GetProcAddress and cast it in @@ -226,24 +239,38 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) else Log(LOG_DEBUG_2) << "Module " << modname << " is compiled against current version of Anope " << Anope::VersionShort(); - /* If the module is hooked to the reload event it wants to initialize its config here */ - if (std::find(EventHandlers[I_OnReload].begin(), EventHandlers[I_OnReload].end(), m) != EventHandlers[I_OnReload].end()) + /* Initialize config */ + try + { + m->OnReload(Config); + } + catch (const ModuleException &ex) + { + Log() << "Module " << modname << " couldn't load:" << ex.GetReason(); + DeleteModule(m); + return MOD_ERR_EXCEPTION; + } + catch (const ConfigException &ex) + { + Log() << "Module " << modname << " couldn't load due to configuration problems: " << ex.GetReason(); + DeleteModule(m); + return MOD_ERR_EXCEPTION; + } + catch (const NotImplementedException &ex) { - try - { - m->OnReload(Config); - } - catch (const ConfigException &ex) - { - Log() << "Module " << modname << " couldn't load due to configuration problems: " << ex.GetReason(); - DeleteModule(m); - return MOD_ERR_EXCEPTION; - } } Log(LOG_DEBUG) << "Module " << modname << " loaded."; - FOREACH_MOD(I_OnModuleLoad, OnModuleLoad(u, m)); + /* Attach module to all events */ + for (std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.begin(); it != EventHandlers.end(); ++it) + /* Modules can already be attached here if loading them causes a new event to trigged, which initializes this vector + * to all known modules, which includes this one. + */ + if (std::find(it->second.begin(), it->second.end(), m) != it->second.end()) + it->second.push_back(m); + + FOREACH_MOD(OnModuleLoad, (u, m)); return MOD_ERR_OK; } @@ -253,7 +280,7 @@ ModuleReturn ModuleManager::UnloadModule(Module *m, User *u) if (!m) return MOD_ERR_PARAMS; - FOREACH_MOD(I_OnModuleUnload, OnModuleUnload(u, m)); + FOREACH_MOD(OnModuleUnload, (u, m)); return DeleteModule(m); } @@ -340,47 +367,26 @@ ModuleReturn ModuleManager::DeleteModule(Module *m) return MOD_ERR_OK; } -bool ModuleManager::Attach(Implementation i, Module *mod) -{ - if (std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod) != EventHandlers[i].end()) - return false; - - EventHandlers[i].push_back(mod); - return true; -} - -bool ModuleManager::Detach(Implementation i, Module *mod) -{ - std::vector<Module *>::iterator x = std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod); - - if (x == EventHandlers[i].end()) - return false; - - EventHandlers[i].erase(x); - return true; -} - -void ModuleManager::Attach(Implementation *i, Module *mod, size_t sz) -{ - for (size_t n = 0; n < sz; ++n) - Attach(i[n], mod); -} - void ModuleManager::DetachAll(Module *mod) { - for (size_t n = I_BEGIN + 1; n != I_END; ++n) - Detach(static_cast<Implementation>(n), mod); + for (std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.begin(); it != EventHandlers.end(); ++it) + { + std::vector<Module *> &mods = it->second; + std::vector<Module *>::iterator it2 = std::find(mods.begin(), mods.end(), mod); + if (it2 != mods.end()) + mods.erase(it2); + } } bool ModuleManager::SetPriority(Module *mod, Priority s) { - for (size_t n = I_BEGIN + 1; n != I_END; ++n) - SetPriority(mod, static_cast<Implementation>(n), s); + for (std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.begin(); it != EventHandlers.end(); ++it) + SetPriority(mod, it->first, s); return true; } -bool ModuleManager::SetPriority(Module *mod, Implementation i, Priority s, Module **modules, size_t sz) +bool ModuleManager::SetPriority(Module *mod, const Anope::string &i, Priority s, Module **modules, size_t sz) { /** To change the priority of a module, we first find its position in the vector, * then we find the position of the other modules in the vector that this module diff --git a/src/nickalias.cpp b/src/nickalias.cpp index 327340a1d..1595987e4 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -51,7 +51,7 @@ NickAlias::NickAlias(const Anope::string &nickname, NickCore* nickcore) : Serial NickAlias::~NickAlias() { - FOREACH_MOD(I_OnDelNick, OnDelNick(this)); + FOREACH_MOD(OnDelNick, (this)); /* Accept nicks that have no core, because of database load functions */ if (this->nc) diff --git a/src/nickcore.cpp b/src/nickcore.cpp index 9e2ff8dbb..5779767dd 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -33,12 +33,12 @@ NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), if (old == NickCoreList->size()) Log(LOG_DEBUG) << "Duplicate account " << coredisplay << " in nickcore table?"; - FOREACH_MOD(I_OnNickCoreCreate, OnNickCoreCreate(this)); + FOREACH_MOD(OnNickCoreCreate, (this)); } NickCore::~NickCore() { - FOREACH_MOD(I_OnDelCore, OnDelCore(this)); + FOREACH_MOD(OnDelCore, (this)); if (!this->chanaccess->empty()) Log(LOG_DEBUG) << "Non-empty chanaccess list in destructor!"; @@ -140,7 +140,7 @@ void NickCore::SetDisplay(const NickAlias *na) if (na->nc != this || na->nick == this->display) return; - FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(this, na->nick)); + FOREACH_MOD(OnChangeCoreDisplay, (this, na->nick)); /* Remove the core from the list */ NickCoreList->erase(this->display); @@ -158,7 +158,7 @@ bool NickCore::IsServicesOper() const void NickCore::AddAccess(const Anope::string &entry) { this->access.push_back(entry); - FOREACH_MOD(I_OnNickAddAccess, OnNickAddAccess(this, entry)); + FOREACH_MOD(OnNickAddAccess, (this, entry)); } Anope::string NickCore::GetAccess(unsigned entry) const @@ -187,7 +187,7 @@ void NickCore::EraseAccess(const Anope::string &entry) for (unsigned i = 0, end = this->access.size(); i < end; ++i) if (this->access[i] == entry) { - FOREACH_MOD(I_OnNickEraseAccess, OnNickEraseAccess(this, entry)); + FOREACH_MOD(OnNickEraseAccess, (this, entry)); this->access.erase(this->access.begin() + i); break; } @@ -195,7 +195,7 @@ void NickCore::EraseAccess(const Anope::string &entry) void NickCore::ClearAccess() { - FOREACH_MOD(I_OnNickClearAccess, OnNickClearAccess(this)); + FOREACH_MOD(OnNickClearAccess, (this)); this->access.clear(); } @@ -219,7 +219,7 @@ bool NickCore::IsOnAccess(const User *u) const void NickCore::AddCert(const Anope::string &entry) { this->cert.push_back(entry); - FOREACH_MOD(I_OnNickAddCert, OnNickAddCert(this, entry)); + FOREACH_MOD(OnNickAddCert, (this, entry)); } Anope::string NickCore::GetCert(unsigned entry) const @@ -243,7 +243,7 @@ void NickCore::EraseCert(const Anope::string &entry) for (unsigned i = 0, end = this->cert.size(); i < end; ++i) if (this->cert[i] == entry) { - FOREACH_MOD(I_OnNickEraseCert, OnNickEraseCert(this, entry)); + FOREACH_MOD(OnNickEraseCert, (this, entry)); this->cert.erase(this->cert.begin() + i); break; } @@ -251,7 +251,7 @@ void NickCore::EraseCert(const Anope::string &entry) void NickCore::ClearCert() { - FOREACH_MOD(I_OnNickClearCert, OnNickClearCert(this)); + FOREACH_MOD(OnNickClearCert, (this)); this->cert.clear(); } diff --git a/src/process.cpp b/src/process.cpp index a767b87c2..649228f03 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -70,7 +70,7 @@ void Anope::Process(const Anope::string &buffer) MessageSource src(source); EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnMessage, OnMessage(src, command, params)); + FOREACH_RESULT(OnMessage, MOD_RESULT, (src, command, params)); if (MOD_RESULT == EVENT_STOP) return; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 2fcb3ca14..bd8c3dca0 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -292,7 +292,7 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Serializable("ChannelInf if (old == RegisteredChannelList->size()) Log(LOG_DEBUG) << "Duplicate channel " << this->name << " in registered channel table?"; - FOREACH_MOD(I_OnCreateChan, OnCreateChan(this)); + FOREACH_MOD(OnCreateChan, (this)); } ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Serializable("ChannelInfo"), @@ -348,12 +348,12 @@ ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Serializable("ChannelInfo"), this->log_settings->push_back(l); } - FOREACH_MOD(I_OnCreateChan, OnCreateChan(this)); + FOREACH_MOD(OnCreateChan, (this)); } ChannelInfo::~ChannelInfo() { - FOREACH_MOD(I_OnDelChan, OnDelChan(this)); + FOREACH_MOD(OnDelChan, (this)); Log(LOG_DEBUG) << "Deleting channel " << this->name; @@ -766,7 +766,7 @@ BadWord* ChannelInfo::AddBadWord(const Anope::string &word, BadWordType type) this->badwords->push_back(bw); - FOREACH_MOD(I_OnBadWordAdd, OnBadWordAdd(this, bw)); + FOREACH_MOD(OnBadWordAdd, (this, bw)); return bw; } @@ -791,7 +791,7 @@ void ChannelInfo::EraseBadWord(unsigned index) if (this->badwords->empty() || index >= this->badwords->size()) return; - FOREACH_MOD(I_OnBadWordDel, OnBadWordDel(this, (*this->badwords)[index])); + FOREACH_MOD(OnBadWordDel, (this, (*this->badwords)[index])); delete this->badwords->at(index); } @@ -838,7 +838,7 @@ bool ChannelInfo::SetMLock(ChannelMode *mode, bool status, const Anope::string & std::pair<Anope::string, ModeLock *> ml = std::make_pair(mode->name, new ModeLock(this, status, mode->name, param, setter, created)); EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnMLock, OnMLock(this, ml.second)); + FOREACH_RESULT(OnMLock, MOD_RESULT, (this, ml.second)); if (MOD_RESULT == EVENT_STOP) return false; @@ -891,7 +891,7 @@ bool ChannelInfo::RemoveMLock(ChannelMode *mode, bool status, const Anope::strin continue; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnUnMLock, OnUnMLock(this, it->second)); + FOREACH_RESULT(OnUnMLock, MOD_RESULT, (this, it->second)); if (MOD_RESULT != EVENT_STOP) { delete it->second; @@ -913,7 +913,7 @@ bool ChannelInfo::RemoveMLock(ChannelMode *mode, bool status, const Anope::strin if (ml->set == status && ml->param == param) { EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnUnMLock, OnUnMLock(this, it->second)); + FOREACH_RESULT(OnUnMLock, MOD_RESULT, (this, it->second)); if (MOD_RESULT == EVENT_STOP) return false; delete it->second; @@ -1026,7 +1026,7 @@ bool ChannelInfo::CheckKick(User *user) Anope::string mask, reason; EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnCheckKick, OnCheckKick(user, this, mask, reason)); + FOREACH_RESULT(OnCheckKick, MOD_RESULT, (user, this, mask, reason)); if (MOD_RESULT != EVENT_STOP) return false; diff --git a/src/serialize.cpp b/src/serialize.cpp index bb95cdc41..ef79bc396 100644 --- a/src/serialize.cpp +++ b/src/serialize.cpp @@ -55,7 +55,7 @@ Serializable::Serializable(const Anope::string &serialize_type) : last_commit(0) this->s_iter = SerializableItems->end(); --this->s_iter; - FOREACH_MOD(I_OnSerializableConstruct, OnSerializableConstruct(this)); + FOREACH_MOD(OnSerializableConstruct, (this)); } Serializable::Serializable(const Serializable &other) : last_commit(0), last_commit_time(0), id(0), redis_ignore(0) @@ -66,12 +66,12 @@ Serializable::Serializable(const Serializable &other) : last_commit(0), last_com this->s_type = other.s_type; - FOREACH_MOD(I_OnSerializableConstruct, OnSerializableConstruct(this)); + FOREACH_MOD(OnSerializableConstruct, (this)); } Serializable::~Serializable() { - FOREACH_MOD(I_OnSerializableDestruct, OnSerializableDestruct(this)); + FOREACH_MOD(OnSerializableDestruct, (this)); SerializableItems->erase(this->s_iter); } @@ -84,10 +84,10 @@ Serializable &Serializable::operator=(const Serializable &) void Serializable::QueueUpdate() { /* Schedule updater */ - FOREACH_MOD(I_OnSerializableUpdate, OnSerializableUpdate(this)); + FOREACH_MOD(OnSerializableUpdate, (this)); /* Check for modifications now - this can delete this object! */ - FOREACH_MOD(I_OnSerializeCheck, OnSerializeCheck(this->GetSerializableType())); + FOREACH_MOD(OnSerializeCheck, (this->GetSerializableType())); } bool Serializable::IsCached(Serialize::Data &data) @@ -120,7 +120,7 @@ Type::Type(const Anope::string &n, unserialize_func f, Module *o) : name(n), un TypeOrder.push_back(this->name); Types[this->name] = this; - FOREACH_MOD(I_OnSerializeTypeCreate, OnSerializeTypeCreate(this)); + FOREACH_MOD(OnSerializeTypeCreate, (this)); } Type::~Type() @@ -138,7 +138,7 @@ Serializable *Type::Unserialize(Serializable *obj, Serialize::Data &data) void Type::Check() { - FOREACH_MOD(I_OnSerializeCheck, OnSerializeCheck(this)); + FOREACH_MOD(OnSerializeCheck, (this)); } time_t Type::GetTimestamp() const diff --git a/src/servers.cpp b/src/servers.cpp index d8fc84a81..ee4891138 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -118,7 +118,7 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano } } - FOREACH_MOD(I_OnNewServer, OnNewServer(this)); + FOREACH_MOD(OnNewServer, (this)); } Server::~Server() @@ -152,7 +152,7 @@ Server::~Server() void Server::Delete(const Anope::string &reason) { this->quit_reason = reason; - FOREACH_MOD(I_OnServerQuit, OnServerQuit(this)); + FOREACH_MOD(OnServerQuit, (this)); delete this; } @@ -237,7 +237,7 @@ void Server::Sync(bool sync_links) Log(this, "sync") << "is done syncing"; - FOREACH_MOD(I_OnServerSync, OnServerSync(this)); + FOREACH_MOD(OnServerSync, (this)); if (sync_links && !this->links.empty()) { @@ -247,7 +247,7 @@ void Server::Sync(bool sync_links) if (this->GetUplink() && this->GetUplink() == Me) { - FOREACH_MOD(I_OnPreUplinkSync, OnPreUplinkSync(this)); + FOREACH_MOD(OnPreUplinkSync, (this)); for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) { @@ -258,7 +258,7 @@ void Server::Sync(bool sync_links) IRCD->SendEOB(); Me->Sync(false); - FOREACH_MOD(I_OnUplinkSync, OnUplinkSync(this)); + FOREACH_MOD(OnUplinkSync, (this)); if (!Anope::NoFork && Anope::AtTerm()) { diff --git a/src/uplink.cpp b/src/uplink.cpp index dccdbf8fb..9f2caa02d 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -46,7 +46,7 @@ void Uplink::Connect() new UplinkSocket(); if (!Config->GetBlock("serverinfo")->Get<const Anope::string>("localhost").empty()) UplinkSock->Bind(Config->GetBlock("serverinfo")->Get<const Anope::string>("localhost")); - FOREACH_MOD(I_OnPreServerConnect, OnPreServerConnect()); + FOREACH_MOD(OnPreServerConnect, ()); Anope::string ip = Anope::Resolve(u.host, u.ipv6 ? AF_INET6 : AF_INET); Log(LOG_TERMINAL) << "Attempting to connect to uplink #" << (Anope::CurrentUplink + 1) << " " << u.host << " (" << ip << "), port " << u.port; UplinkSock->Connect(ip, u.port); @@ -62,7 +62,7 @@ UplinkSocket::~UplinkSocket() { if (IRCD && Servers::GetUplink() && Servers::GetUplink()->IsSynced()) { - FOREACH_MOD(I_OnServerDisconnect, OnServerDisconnect()); + FOREACH_MOD(OnServerDisconnect, ()); for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { @@ -129,7 +129,7 @@ void UplinkSocket::OnConnect() { Log(LOG_TERMINAL) << "Successfully connected to uplink #" << (Anope::CurrentUplink + 1) << " " << Config->Uplinks[Anope::CurrentUplink].host << ":" << Config->Uplinks[Anope::CurrentUplink].port; IRCD->SendConnect(); - FOREACH_MOD(I_OnServerConnect, OnServerConnect()); + FOREACH_MOD(OnServerConnect, ()); } void UplinkSocket::OnError(const Anope::string &error) diff --git a/src/users.cpp b/src/users.cpp index cba624104..cc99cd63e 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -83,7 +83,7 @@ User::User(const Anope::string &snick, const Anope::string &sident, const Anope: bool exempt = false; if (server && server->IsULined()) exempt = true; - FOREACH_MOD(I_OnUserConnect, OnUserConnect(this, exempt)); + FOREACH_MOD(OnUserConnect, (this, exempt)); } void User::ChangeNick(const Anope::string &newnick, time_t ts) @@ -122,7 +122,7 @@ void User::ChangeNick(const Anope::string &newnick, time_t ts) } } - FOREACH_MOD(I_OnUserNickChange, OnUserNickChange(this, old)); + FOREACH_MOD(OnUserNickChange, (this, old)); } void User::SetDisplayedHost(const Anope::string &shost) @@ -236,7 +236,7 @@ User::~User() --this->server->users; } - FOREACH_MOD(I_OnPreUserLogoff, OnPreUserLogoff(this)); + FOREACH_MOD(OnPreUserLogoff, (this)); ModeManager::StackerDel(this); this->Logout(); @@ -251,7 +251,7 @@ User::~User() if (!this->uid.empty()) UserListByUID.erase(this->uid); - FOREACH_MOD(I_OnPostUserLogoff, OnPostUserLogoff(this)); + FOREACH_MOD(OnPostUserLogoff, (this)); } void User::SendMessage(const BotInfo *source, const char *fmt, ...) @@ -302,7 +302,7 @@ void User::Identify(NickAlias *na) this->Login(na->nc); IRCD->SendLogin(this); - FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(this)); + FOREACH_MOD(OnNickIdentify, (this)); if (this->IsServicesOper()) { @@ -338,7 +338,7 @@ void User::Login(NickCore *core) if (this->server->IsSynced()) Log(this, "account") << "is now identified as " << this->nc->display; - FOREACH_MOD(I_OnUserLogin, OnUserLogin(this)); + FOREACH_MOD(OnUserLogin, (this)); } void User::Logout() @@ -406,7 +406,7 @@ bool User::IsServicesOper() } EventReturn MOD_RESULT; - FOREACH_RESULT(I_IsServicesOper, IsServicesOper(this)); + FOREACH_RESULT(IsServicesOper, MOD_RESULT, (this)); if (MOD_RESULT == EVENT_STOP) return false; @@ -458,7 +458,7 @@ void User::SetModeInternal(UserMode *um, const Anope::string ¶m) this->modes[um->name] = param; - FOREACH_MOD(I_OnUserModeSet, OnUserModeSet(this, um->name)); + FOREACH_MOD(OnUserModeSet, (this, um->name)); } void User::RemoveModeInternal(UserMode *um) @@ -468,7 +468,7 @@ void User::RemoveModeInternal(UserMode *um) this->modes.erase(um->name); - FOREACH_MOD(I_OnUserModeUnset, OnUserModeUnset(this, um->name)); + FOREACH_MOD(OnUserModeUnset, (this, um->name)); } void User::SetMode(const BotInfo *bi, UserMode *um, const Anope::string &Param) @@ -668,7 +668,7 @@ void User::Quit(const Anope::string &reason) return; } - FOREACH_MOD(I_OnUserQuit, OnUserQuit(this, reason)); + FOREACH_MOD(OnUserQuit, (this, reason)); this->quit = true; quitting_users.push_back(this); |