From 27e58363dde28f4667761970fc7068be8fe047ac Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Mon, 3 Apr 2023 09:39:39 -0400 Subject: modules: Fix issue with unloading modules bound to OnMessage When unloaded, modules attached to OnMessage events would still be part of the list used by FOREACH_MOD to send events to, leading to a segfault. This changes the behavior of load and unload to place new modules at the *start* of the event handler arrays, leading them to already be processed by the time the bot gets to the ModuleManager. --- include/142bot/modules.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/142bot/modules.hpp b/include/142bot/modules.hpp index 27025b8..3af0253 100644 --- a/include/142bot/modules.hpp +++ b/include/142bot/modules.hpp @@ -73,7 +73,8 @@ enum Events { \ try \ { \ - if (!(*_i)->x) { \ + if (!(*_i)->x) { \ + list_to_call = loader->EventHandlers[y]; \ break; \ } \ } \ -- cgit v1.2.3