]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_blockamsg.cpp
Updates, should be able to safely unload client modules with queries in progress...
[user/henk/code/inspircd.git] / src / modules / m_blockamsg.cpp
index 8af55de0fda31cc84e6560da9a621344cdc15291..0ddaddd34445097aceaab6639b0718f30300c0f2 100644 (file)
@@ -32,7 +32,7 @@ extern time_t TIME;
 
 enum BlockAction { IBLOCK_KILL, IBLOCK_KILLOPERS, IBLOCK_NOTICE, IBLOCK_NOTICEOPERS, IBLOCK_SILENT };
 
-class BlockedMessage
+class BlockedMessage : public classbase
 {
 public:
        std::string message;
@@ -70,7 +70,7 @@ public:
                return Version(1,0,0,0,VF_VENDOR);
        }
        
-       virtual void OnRehash(std::string parameter)
+       virtual void OnRehash(const std::string &parameter)
        {
                ConfigReader* Conf = new ConfigReader;
                
@@ -91,10 +91,10 @@ public:
                else
                        action = IBLOCK_KILLOPERS;
 
-               delete Conf;
+               DELETE(Conf);
        }
 
-       virtual int OnPreCommand(std::string command, char **parameters, int pcnt, userrec *user, bool validated)
+       virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated)
        {
                // Don't do anything with unregistered users, or remote ones.
                if(!user || (user->registered != 7) || !IS_LOCAL(user))
@@ -117,7 +117,7 @@ public:
                        if(*parameters[0] != '#')
                                targets--;
                        
-                       for(char* c = parameters[0]; *c; c++)
+                       for(const char* c = parameters[0]; *c; c++)
                                if((*c == ',') && *(c+1) && (*(c+1) == '#'))
                                        targets++;
                                        
@@ -126,7 +126,8 @@ public:
                                        userchans++;
 
                        // Check that this message wasn't already sent within a few seconds.
-                       BlockedMessage* m = (BlockedMessage*)user->GetExt("amsgblock");
+                       BlockedMessage* m;
+                       user->GetExt("amsgblock", m);
                        
                        // If the message is identical and within the time.
                        // We check the target is *not* identical, that'd straying into the realms of flood control. Which isn't what we're doing...
@@ -168,10 +169,11 @@ public:
                if(target_type == TYPE_USER)
                {
                        userrec* user = (userrec*)item;
-                       BlockedMessage* m = (BlockedMessage*)user->GetExt("amsgblock");
+                       BlockedMessage* m;
+                       user->GetExt("amsgblock", m);
                        if(m)
                        {
-                               delete m;
+                               DELETE(m);
                                user->Shrink("amsgblock");
                        }
                }
@@ -201,4 +203,3 @@ extern "C" void * init_module( void )
 {
        return new ModuleBlockAmsgFactory;
 }
-