diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-14 13:11:57 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-14 13:11:57 +0000 |
commit | cd211dbaf1abb0402a883bd12e983faf569807bc (patch) | |
tree | d76984174d837722f04cfe93ce6301d9f349ef6c /src | |
parent | f6f45af59e8cd572e724d95f3736f6a60f73486c (diff) |
Allow aliasing of anything to anything, removing the need for tons of non-programmer tweaks to be modules.
Also speed up matching of aliases by storing a map so we dont need to loop if we dont have an alias that looks like the current command
(when allowing aliasing of ANYTHING this is required otherwise this module would be major cpu suck)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6317 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_alias.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index e8e7cec1a..ffa6c1e46 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -43,6 +43,7 @@ class ModuleAlias : public Module private: /** We cant use a map, there may be multiple aliases with the same name */ std::vector<Alias> Aliases; + std::map<std::string, int> AliasMap; std::vector<std::string> pars; virtual void ReadAliases() @@ -50,6 +51,7 @@ class ModuleAlias : public Module ConfigReader MyConf(ServerInstance); Aliases.clear(); + AliasMap.clear(); for (int i = 0; i < MyConf.Enumerate("alias"); i++) { Alias a; @@ -62,6 +64,7 @@ class ModuleAlias : public Module a.operonly = MyConf.ReadFlag("alias", "operonly", i); a.format = MyConf.ReadValue("alias", "format", i); Aliases.push_back(a); + AliasMap[txt] = 1; } } @@ -132,11 +135,14 @@ class ModuleAlias : public Module { userrec *u = NULL; - /* If the command is valid, we dont want to know, - * and if theyre not registered yet, we dont want - * to know either + /* If theyre not registered yet, we dont want + * to know. */ - if ((validated) || (user->registered != REG_ALL)) + if (user->registered != REG_ALL) + return 0; + + /* We dont have any commands looking like this, dont bother with the loop */ + if (AliasMap.find(command) == AliasMap.end()) return 0; irc::string c = command.c_str(); |