X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_alias.cpp;h=9055a8bf829d23bde263771ecbe44533ed8bc6d4;hb=adb5ab48a2b6efd146b9cc85a62b45c6a70aa34d;hp=b3b5f2c7619e1eef2cf958f89b84f71535d5c480;hpb=e244cb2c63b1ac1d85bdbb4691f7b1bd940ae804;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index b3b5f2c76..9055a8bf8 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -136,8 +136,6 @@ class ModuleAlias : public Module ModResult OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE { - AliasMap::iterator i, upperbound; - /* If theyre not registered yet, we dont want * to know. */ @@ -145,18 +143,16 @@ class ModuleAlias : public Module return MOD_RES_PASSTHRU; /* We dont have any commands looking like this? Stop processing. */ - i = Aliases.find(command); - if (i == Aliases.end()) + std::pair iters = Aliases.equal_range(command); + if (iters.first == iters.second) return MOD_RES_PASSTHRU; - /* Avoid iterating on to different aliases if no patterns match. */ - upperbound = Aliases.upper_bound(command); /* The parameters for the command in their original form, with the command stripped off */ std::string compare = original_line.substr(command.length()); while (*(compare.c_str()) == ' ') compare.erase(compare.begin()); - while (i != upperbound) + for (AliasMap::iterator i = iters.first; i != iters.second; ++i) { if (i->second.UserCommand) { @@ -165,8 +161,6 @@ class ModuleAlias : public Module return MOD_RES_DENY; } } - - i++; } // If we made it here, no aliases actually matched. @@ -213,21 +207,16 @@ class ModuleAlias : public Module // nor do we give a shit about the prefix scommand.erase(scommand.begin()); - AliasMap::iterator i = Aliases.find(scommand); - - if (i == Aliases.end()) + std::pair iters = Aliases.equal_range(scommand); + if (iters.first == iters.second) return; - /* Avoid iterating on to other aliases if no patterns match */ - AliasMap::iterator upperbound = Aliases.upper_bound(scommand); - - /* The parameters for the command in their original form, with the command stripped off */ std::string compare = text.substr(scommand.length() + 1); while (*(compare.c_str()) == ' ') compare.erase(compare.begin()); - while (i != upperbound) + for (AliasMap::iterator i = iters.first; i != iters.second; ++i) { if (i->second.ChannelCommand) { @@ -235,16 +224,12 @@ class ModuleAlias : public Module if (DoAlias(user, c, &(i->second), compare, text.substr(1))) return; } - - i++; } } 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()) { @@ -265,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.");