From cd211dbaf1abb0402a883bd12e983faf569807bc Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 14 Jan 2007 13:11:57 +0000 Subject: 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 --- src/modules/m_alias.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/modules') 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 Aliases; + std::map AliasMap; std::vector 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(); -- cgit v1.2.3