aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorGravatar attilamolnar2012-05-19 12:26:40 +0200
committerGravatar attilamolnar2012-05-19 12:26:40 +0200
commitb5d87ca4c51a847e9eeb2df047e2edc77d2c7bbd (patch)
treeaa99dd95f765981974354ca5a697d7661b1364c8 /src/modules
parentm_spanningtree Fix potential crash in SVSPART handler, don't broadcast incomi... (diff)
m_spanningtree Remove no-op instructions and simplify code
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_spanningtree/main.cpp30
-rw-r--r--src/modules/m_spanningtree/metadata.cpp2
-rw-r--r--src/modules/m_spanningtree/netburst.cpp11
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp1
-rw-r--r--src/modules/m_spanningtree/uid.cpp2
5 files changed, 15 insertions, 31 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index fbaee127c..36eae8872 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -43,7 +43,7 @@
/* $ModDep: m_spanningtree/cachetimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h m_spanningtree/protocolinterface.h */
ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
- : Module(Me), max_local(0), max_global(0)
+ : Module(Me), max_local(0), max_global(0), loopCall(false)
{
ServerInstance->Modules->UseInterface("BufferedSocketHook");
Utils = new SpanningTreeUtilities(ServerInstance, this);
@@ -67,7 +67,6 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me)
delete ServerInstance->PI;
ServerInstance->PI = new SpanningTreeProtocolInterface(this, Utils, ServerInstance);
- loopCall = false;
for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
{
@@ -611,7 +610,7 @@ void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, boo
params.push_back(channel->name);
params.push_back(ConvToStr(channel->age));
params.push_back(std::string("+") + channel->ChanModes(true));
- params.push_back(ServerInstance->Modes->ModeString(user, channel, false)+","+std::string(user->uuid));
+ params.push_back(ServerInstance->Modes->ModeString(user, channel, false) + "," + user->uuid);
Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FJOIN",params);
}
}
@@ -638,7 +637,7 @@ void ModuleSpanningTree::OnChangeName(User* user, const std::string &gecos)
Utils->DoOneToMany(user->uuid,"FNAME",params);
}
-void ModuleSpanningTree::OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent)
+void ModuleSpanningTree::OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent)
{
if (IS_LOCAL(user))
{
@@ -660,8 +659,8 @@ void ModuleSpanningTree::OnUserQuit(User* user, const std::string &reason, const
{
params.push_back(":"+oper_message);
Utils->DoOneToMany(user->uuid,"OPERQUIT",params);
+ params.clear();
}
- params.clear();
params.push_back(":"+reason);
Utils->DoOneToMany(user->uuid,"QUIT",params);
}
@@ -834,7 +833,6 @@ void ModuleSpanningTree::OnMode(User* user, void* dest, int target_type, const s
if ((IS_LOCAL(user)) && (user->registered == REG_ALL))
{
std::deque<std::string> params;
- std::string command;
std::string output_text;
ServerInstance->Parser->TranslateUIDs(translate, text, output_text);
@@ -844,7 +842,7 @@ void ModuleSpanningTree::OnMode(User* user, void* dest, int target_type, const s
User* u = (User*)dest;
params.push_back(u->uuid);
params.push_back(output_text);
- command = "MODE";
+ Utils->DoOneToMany(user->uuid, "MODE", params);
}
else
{
@@ -852,10 +850,8 @@ void ModuleSpanningTree::OnMode(User* user, void* dest, int target_type, const s
params.push_back(c->name);
params.push_back(ConvToStr(c->age));
params.push_back(output_text);
- command = "FMODE";
+ Utils->DoOneToMany(user->uuid, "FMODE", params);
}
-
- Utils->DoOneToMany(user->uuid, command, params);
}
}
@@ -863,18 +859,10 @@ int ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
{
if (IS_LOCAL(user))
{
- if (awaymsg.empty())
- {
- std::deque<std::string> params;
- params.clear();
- Utils->DoOneToMany(user->uuid,"AWAY",params);
- }
- else
- {
- std::deque<std::string> params;
+ std::deque<std::string> params;
+ if (!awaymsg.empty())
params.push_back(":" + awaymsg);
- Utils->DoOneToMany(user->uuid,"AWAY",params);
- }
+ Utils->DoOneToMany(user->uuid,"AWAY",params);
}
return 0;
diff --git a/src/modules/m_spanningtree/metadata.cpp b/src/modules/m_spanningtree/metadata.cpp
index 1cd061a20..706317334 100644
--- a/src/modules/m_spanningtree/metadata.cpp
+++ b/src/modules/m_spanningtree/metadata.cpp
@@ -48,7 +48,7 @@ bool TreeSocket::MetaData(const std::string &prefix, std::deque<std::string> &pa
FOREACH_MOD_I(this->ServerInstance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2]));
}
}
- else if (*(params[0].c_str()) != '#')
+ else
{
User* u = this->ServerInstance->FindNick(params[0]);
if (u)
diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp
index f240f7cfd..997f040f1 100644
--- a/src/modules/m_spanningtree/netburst.cpp
+++ b/src/modules/m_spanningtree/netburst.cpp
@@ -36,15 +36,12 @@
*/
void TreeSocket::DoBurst(TreeServer* s)
{
- std::string name = s->GetName();
- std::string burst = ":" + this->ServerInstance->Config->GetSID() + " BURST " +ConvToStr(ServerInstance->Time());
- std::string endburst = ":" + this->ServerInstance->Config->GetSID() + " ENDBURST";
this->ServerInstance->SNO->WriteToSnoMask('l',"Bursting to \2%s\2 (Authentication: %s%s).",
- name.c_str(),
+ s->GetName().c_str(),
this->auth_fingerprint ? "SSL Fingerprint and " : "",
this->auth_challenge ? "challenge-response" : "plaintext password");
this->CleanNegotiationInfo();
- this->WriteLine(burst);
+ this->WriteLine(":" + ServerInstance->Config->GetSID() + " BURST " + ConvToStr(ServerInstance->Time()));
/* send our version string */
this->WriteLine(std::string(":")+this->ServerInstance->Config->GetSID()+" VERSION :"+this->ServerInstance->GetVersionString());
/* Send server tree */
@@ -55,8 +52,8 @@ void TreeSocket::DoBurst(TreeServer* s)
this->SendChannelModes(s);
this->SendXLines(s);
FOREACH_MOD_I(this->ServerInstance,I_OnSyncOtherMetaData,OnSyncOtherMetaData((Module*)Utils->Creator,(void*)this));
- this->WriteLine(endburst);
- this->ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+name+"\2.");
+ this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST");
+ this->ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+s->GetName()+"\2.");
}
/** Recursively send the server tree with distances as hops.
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index 0c80af2c9..f3da162ec 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -45,7 +45,6 @@ void ModuleSpanningTree::OnPostCommand(const std::string &command, const std::ve
// to have any special provision in place for remote
// commands and linking protocols.
std::deque<std::string> params;
- params.clear();
unsigned int n_translate = thiscmd->translation.size();
TranslateType translate_to;
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 340b9fb64..7942c12b5 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -38,7 +38,7 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa
*/
if (params.size() < 10)
{
- this->SendError("Invalid client introduction (wanted 10 or more parameters, got " + (params.empty() ? "0" : ConvToStr(params.size())) + "!)");
+ this->SendError("Invalid client introduction (wanted 10 or more parameters, got " + ConvToStr(params.size()) + "!)");
return false;
}