]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Alter SetModeParam to take const char* to save on casts, notice a load of modules...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 9 Jul 2006 16:40:58 +0000 (16:40 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 9 Jul 2006 16:40:58 +0000 (16:40 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4231 e03df62e-2008-0410-955e-edbf42e46eb7

include/channels.h
src/channels.cpp
src/modules/m_joinflood.cpp
src/modules/m_kicknorejoin.cpp
src/modules/m_messageflood.cpp
src/modules/m_redirect.cpp

index ade28470946ca8937319303448bf0d49e3ea3c5d..17e47c88db34fd7bb8cddf484d4fdb2b3c03187e 100644 (file)
@@ -173,7 +173,7 @@ class chanrec : public Extensible
         * @param parameter The parameter string to associate with this mode character
         * @param mode_on True if you want to set the mode or false if you want to remove it
         */
-       void SetModeParam(char mode,char* parameter,bool mode_on);
+       void SetModeParam(char mode,const char* parameter,bool mode_on);
  
        /** Returns true if a mode is set on a channel
          * @param mode The mode character you wish to query
index a25b2927c7ea0a3b7f196496adf00cde04ecba2d..632e198e53ea370e6765e351f3a94a29bca10a89 100644 (file)
@@ -65,7 +65,7 @@ void chanrec::SetMode(char mode,bool mode_on)
 }
 
 
-void chanrec::SetModeParam(char mode,char* parameter,bool mode_on)
+void chanrec::SetModeParam(char mode,const char* parameter,bool mode_on)
 {
        log(DEBUG,"SetModeParam called");
        
index 6cc54db685fa90a79409a5821bf865bfeb6a4a9a..43b45be69d612c18aa83f3ff04bf50c59a0f8b4d 100644 (file)
@@ -136,6 +136,8 @@ class JoinFlood : public ModeHandler
                                        {
                                                joinfloodsettings *f = new joinfloodsettings(nsecs,njoins);
                                                channel->Extend("joinflood",(char*)f);
+                                               channel->SetMode('j', true);
+                                               channel->SetModeParam('j', parameter.c_str(), true);
                                                return MODEACTION_ALLOW;
                                        }
                                }
@@ -153,6 +155,7 @@ class JoinFlood : public ModeHandler
                                joinfloodsettings *f = (joinfloodsettings*)channel->GetExt("joinflood");
                                DELETE(f);
                                channel->Shrink("joinflood");
+                               channel->SetMode('j', false);
                                return MODEACTION_ALLOW;
                        }
                }
index 770b79db31788835e22823bce14d4ea249e01d32..1c5333defeaf06ff896701d08ff94524e724a5c2 100644 (file)
@@ -40,6 +40,8 @@ class KickRejoin : public ModeHandler
                }
                if ((!adding) || (atoi(parameter.c_str()) > 0))
                {
+                       channel->SetModeParam('J', parameter.c_str(), adding);
+                       channel->SetMode('J', adding);
                        return MODEACTION_ALLOW;
                }
                else
index 2cbecfdac409e3b32160029972d481a078bdbf8c..bcec8248b23f3792a763200ab57eba5e9e9831ae 100644 (file)
@@ -135,6 +135,8 @@ class MsgFlood : public ModeHandler
                                        {
                                                floodsettings *f = new floodsettings(ban,nsecs,nlines);
                                                channel->Extend("flood",(char*)f);
+                                               channel->SetMode('f', true);
+                                               channel->SetModeParam('f', parameter.c_str(), true);
                                                return MODEACTION_ALLOW;
                                        }
                                }
@@ -153,6 +155,7 @@ class MsgFlood : public ModeHandler
                                floodsettings *f = (floodsettings*)channel->GetExt("flood");
                                DELETE(f);
                                channel->Shrink("flood");
+                               channel->SetMode('f', false);
                                return MODEACTION_ALLOW;
                        }
                }
index 799eb25deecb3f8ca906eb0ba5fae1ab51f0875c..e3da4622f400ce62b265aadc0e11ff87fce4db8d 100644 (file)
@@ -24,6 +24,42 @@ using namespace std;
 
 /* $ModDesc: Provides channel mode +L (limit redirection) */
 
+class Redirect : public ModeHandler
+{
+ public:
+       Redirect() : ModeHandler('L', 1, 0, false, MODETYPE_CHANNEL, false) { }
+
+       ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
+       {
+               if (adding)
+               {
+                       chanrec* c = NULL;
+
+                       if (!IsValidChannelName(parameter.c_str()))
+                       {
+                               WriteServ(user->fd,"403 %s %s :Invalid channel name",user->nick, parameter.c_str());
+                               parameter = "";
+                               return MODEACTION_DENY;
+                       }
+
+                       c = Srv->FindChannel(parameter);
+                       if (c)
+                       {
+                               /* Fix by brain: Dont let a channel be linked to *itself* either */
+                               if ((c == target) || (c->IsModeSet('L')))
+                               {
+                                       WriteServ(user->fd,"690 %s :Circular redirection, mode +L to %s not allowed.",user->nick,parameter.c_str());
+                                       parameter = "";
+                                       return MODEACTION_DENY;
+                               }
+                       }
+
+                       c->SetMode('L', true);
+                       c->SetModeParam('L', parameter);
+                       return MODEACTION_ALLOW;
+               }
+       }
+};
 
 class ModuleRedirect : public Module
 {