]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_permchannels.cpp
Merge pull request #514 from SaberUK/master+virtual-cleanup
[user/henk/code/inspircd.git] / src / modules / m_permchannels.cpp
index 27026bde9f5c38d94aff4bf1afeb5be9df526fb3..d7444845e355f80e5836a75a9e3d16df985c1108 100644 (file)
@@ -165,21 +165,13 @@ public:
        {
        }
 
-       void init()
+       void init() CXX11_OVERRIDE
        {
                ServerInstance->Modules->AddService(p);
                Implementation eventlist[] = { I_OnChannelPreDelete, I_OnPostTopicChange, I_OnRawMode, I_OnRehash, I_OnBackgroundTimer };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
 
                OnRehash(NULL);
-
-               // Load only when there are no linked servers - we set the TS of the channels we
-               // create to the current time, this can lead to desync because spanningtree has
-               // no way of knowing what we do
-               ProtoServerList serverlist;
-               ServerInstance->PI->GetServerList(serverlist);
-               if (serverlist.size() < 2)
-                       LoadDatabase();
        }
 
        CullResult cull()
@@ -208,7 +200,7 @@ public:
                return Module::cull();
        }
 
-       virtual void OnRehash(User *user)
+       void OnRehash(User *user) CXX11_OVERRIDE
        {
                permchannelsconf = ServerInstance->Config->ConfValue("permchanneldb")->getString("filename");
        }
@@ -279,7 +271,7 @@ public:
                }
        }
 
-       virtual ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt)
+       ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string &param, bool adding, int pcnt) CXX11_OVERRIDE
        {
                if (chan && (chan->IsModeSet('P') || mode == 'P'))
                        dirty = true;
@@ -287,25 +279,57 @@ public:
                return MOD_RES_PASSTHRU;
        }
 
-       virtual void OnPostTopicChange(User*, Channel *c, const std::string&)
+       void OnPostTopicChange(User*, Channel *c, const std::string&) CXX11_OVERRIDE
        {
                if (c->IsModeSet('P'))
                        dirty = true;
        }
 
-       void OnBackgroundTimer(time_t)
+       void OnBackgroundTimer(time_t) CXX11_OVERRIDE
        {
                if (dirty)
                        WriteDatabase();
                dirty = false;
        }
 
-       virtual Version GetVersion()
+       void Prioritize()
+       {
+               // XXX: Load the DB here because the order in which modules are init()ed at boot is
+               // alphabetical, this means we must wait until all modules have done their init()
+               // to be able to set the modes they provide (e.g.: m_stripcolor is inited after us)
+               // Prioritize() is called after all module initialization is complete, consequently
+               // all modes are available now
+
+               static bool loaded = false;
+               if (loaded)
+                       return;
+
+               loaded = true;
+
+               // Load only when there are no linked servers - we set the TS of the channels we
+               // create to the current time, this can lead to desync because spanningtree has
+               // no way of knowing what we do
+               ProtoServerList serverlist;
+               ServerInstance->PI->GetServerList(serverlist);
+               if (serverlist.size() < 2)
+               {
+                       try
+                       {
+                               LoadDatabase();
+                       }
+                       catch (CoreException& e)
+                       {
+                               ServerInstance->Logs->Log("m_permchannels", LOG_DEFAULT, "Error loading permchannels database: " + std::string(e.GetReason()));
+                       }
+               }
+       }
+
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides support for channel mode +P to provide permanent channels",VF_VENDOR);
        }
 
-       virtual ModResult OnChannelPreDelete(Channel *c)
+       ModResult OnChannelPreDelete(Channel *c) CXX11_OVERRIDE
        {
                if (c->IsModeSet('P'))
                        return MOD_RES_DENY;