]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Add CommandNum::Builder
authorAttila Molnar <attilamolnar@hush.com>
Tue, 29 Mar 2016 14:39:06 +0000 (16:39 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Tue, 29 Mar 2016 14:39:06 +0000 (16:39 +0200)
src/modules/m_spanningtree/commands.h
src/modules/m_spanningtree/num.cpp

index a6563943407b99159718f01bf842b30dd9b9333b..4810e9d4bcde2621a23130968e271874cc499920 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "servercommand.h"
 #include "commandbuilder.h"
 
 #include "servercommand.h"
 #include "commandbuilder.h"
+#include "remoteuser.h"
 
 /** Handle /RCONNECT
  */
 
 /** Handle /RCONNECT
  */
@@ -375,6 +376,12 @@ class CommandNum : public ServerOnlyServerCommand<CommandNum>
        CommandNum(Module* Creator) : ServerOnlyServerCommand<CommandNum>(Creator, "NUM", 3) { }
        CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
        CommandNum(Module* Creator) : ServerOnlyServerCommand<CommandNum>(Creator, "NUM", 3) { }
        CmdResult HandleServer(TreeServer* server, std::vector<std::string>& parameters);
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
+
+       class Builder : public CmdBuilder
+       {
+        public:
+               Builder(SpanningTree::RemoteUser* target, const Numeric::Numeric& numeric);
+       };
 };
 
 class SpanningTreeCommands
 };
 
 class SpanningTreeCommands
index 047dba4322b9826528f3e5c02190ea8e18875a3c..2c8697c9a5b6b64704db6fd8a3cd1a435fd954c8 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "utils.h"
 #include "commands.h"
 
 #include "utils.h"
 #include "commands.h"
+#include "remoteuser.h"
 
 CmdResult CommandNum::HandleServer(TreeServer* server, std::vector<std::string>& params)
 {
 
 CmdResult CommandNum::HandleServer(TreeServer* server, std::vector<std::string>& params)
 {
@@ -45,3 +46,17 @@ RouteDescriptor CommandNum::GetRouting(User* user, const std::vector<std::string
 {
        return ROUTE_UNICAST(params[1]);
 }
 {
        return ROUTE_UNICAST(params[1]);
 }
+
+CommandNum::Builder::Builder(SpanningTree::RemoteUser* target, const Numeric::Numeric& numeric)
+       : CmdBuilder("NUM")
+{
+       TreeServer* const server = (numeric.GetServer() ? (static_cast<TreeServer*>(numeric.GetServer())) : Utils->TreeRoot);
+       push(server->GetID()).push(target->uuid).push(InspIRCd::Format("%03u", numeric.GetNumeric()));
+       const std::vector<std::string>& params = numeric.GetParams();
+       if (!params.empty())
+       {
+               for (std::vector<std::string>::const_iterator i = params.begin(); i != params.end()-1; ++i)
+                       push(*i);
+               push_last(params.back());
+       }
+}