diff options
author | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-11-24 14:27:23 -0500 |
commit | 42238034490fb5479d787bd1695750387d508200 (patch) | |
tree | c93c62e0e1c936e656ae5b9ee1b62380ce2a194c /src/command.cpp | |
parent | d492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff) |
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most
object relationships implicitly defined, and use the graph to trace
references between objects to determine relationships. Edges may
also be marked as having a dependency of the object they point to,
which allows for automatic cleanup and deletion of most objects when
no longer needed.
Additionally, this allows not having to require in-memory copies of
everything when using external databases. db_sql has been rewritten
for this and now always requires a database to function. db_sql with
MySQL now requires InnoDB to make use of transactions and foreign
key constraints.
Diffstat (limited to 'src/command.cpp')
-rw-r--r-- | src/command.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/command.cpp b/src/command.cpp index 59db22a4b..c387ddaab 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -20,7 +20,7 @@ #include "modules/botserv.h" #include "modules/chanserv.h" -CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, BotInfo *bi) : nick(n), u(user), nc(core), reply(r), +CommandSource::CommandSource(const Anope::string &n, User *user, NickServ::Account *core, CommandReply *r, ServiceBot *bi) : nick(n), u(user), nc(core), reply(r), c(NULL), service(bi) { } @@ -64,7 +64,7 @@ bool CommandSource::HasCommand(const Anope::string &cmd) if (this->u) return this->u->HasCommand(cmd); else if (this->nc && this->nc->o) - return this->nc->o->ot->HasCommand(cmd); + return this->nc->o->GetType()->HasCommand(cmd); return false; } @@ -73,7 +73,7 @@ bool CommandSource::HasPriv(const Anope::string &cmd) if (this->u) return this->u->HasPriv(cmd); else if (this->nc && this->nc->o) - return this->nc->o->ot->HasPriv(cmd); + return this->nc->o->GetType()->HasPriv(cmd); return false; } @@ -274,13 +274,17 @@ void Command::Run(CommandSource &source, const Anope::string &message) Event::OnPostCommand(&Event::PostCommand::OnPostCommand, source, c, params); } -bool Command::FindCommandFromService(const Anope::string &command_service, BotInfo* &bot, Anope::string &name) +bool Command::FindCommandFromService(const Anope::string &command_service, ServiceBot* &bot, Anope::string &name) { bot = NULL; - for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) + for (std::pair<Anope::string, User *> p : UserListByNick) { - BotInfo *bi = it->second; + User *u = p.second; + if (u->type != UserType::BOT) + continue; + + ServiceBot *bi = anope_dynamic_static_cast<ServiceBot *>(u); for (CommandInfo::map::const_iterator cit = bi->commands.begin(), cit_end = bi->commands.end(); cit != cit_end; ++cit) { |