From 8cebe2878f3878afce6f643d93668155cb26801d Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 2 Sep 2009 00:44:50 +0000 Subject: Include explicit routing information in Command, will replace CMD_LOCALONLY return value git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11601 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/command_parse.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'src/command_parse.cpp') diff --git a/src/command_parse.cpp b/src/command_parse.cpp index b446d2b9a..b063e392c 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -607,20 +607,29 @@ void CommandParser::SetupCommandTable() this->CreateCommand(new CommandReload(ServerInstance)); } -int CommandParser::TranslateUIDs(const std::vector to, const std::vector &source, std::string &dest) +int CommandParser::TranslateUIDs(const std::vector to, const std::vector &source, std::string &dest, bool prefix_final, Command* custom_translator) { - std::vector::const_iterator items = source.begin(); std::vector::const_iterator types = to.begin(); User* user = NULL; + unsigned int i; int translations = 0; dest.clear(); - while (items != source.end() && types != to.end()) + for(i=0; i < source.size(); i++) { - TranslateType t = *types; - std::string item = *items; - types++; - items++; + TranslateType t; + std::string item = source[i]; + + if (types == to.end()) + t = TR_TEXT; + else + { + t = *types; + types++; + } + + if (prefix_final && i == source.size() - 1) + dest.append(":"); switch (t) { @@ -635,6 +644,10 @@ int CommandParser::TranslateUIDs(const std::vector to, const std: else dest.append(item); break; + case TR_CUSTOM: + if (custom_translator) + custom_translator->EncodeParameter(item, i); + dest.append(item); break; case TR_END: case TR_TEXT: @@ -643,11 +656,10 @@ int CommandParser::TranslateUIDs(const std::vector to, const std: dest.append(item); break; } - dest.append(" "); + if (i != source.size() - 1) + dest.append(" "); } - if (!dest.empty()) - dest.erase(dest.end() - 1); return translations; } -- cgit v1.2.3