From 0e758a2ac23dc4a001e8e126cec14588da9a9769 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 28 Jul 2016 21:29:35 -0400 Subject: Allow serializable fields to use storage in the respective objects. Split service management code nito a proper servicemanager. Make service references managed instead of lazy lookup. Also made events and serializable use service manager instead of their respective systems for management --- modules/botserv/main/botserv.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'modules/botserv/main') diff --git a/modules/botserv/main/botserv.cpp b/modules/botserv/main/botserv.cpp index 0b51691fc..a297db153 100644 --- a/modules/botserv/main/botserv.cpp +++ b/modules/botserv/main/botserv.cpp @@ -20,17 +20,25 @@ class BotServCore : public Module, public BotServ::BotServService , public EventHook , public EventHook , public EventHook - , public EventHook + , public EventHook , public EventHook , public EventHook { Reference BotServ; - ExtensibleRef persist, inhabit;//XXX? + ExtensibleRef inhabit; public: BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) , BotServ::BotServService(this) - , persist("PERSIST") + , EventHook(this) + , EventHook(this) + , EventHook(this) + , EventHook(this) + , EventHook(this) + , EventHook(this) + , EventHook(this) + , EventHook(this) + , EventHook(this) , inhabit("inhabit") { } @@ -119,7 +127,7 @@ class BotServCore : public Module, public BotServ::BotServService void OnLeaveChannel(User *u, Channel *c) override { /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ - if (c->ci && persist && persist->HasExt(c->ci)) + if (c->ci && c->ci->HasFieldS("PERSIST")) return; /* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediately @@ -132,9 +140,14 @@ class BotServCore : public Module, public BotServ::BotServService if (inhabit && inhabit->HasExt(c)) return; - /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */ - if (c->ci && c->ci->GetBot() && u != c->ci->GetBot() && c->users.size() - 1 <= Config->GetModule(this)->Get("minusers") && c->FindUser(c->ci->GetBot())) - c->ci->GetBot()->Part(c->ci->c); + if (c->ci) + { + ServiceBot *bot = c->ci->GetBot(); + + /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */ + if (bot && u != bot && c->users.size() - 1 <= Config->GetModule(this)->Get("minusers") && c->FindUser(bot)) + bot->Part(c); + } } EventReturn OnPreHelp(CommandSource &source, const std::vector ¶ms) override @@ -201,7 +214,7 @@ class BotServCore : public Module, public BotServ::BotServService return EVENT_CONTINUE; } - void OnCreateChan(ChanServ::Channel *ci) override + void OnChanRegistered(ChanServ::Channel *ci) override { /* Set default bot flags */ spacesepstream sep(Config->GetModule(this)->Get("defaults", "greet fantasy")); -- cgit