+
+ // We always apply the permchannels mode to permanent channels.
+ par.clear();
+ p.OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, c, par, true);
+ }
+ }
+ }
+
+ ModResult OnRawMode(User* user, Channel* chan, ModeHandler* mh, const std::string& param, bool adding) CXX11_OVERRIDE
+ {
+ if (chan && (chan->IsModeSet(p) || mh == &p))
+ dirty = true;
+
+ return MOD_RES_PASSTHRU;
+ }
+
+ void OnPostTopicChange(User*, Channel *c, const std::string&) CXX11_OVERRIDE
+ {
+ if (c->IsModeSet(p))
+ dirty = true;
+ }
+
+ bool Tick(time_t) CXX11_OVERRIDE
+ {
+ if (dirty)
+ WriteDatabase(p, this, save_listmodes);
+ dirty = false;
+ return true;
+ }
+
+ void Prioritize() CXX11_OVERRIDE
+ {
+ // 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
+ 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
+ ProtocolInterface::ServerList serverlist;
+ ServerInstance->PI->GetServerList(serverlist);
+ if (serverlist.size() < 2)
+ {
+ try
+ {
+ LoadDatabase();
+ }
+ catch (CoreException& e)
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Error loading permchannels database: " + std::string(e.GetReason()));