]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services.cpp
Change module versions to use a string instead of fixed digits, and use propset ID...
[user/henk/code/inspircd.git] / src / modules / m_services.cpp
index 92c9c6d3ad376d775797e2adfb17aa1e8f9dc52d..9b10b2f5e5425a62f413c1f00c503ef9c9cb15bc 100644 (file)
@@ -21,7 +21,7 @@ static bool kludgeme = false;
  */
 class Channel_r : public ModeHandler
 {
-       
+
  public:
        Channel_r(InspIRCd* Instance) : ModeHandler(Instance, 'r', 0, 0, false, MODETYPE_CHANNEL, false) { }
 
@@ -30,8 +30,14 @@ class Channel_r : public ModeHandler
                // only a u-lined server may add or remove the +r mode.
                if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server || (source->nick.find('.') != std::string::npos)))
                {
-                       channel->SetMode('r',adding);
-                       return MODEACTION_ALLOW;
+                       // Only change the mode if it's not redundant
+                       if ((adding && !channel->IsModeSet('r')) || (!adding && channel->IsModeSet('r')))
+                       {
+                               channel->SetMode('r',adding);
+                               return MODEACTION_ALLOW;
+                       }
+
+                       return MODEACTION_DENY;
                }
                else
                {
@@ -45,7 +51,7 @@ class Channel_r : public ModeHandler
  */
 class User_r : public ModeHandler
 {
-       
+
  public:
        User_r(InspIRCd* Instance) : ModeHandler(Instance, 'r', 0, 0, false, MODETYPE_USER, false) { }
 
@@ -96,7 +102,7 @@ class Channel_M : public SimpleChannelModeHandler
  */
 class ModuleServices : public Module
 {
-       
+
        Channel_r* m1;
        Channel_R* m2;
        Channel_M* m3;
@@ -106,7 +112,7 @@ class ModuleServices : public Module
        ModuleServices(InspIRCd* Me)
                : Module(Me)
        {
-               
+
                m1 = new Channel_r(ServerInstance);
                m2 = new Channel_R(ServerInstance);
                m3 = new Channel_M(ServerInstance);
@@ -118,7 +124,7 @@ class ModuleServices : public Module
                {
                        throw ModuleException("Could not add user and channel modes!");
                }
-       
+
                kludgeme = false;
                Implementation eventlist[] = { I_OnWhois, I_OnUserPostNick, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin };
                ServerInstance->Modules->Attach(eventlist, this, 5);
@@ -148,7 +154,7 @@ class ModuleServices : public Module
                        kludgeme = false;
                }
        }
-       
+
        virtual int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (!IS_LOCAL(user))
@@ -165,7 +171,7 @@ class ModuleServices : public Module
                                        return 0;
                                }
                                // user messaging a +M channel and is not registered
-                               user->WriteNumeric(477, "%s %s :You need a registered nickname to speak on this channel", user->nick.c_str(), c->name);
+                               user->WriteNumeric(477, "%s %s :You need a registered nickname to speak on this channel", user->nick.c_str(), c->name.c_str());
                                return 1;
                        }
                }
@@ -186,12 +192,12 @@ class ModuleServices : public Module
                }
                return 0;
        }
-       
+
        virtual int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
        {
                return OnUserPreMessage(user,dest,target_type,text,status, exempt_list);
        }
-       
+
        virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
        {
                if (chan)
@@ -206,7 +212,7 @@ class ModuleServices : public Module
                                                return 0;
                                        }
                                        // joining a +R channel and not identified
-                                       user->WriteNumeric(477, "%s %s :You need a registered nickname to join this channel", user->nick.c_str(), chan->name);
+                                       user->WriteNumeric(477, "%s %s :You need a registered nickname to join this channel", user->nick.c_str(), chan->name.c_str());
                                        return 1;
                                }
                        }
@@ -228,7 +234,7 @@ class ModuleServices : public Module
                delete m4;
                delete m5;
        }
-       
+
        virtual Version GetVersion()
        {
                return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);