]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_reloadmodule.cpp
Use an oper priv instead of a config flag for overriding nonicks.
[user/henk/code/inspircd.git] / src / coremods / core_reloadmodule.cpp
index 755b49abfb95b73a19f89135aaf07c5ccd3bc94a..9101442216465c477df8dbfe5911ff47729e1215 100644 (file)
@@ -45,7 +45,7 @@ class CommandReloadmodule : public Command
         * @param user The user issuing the command
         * @return A value from CmdResult to indicate command success or failure.
         */
-       CmdResult Handle(const std::vector<std::string>& parameters, User *user);
+       CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE;
 };
 
 namespace ReloadModule
@@ -236,6 +236,10 @@ class DataKeeper
         * @param newmod Newly loaded instance of the module which had its data saved
         */
        void Restore(Module* newmod);
+
+       /** Handle reload failure
+        */
+       void Fail();
 };
 
 void DataKeeper::DoSaveUsers()
@@ -349,7 +353,8 @@ void DataKeeper::SaveMemberData(Channel* chan, std::vector<OwnedModesExts>& memb
                for (size_t j = 0; j < handledmodes[MODETYPE_CHANNEL].size(); j++)
                {
                        ModeHandler* mh = handledmodes[MODETYPE_CHANNEL][j].mh;
-                       if ((mh->IsPrefixMode()) && (memb->hasMode(mh->GetModeChar())))
+                       const PrefixMode* const pm = mh->IsPrefixMode();
+                       if ((pm) && (memb->HasMode(pm)))
                                currdata.modelist.push_back(InstanceData(j, memb->user->uuid)); // Need to pass the user's uuid to the mode parser to set the mode later
                }
 
@@ -468,6 +473,14 @@ void DataKeeper::Restore(Module* newmod)
        ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Restore finished");
 }
 
+void DataKeeper::Fail()
+{
+       this->mod = NULL;
+
+       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Restore failed, notifying modules");
+       DoRestoreModules();
+}
+
 void DataKeeper::RestoreObj(const OwnedModesExts& data, Extensible* extensible, ModeType modetype, Modes::ChangeList& modechange)
 {
        RestoreExtensions(data.extlist, extensible);
@@ -552,7 +565,7 @@ void DataKeeper::DoRestoreModules()
 
 } // namespace ReloadModule
 
-class ReloadAction : public HandlerBase0<void>
+class ReloadAction : public ActionBase
 {
        Module* const mod;
        const std::string uuid;
@@ -566,7 +579,7 @@ class ReloadAction : public HandlerBase0<void>
        {
        }
 
-       void Call()
+       void Call() CXX11_OVERRIDE
        {
                ReloadModule::DataKeeper datakeeper;
                datakeeper.Save(mod);
@@ -583,11 +596,13 @@ class ReloadAction : public HandlerBase0<void>
                        Module* newmod = ServerInstance->Modules->Find(name);
                        datakeeper.Restore(newmod);
                }
+               else
+                       datakeeper.Fail();
 
                ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded", passedname.c_str(), result ? "" : "un");
                User* user = ServerInstance->FindUUID(uuid);
                if (user)
-                       user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %ssuccessfully reloaded.", passedname.c_str(), result ? "" : "un");
+                       user->WriteNumeric(RPL_LOADEDMODULE, passedname, InspIRCd::Format("Module %ssuccessfully reloaded.", (result ? "" : "un")));
 
                ServerInstance->GlobalCulls.AddItem(this);
        }
@@ -598,8 +613,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter
        Module* m = ServerInstance->Modules->Find(parameters[0]);
        if (m == creator)
        {
-               user->WriteNumeric(RPL_LOADEDMODULE, "%s :You cannot reload core_reloadmodule.so (unload and load it)",
-                       parameters[0].c_str());
+               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "You cannot reload core_reloadmodule (unload and load it)");
                return CMD_FAILURE;
        }
 
@@ -613,7 +627,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter
        }
        else
        {
-               user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str());
+               user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Could not find module by that name");
                return CMD_FAILURE;
        }
 }