]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_alias.cpp
m_ssl_gnutls, m_ssl_openssl Simplify Handshake() result handling
[user/henk/code/inspircd.git] / src / modules / m_alias.cpp
index 2b38c894e807c5a9cc66f560ec76d5f10883fe1e..6bd59a78070a788eaf66b951fd84ea12dad841df 100644 (file)
@@ -63,7 +63,7 @@ class ModuleAlias : public Module
         * We can, however, use a fancy invention: the multimap. Maps a key to one or more values.
         *              -- w00t
      */
-       typedef std::multimap<std::string, Alias, irc::insensitive_swo> AliasMap;
+       typedef insp::flat_multimap<std::string, Alias, irc::insensitive_swo> AliasMap;
 
        AliasMap Aliases;
 
@@ -148,7 +148,7 @@ class ModuleAlias : public Module
                        return MOD_RES_PASSTHRU;
 
                /* The parameters for the command in their original form, with the command stripped off */
-               std::string compare = original_line.substr(command.length());
+               std::string compare(original_line, command.length());
                while (*(compare.c_str()) == ' ')
                        compare.erase(compare.begin());
 
@@ -212,7 +212,7 @@ class ModuleAlias : public Module
                        return;
 
                /* The parameters for the command in their original form, with the command stripped off */
-               std::string compare = text.substr(scommand.length() + 1);
+               std::string compare(text, scommand.length() + 1);
                while (*(compare.c_str()) == ' ')
                        compare.erase(compare.begin());
 
@@ -230,8 +230,6 @@ class ModuleAlias : public Module
 
        int DoAlias(User *user, Channel *c, Alias *a, const std::string& compare, const std::string& safe)
        {
-               User *u = NULL;
-
                /* Does it match the pattern? */
                if (!a->format.empty())
                {
@@ -252,16 +250,14 @@ class ModuleAlias : public Module
 
                if (!a->RequiredNick.empty())
                {
-                       u = ServerInstance->FindNick(a->RequiredNick);
+                       User* u = ServerInstance->FindNick(a->RequiredNick);
                        if (!u)
                        {
                                user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is currently unavailable. Please try again later.");
                                return 1;
                        }
-               }
-               if ((u != NULL) && (!a->RequiredNick.empty()) && (a->ULineOnly))
-               {
-                       if (!u->server->IsULine())
+
+                       if ((a->ULineOnly) && (!u->server->IsULine()))
                        {
                                ServerInstance->SNO->WriteToSnoMask('a', "NOTICE -- Service "+a->RequiredNick+" required by alias "+a->AliasedCommand+" is not on a u-lined server, possibly underhanded antics detected!");
                                user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is an imposter! Please inform an IRC operator as soon as possible.");
@@ -306,28 +302,28 @@ class ModuleAlias : public Module
                                        result.append(GetVar(var, original_line));
                                        i += len - 1;
                                }
-                               else if (newline.substr(i, 5) == "$nick")
+                               else if (!newline.compare(i, 5, "$nick", 5))
                                {
                                        result.append(user->nick);
                                        i += 4;
                                }
-                               else if (newline.substr(i, 5) == "$host")
+                               else if (!newline.compare(i, 5, "$host", 5))
                                {
                                        result.append(user->host);
                                        i += 4;
                                }
-                               else if (newline.substr(i, 5) == "$chan")
+                               else if (!newline.compare(i, 5, "$chan", 5))
                                {
                                        if (chan)
                                                result.append(chan->name);
                                        i += 4;
                                }
-                               else if (newline.substr(i, 6) == "$ident")
+                               else if (!newline.compare(i, 6, "$ident", 6))
                                {
                                        result.append(user->ident);
                                        i += 5;
                                }
-                               else if (newline.substr(i, 6) == "$vhost")
+                               else if (!newline.compare(i, 6, "$vhost", 6))
                                {
                                        result.append(user->dhost);
                                        i += 5;
@@ -348,14 +344,14 @@ class ModuleAlias : public Module
                {
                        pars.push_back(token);
                }
-               ServerInstance->Parser->CallHandler(command, pars, user);
+               ServerInstance->Parser.CallHandler(command, pars, user);
        }
 
        void Prioritize()
        {
                // Prioritise after spanningtree so that channel aliases show the alias before the effects.
                Module* linkmod = ServerInstance->Modules->Find("m_spanningtree.so");
-               ServerInstance->Modules->SetPriority(this, I_OnUserMessage, PRIORITY_AFTER, &linkmod);
+               ServerInstance->Modules->SetPriority(this, I_OnUserMessage, PRIORITY_AFTER, linkmod);
        }
 };