From fcb3090055429a108b9837dbd4ba505d9c291129 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 11 Mar 2026 21:54:40 +0000 Subject: Rework sending server protocol messages. - Replace CmdBuilder with MessageBuilder. This has a less footgun API. All message building has to go through this now so we can implement other message formats in the future. - Replace the message parsing in WriteLine with an analogue to PreProcessOldProtocolMessage. This should be much faster. - Move parameter translation from the core to spanningtree. - Change EncodeParameter to return the value instead of updating in place. - Replace the OnBuild*Message events with one OnServerMessage that can now access all parts of the message and change them. --- modules/spanningtree/num.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'modules/spanningtree/num.cpp') diff --git a/modules/spanningtree/num.cpp b/modules/spanningtree/num.cpp index 64cc0f62e..e8e995895 100644 --- a/modules/spanningtree/num.cpp +++ b/modules/spanningtree/num.cpp @@ -49,16 +49,11 @@ RouteDescriptor CommandNum::GetRouting(User* user, const Params& params) } CommandNum::Builder::Builder(SpanningTree::RemoteUser* target, const Numeric::Numeric& numeric) - : CmdBuilder("NUM") + : MessageBuilder("NUM") { TreeServer* const server = (numeric.GetServer() ? (static_cast(numeric.GetServer())) : Utils->TreeRoot); - push(server->GetId()).push(target->uuid).push(FMT::format("{:03}", numeric.GetNumeric())); - const CommandBase::Params& params = numeric.GetParams(); - if (!params.empty()) - { - for (CommandBase::Params::const_iterator i = params.begin(); i != params.end()-1; ++i) - push(*i); - push_last(params.back()); - } - push_tags(params.GetTags()); + Push(server->GetId()); + Push(target->uuid); + PushFmt("{:03}", numeric.GetNumeric()); + PushParams(numeric.GetParams()); } -- cgit v1.3.1-10-gc9f91