From 8d395f8c46ca9f61710a6c30e2e24c0b9627d2e8 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 2 Nov 2007 20:13:10 +0000 Subject: Implement DELLINE, allow both DELLINE and ADDLINE to take a server OR client origin git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8468 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/main.cpp | 54 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'src/modules/m_spanningtree/main.cpp') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 2e743689c..470ae7b36 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -738,50 +738,40 @@ void ModuleSpanningTree::OnOper(User* user, const std::string &opertype) void ModuleSpanningTree::OnAddLine(XLine* line, User* user) { + char data[MAXBUF]; + snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", line->type.c_str(), line->Displayable(), ServerInstance->Config->ServerName, line->set_time, + line->duration, line->reason); + std::deque params; + params.push_back(data); + if (!user) { /* Server-set lines */ - char data[MAXBUF]; - snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", line->type.c_str(), line->Displayable(), ServerInstance->Config->ServerName, line->set_time, - line->duration, line->reason); - std::deque params; - params.push_back(data); Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ADDLINE", params); } - else + else if (IS_LOCAL(user)) { - /** XXX: This is WRONG and needs fixing. - * We need to implement a DELLINE - */ - if (user && IS_LOCAL(user)) - { - char type[8]; - snprintf(type,8,"%sLINE",line->type.c_str()); - std::string stype(type); - char sduration[MAXBUF]; - snprintf(sduration,MAXBUF,"%ld",line->duration); - std::deque params; - params.push_back(line->Displayable()); - params.push_back(ConvToStr(line->duration)); - params.push_back(std::string(":")+line->reason); - Utils->DoOneToMany(user->uuid,stype,params); - } + /* User-set lines */ + Utils->DoOneToMany(user->uuid, "ADDLINE", params); } } void ModuleSpanningTree::OnDelLine(XLine* line, User* user) { - if (user && IS_LOCAL(user)) + char data[MAXBUF]; + snprintf(data,MAXBUF,"%s %s", line->type.c_str(), line->Displayable()); + std::deque params; + params.push_back(data); + + if (!user) { - /** XXX: This is WRONG and needs fixing. - * We need to implement a DELLINE - */ - char type[8]; - snprintf(type,8,"%sLINE",line->type.c_str()); - std::string stype(type); - std::deque params; - params.push_back(line->Displayable()); - Utils->DoOneToMany(user->uuid,stype,params); + /* Server-unset lines */ + Utils->DoOneToMany(ServerInstance->Config->GetSID(), "DELLINE", params); + } + else if (IS_LOCAL(user)) + { + /* User-unset lines */ + Utils->DoOneToMany(user->uuid, "DELLINE", params); } } -- cgit v1.2.3