diff options
-rw-r--r-- | include/command_parse.h | 8 | ||||
-rw-r--r-- | src/configreader.cpp | 3 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_commands.cpp | 5 | ||||
-rw-r--r-- | src/coremods/core_stats.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_abbreviation.cpp | 3 |
5 files changed, 20 insertions, 6 deletions
diff --git a/include/command_parse.h b/include/command_parse.h index 70544b0c8..bdbc12757 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -29,6 +29,9 @@ */ class CoreExport CommandParser { + public: + typedef Commandtable CommandMap; + private: /** Process a command from a user. * @param user The user to parse the command for @@ -45,6 +48,11 @@ class CoreExport CommandParser */ CommandParser(); + /** Get a command name -> Command* map containing all client to server commands + * @return A map of command handlers keyed by command names + */ + const CommandMap& GetCommands() const { return cmdlist; } + /** Calls the handler for a given command. * @param commandname The command to find. This should be in uppercase. * @param parameters Parameter list diff --git a/src/configreader.cpp b/src/configreader.cpp index 1ac075557..945600e6c 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -69,7 +69,8 @@ bool ServerConfig::ApplyDisabledCommands(const std::string& data) std::string thiscmd; /* Enable everything first */ - for (Commandtable::iterator x = ServerInstance->Parser->cmdlist.begin(); x != ServerInstance->Parser->cmdlist.end(); x++) + const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands(); + for (CommandParser::CommandMap::const_iterator x = commands.begin(); x != commands.end(); ++x) x->second->Disable(false); /* Now disable all the ones which the user wants disabled */ diff --git a/src/coremods/core_info/cmd_commands.cpp b/src/coremods/core_info/cmd_commands.cpp index 9ae258a9c..8b255a928 100644 --- a/src/coremods/core_info/cmd_commands.cpp +++ b/src/coremods/core_info/cmd_commands.cpp @@ -31,9 +31,10 @@ CommandCommands::CommandCommands(Module* parent) */ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user) { + const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands(); std::vector<std::string> list; - list.reserve(ServerInstance->Parser->cmdlist.size()); - for (Commandtable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++) + list.reserve(commands.size()); + for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i) { // Don't show S2S commands to users if (i->second->flags_needed == FLAG_SERVERONLY) diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index b8ea21731..1e90ed2bf 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -189,7 +189,9 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) /* stats m (list number of times each command has been used, plus bytecount) */ case 'm': - for (Commandtable::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++) + { + const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands(); + for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i) { if (i->second->use_count) { @@ -197,6 +199,7 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) results.push_back("212 "+user->nick+" "+i->second->name+" "+ConvToStr(i->second->use_count)); } } + } break; /* stats z (debug and memory info) */ @@ -204,7 +207,7 @@ void CommandStats::DoStats(char statschar, User* user, string_list &results) { results.push_back("249 "+user->nick+" :Users: "+ConvToStr(ServerInstance->Users->GetUsers().size())); results.push_back("249 "+user->nick+" :Channels: "+ConvToStr(ServerInstance->GetChans().size())); - results.push_back("249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser->cmdlist.size())); + results.push_back("249 "+user->nick+" :Commands: "+ConvToStr(ServerInstance->Parser->GetCommands().size())); float kbitpersec_in, kbitpersec_out, kbitpersec_total; char kbitpersec_in_s[30], kbitpersec_out_s[30], kbitpersec_total_s[30]; diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp index f69d26749..a7bf8ceee 100644 --- a/src/modules/m_abbreviation.cpp +++ b/src/modules/m_abbreviation.cpp @@ -42,7 +42,8 @@ class ModuleAbbreviation : public Module size_t clen = command.length() - 1; std::string foundcommand, matchlist; bool foundmatch = false; - for (Commandtable::iterator n = ServerInstance->Parser->cmdlist.begin(); n != ServerInstance->Parser->cmdlist.end(); ++n) + const CommandParser::CommandMap& commands = ServerInstance->Parser->GetCommands(); + for (CommandParser::CommandMap::const_iterator n = commands.begin(); n != commands.end(); ++n) { if (!command.compare(0, clen, n->first, 0, clen)) { |