diff options
author | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-25 21:58:20 -0400 |
---|---|---|
committer | Naram Qashat <cyberbotx@cyberbotx.com> | 2010-07-25 21:58:20 -0400 |
commit | ae38212c1ce829c783edf971081c90137abb49a0 (patch) | |
tree | 5c652d9cdc38103dec6fa112d57fca882b4e3e44 /src/commands.cpp | |
parent | 15d7f0f6fe8bb903275f603f734c13f65f3aa906 (diff) |
Epic commit to replace most of the strings in Anope with a single Anope::string class, plus some other little fixes here and there. If you follow 1.9.x development and are testing things, THIS is one of those things that NEEDS testing.
Diffstat (limited to 'src/commands.cpp')
-rw-r--r-- | src/commands.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index ebe189fd4..2647ea952 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -14,12 +14,12 @@ #include "language.h" #include "hashcomp.h" -Command *FindCommand(BotInfo *bi, const ci::string &name) +Command *FindCommand(BotInfo *bi, const Anope::string &name) { if (!bi || bi->Commands.empty() || name.empty()) return NULL; - std::map<ci::string, Command *>::iterator it = bi->Commands.find(name); + CommandMap::iterator it = bi->Commands.find(name); if (it != bi->Commands.end()) return it->second; @@ -27,16 +27,16 @@ Command *FindCommand(BotInfo *bi, const ci::string &name) return NULL; } -void mod_run_cmd(BotInfo *bi, User *u, const std::string &message) +void mod_run_cmd(BotInfo *bi, User *u, const Anope::string &message) { - spacesepstream sep(ci::string(message.c_str())); - ci::string cmd; + spacesepstream sep(message); + Anope::string cmd; if (sep.GetToken(cmd)) - mod_run_cmd(bi, u, FindCommand(bi, cmd), cmd, sep.GetRemaining().c_str()); + mod_run_cmd(bi, u, FindCommand(bi, cmd), cmd, sep.GetRemaining()); } -void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, const ci::string &message) +void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command, const Anope::string &message) { if (!bi || !u) return; @@ -57,22 +57,19 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, co // Command requires registered users only if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->IsIdentified()) { - notice_lang(bi->nick, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ); + notice_lang(bi->nick, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ.c_str()); Alog() << "Access denied for unregistered user " << u->nick << " with service " << bi->nick << " and command " << command; return; } - std::vector<ci::string> params; - ci::string curparam, endparam; + std::vector<Anope::string> params; + Anope::string curparam, endparam; spacesepstream sep(message); while (sep.GetToken(curparam)) { // - 1 because params[0] corresponds with a maxparam of 1. - if (params.size() >= (c->MaxParams - 1)) - { - endparam += curparam; - endparam += " "; - } + if (params.size() >= c->MaxParams - 1) + endparam += curparam + " "; else params.push_back(curparam); } @@ -80,7 +77,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, co if (!endparam.empty()) { // Remove trailing space - endparam.erase(endparam.size() - 1, endparam.size()); + endparam.erase(endparam.length() - 1); // Add it params.push_back(endparam); @@ -98,7 +95,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, co if (params.size() > 0 && !c->HasFlag(CFLAG_STRIP_CHANNEL) && (bi == ChanServ || bi == BotServ)) { - if (ircdproto->IsChannelValid(params[0].c_str())) + if (ircdproto->IsChannelValid(params[0])) { ChannelInfo *ci = cs_findchan(params[0]); if (ci) @@ -142,7 +139,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, co if (ret == MOD_CONT) { - FOREACH_MOD(I_OnPostCommand, OnPostCommand(u, c->service, c->name.c_str(), params)); + FOREACH_MOD(I_OnPostCommand, OnPostCommand(u, c->service, c->name, params)); } } @@ -154,18 +151,18 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const ci::string &command, co * @param cmd Command * @return void */ -void mod_help_cmd(BotInfo *bi, User *u, const ci::string &cmd) +void mod_help_cmd(BotInfo *bi, User *u, const Anope::string &cmd) { if (!bi || !u || cmd.empty()) return; spacesepstream tokens(cmd); - ci::string token; + Anope::string token; tokens.GetToken(token); Command *c = FindCommand(bi, token); - ci::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining().c_str(); + Anope::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining(); if (!c || (Config.HidePrivilegedCommands && !c->permission.empty() && (!u->Account() || !u->Account()->HasCommand(c->permission))) || !c->OnHelp(u, subcommand)) notice_lang(bi->nick, u, NO_HELP_AVAILABLE, cmd.c_str()); |