From f9ef4ebc9dc4fd46cdafcc76df644b4896251dac Mon Sep 17 00:00:00 2001 From: peavey Date: Mon, 5 May 2008 03:40:03 +0000 Subject: fix some unitialised vectors and tidy up a bit. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9637 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_sqloper.cpp | 4 ++-- src/modules/m_antibottler.cpp | 8 ++++---- src/modules/m_auditorium.cpp | 5 +++-- src/modules/m_banredirect.cpp | 5 ++--- src/modules/m_chanprotect.cpp | 4 ++-- src/modules/m_conn_umodes.cpp | 8 +++----- src/modules/m_delayjoin.cpp | 4 ++-- src/modules/m_devoice.cpp | 6 +++--- src/modules/m_filter.h | 2 +- src/modules/m_invisible.cpp | 8 ++++---- src/modules/m_opermodes.cpp | 10 +++------- src/modules/m_services.cpp | 5 ++--- src/modules/m_spanningtree/fjoin.cpp | 13 ++++++------- src/modules/m_spanningtree/fmode.cpp | 3 +-- src/modules/m_spanningtree/rconnect.cpp | 3 +-- src/modules/m_timedbans.cpp | 12 ++++++------ 16 files changed, 45 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp index 09b577aed..861a2b70c 100644 --- a/src/modules/extra/m_sqloper.cpp +++ b/src/modules/extra/m_sqloper.cpp @@ -277,8 +277,8 @@ public: if (oper_command) { std::vector params; - params[0] = username; - params[1] = pass; + params.push_back(username); + params.push_back(pass); oper_command->Handle(params, user); } else diff --git a/src/modules/m_antibottler.cpp b/src/modules/m_antibottler.cpp index c6f6abe35..bafd422da 100644 --- a/src/modules/m_antibottler.cpp +++ b/src/modules/m_antibottler.cpp @@ -79,10 +79,10 @@ class ModuleAntiBottler : public Module { std::string strgecos = std::string(gecos) + "[Possible bottler, ident: " + std::string(ident) + "]"; std::vector modified; - modified[0] = "bottler"; - modified[1] = local; - modified[2] = remote; - modified[3] = strgecos; + modified.push_back("bottler"); + modified.push_back(local); + modified.push_back(remote); + modified.push_back(strgecos); ServerInstance->Parser->CallHandler("USER", modified, user); return 1; } diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp index 264418c5b..75f953f43 100644 --- a/src/modules/m_auditorium.cpp +++ b/src/modules/m_auditorium.cpp @@ -160,7 +160,7 @@ class ModuleAuditorium : public Module void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) { Command* parthandler = ServerInstance->Parser->GetHandler("PART"); - std::vector to_leave, parameters; + std::vector to_leave; if (parthandler) { for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) @@ -171,7 +171,8 @@ class ModuleAuditorium : public Module /* We cant do this neatly in one loop, as we are modifying the map we are iterating */ for (std::vector::iterator n = to_leave.begin(); n != to_leave.end(); n++) { - parameters[0] = *n; + std::vector parameters; + parameters.push_back(*n); /* This triggers our OnUserPart, above, making the PART silent */ parthandler->Handle(parameters, user); } diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 4313039aa..e9661c727 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -223,8 +223,7 @@ class ModuleBanRedirect : public Module irc::modestacker modestack(false); StringDeque stackresult; std::vector mode_junk; - - mode_junk[0] = chan->name; + mode_junk.push_back(chan->name); for(BanRedirectList::iterator i = redirects->begin(); i != redirects->end(); i++) { @@ -241,7 +240,7 @@ class ModuleBanRedirect : public Module { for(StringDeque::size_type i = 0; i < stackresult.size(); i++) { - mode_junk[i+1] = stackresult[i]; + mode_junk.push_back(stackresult[i]); } ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient); diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 07b491bb7..82c4e6940 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -67,7 +67,7 @@ class FounderProtectBase CUList* cl = channel->GetUsers(); std::string item = extend + std::string(channel->name); std::vector mode_junk; - mode_junk[0] = channel->name; + mode_junk.push_back(channel->name); irc::modestacker modestack(false); std::deque stackresult; @@ -89,7 +89,7 @@ class FounderProtectBase { for (size_t j = 0; j < stackresult.size(); j++) { - mode_junk[j+1] = stackresult[j]; + mode_junk.push_back(stackresult[j]); } MyInstance->SendMode(mode_junk, MyInstance->FakeClient); } diff --git a/src/modules/m_conn_umodes.cpp b/src/modules/m_conn_umodes.cpp index ba3d6968d..97a8b8340 100644 --- a/src/modules/m_conn_umodes.cpp +++ b/src/modules/m_conn_umodes.cpp @@ -72,17 +72,15 @@ class ModuleModesOnConnect : public Module tokens.push_back(buf); std::vector modes; - modes[0] = user->nick; - modes[1] = tokens[0]; + modes.push_back(user->nick); + modes.push_back(tokens[0]); if (tokens.size() > 1) { // process mode params - int i = 2; for (unsigned int k = 1; k < tokens.size(); k++) { - modes[i] = tokens[k]; - i++; + modes.push_back(tokens[k]); } } diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 2ce31be50..abdee355a 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -146,12 +146,12 @@ class ModuleDelayJoin : public Module void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) { Command* parthandler = ServerInstance->Parser->GetHandler("PART"); - std::vector parameters; if (parthandler && user->GetExt("delayjoin")) { for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) { - parameters[0] = f->first->name; + std::vector parameters; + parameters.push_back(f->first->name); /* This triggers our OnUserPart, above, making the PART silent */ parthandler->Handle(parameters, user); } diff --git a/src/modules/m_devoice.cpp b/src/modules/m_devoice.cpp index 75335885e..ba12d7db9 100644 --- a/src/modules/m_devoice.cpp +++ b/src/modules/m_devoice.cpp @@ -38,9 +38,9 @@ class CommandDevoice : public Command if (c && c->HasUser(user)) { std::vector modes; - modes[0] = parameters[0]; - modes[1] = "-v"; - modes[2] = user->nick; + modes.push_back(parameters[0]); + modes.push_back("-v"); + modes.push_back(user->nick); ServerInstance->SendMode(modes, ServerInstance->FakeClient); diff --git a/src/modules/m_filter.h b/src/modules/m_filter.h index 288ed9310..7af2204bb 100644 --- a/src/modules/m_filter.h +++ b/src/modules/m_filter.h @@ -347,7 +347,7 @@ int FilterBase::OnPreCommand(const std::string &command, const std::vector params; for (int item = 0; item < (int)parameters.size(); item++) - params[item] = parameters[item]; + params.push_back(parameters[item]); params[replacepoint] = "Reason filtered"; /* We're blocking, OR theyre quitting and its a KILL action diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index de573dfde..155c518c4 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -141,8 +141,8 @@ class InvisibleDeOper : public ModeWatcher if ((!adding) && (dest->IsModeSet('Q'))) { std::vector newmodes; - newmodes[0] = dest->nick; - newmodes[1] = "-Q"; + newmodes.push_back(dest->nick); + newmodes.push_back("-Q"); ServerInstance->Modes->Process(newmodes, source, true); } return true; @@ -223,7 +223,6 @@ class ModuleInvisible : public Module { Command* parthandler = ServerInstance->Parser->GetHandler("PART"); std::vector to_leave; - std::vector parameters; if (parthandler) { for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) @@ -231,7 +230,8 @@ class ModuleInvisible : public Module /* We cant do this neatly in one loop, as we are modifying the map we are iterating */ for (std::vector::iterator n = to_leave.begin(); n != to_leave.end(); n++) { - parameters[0] = *n; + std::vector parameters; + parameters.push_back(*n); /* This triggers our OnUserPart, above, making the PART silent */ parthandler->Handle(parameters, user); } diff --git a/src/modules/m_opermodes.cpp b/src/modules/m_opermodes.cpp index 8a91c3569..4184409f1 100644 --- a/src/modules/m_opermodes.cpp +++ b/src/modules/m_opermodes.cpp @@ -99,17 +99,13 @@ class ModuleModesOnOper : public Module while (ss >> buf) tokens.push_back(buf); - int size = tokens.size() + 1; - std::vector modes(size); - modes.resize(size); - modes[0] = u->nick; + std::vector modes; + modes.push_back(u->nick); // process mode params - int i = 1; for (unsigned int k = 0; k < tokens.size(); k++) { - modes[i] = tokens[k].c_str(); - i++; + modes.push_back(tokens[k]); } std::deque n; diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp index bcac36b60..b62f432da 100644 --- a/src/modules/m_services.cpp +++ b/src/modules/m_services.cpp @@ -141,9 +141,8 @@ class ModuleServices : public Module if (user->IsModeSet('r') && irc::string(user->nick) != oldnick) { std::vector modechange; - modechange.resize(2); - modechange[0] = user->nick; - modechange[1] = "-r"; + modechange.push_back(user->nick); + modechange.push_back("-r"); kludgeme = true; ServerInstance->SendMode(modechange,user); kludgeme = false; diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 070051a9c..630aab946 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -109,16 +109,15 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p if (apply_other_sides_modes) { unsigned int idx = 2; - int numpara = 1; std::vector modelist; // Mode parser needs to know what channel to act on. - modelist[0] = params[0]; + modelist.push_back(params[0]); /* Remember, params[params.size() - 1] is nicklist, and we don't want to apply *that* */ for (idx = 2; idx != (params.size() - 1); idx++) { - modelist[numpara++] = params[idx]; + modelist.push_back(params[idx]); } this->Instance->SendMode(modelist, this->Instance->FakeClient); @@ -181,13 +180,13 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque &p { std::deque stackresult; std::vector mode_junk; - mode_junk[0] = channel; + mode_junk.push_back(channel); while (modestack.GetStackedLine(stackresult)) { for (size_t j = 0; j < stackresult.size(); j++) { - mode_junk[j+1] = stackresult[j]; + mode_junk.push_back(stackresult[j]); } Instance->SendMode(mode_junk, Instance->FakeClient); } @@ -210,7 +209,7 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque irc::modestacker stack(false); std::deque stackresult; std::vector mode_junk; - mode_junk[0] = c->name; + mode_junk.push_back(c->name); for (char modeletter = 'A'; modeletter <= 'z'; ++modeletter) { @@ -227,7 +226,7 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque while (stack.GetStackedLine(stackresult)) { for (size_t j = 0; j < stackresult.size(); j++) - mode_junk[j+1] = stackresult[j]; + mode_junk.push_back(stackresult[j]); Instance->SendMode(mode_junk, Instance->FakeClient); } diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp index e7209a852..2ab370170 100644 --- a/src/modules/m_spanningtree/fmode.cpp +++ b/src/modules/m_spanningtree/fmode.cpp @@ -50,7 +50,6 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque &p } std::vector modelist; time_t TS = 0; - int n = 0; for (unsigned int q = 0; (q < params.size()) && (q < 64); q++) { if (q == 1) @@ -64,7 +63,7 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque &p else { /* Everything else is fine to append to the modelist */ - modelist[n++] = params[q]; + modelist.push_back(params[q]); } } diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp index 1dce8e7e4..a25226828 100644 --- a/src/modules/m_spanningtree/rconnect.cpp +++ b/src/modules/m_spanningtree/rconnect.cpp @@ -54,8 +54,7 @@ CmdResult cmd_rconnect::Handle (const std::vector& parameters, User /* Yes, initiate the given connect */ ServerInstance->SNO->WriteToSnoMask('l',"Remote CONNECT from %s matching \002%s\002, connecting server \002%s\002",user->nick,parameters[0].c_str(),parameters[1].c_str()); std::vector para; - para.resize(1); - para[0] = parameters[1]; + para.push_back(parameters[1]); std::string original_command = std::string("CONNECT ") + parameters[1]; Creator->OnPreCommand("CONNECT", para, user, true, original_command); } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 40c994842..ea5ade8e9 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -72,9 +72,9 @@ class CommandTban : public Command } std::string mask = parameters[2]; std::vector setban; - setban[0] = parameters[0]; - setban[1] = "+b"; - setban[2] = parameters[2]; + setban.push_back(parameters[0]); + setban.push_back("+b"); + setban.push_back(parameters[2]); // use CallCommandHandler to make it so that the user sets the mode // themselves ServerInstance->CallCommandHandler("MODE",setban,user); @@ -159,9 +159,9 @@ class ModuleTimedBans : public Module { std::string mask = safei->mask; std::vector setban; - setban[0] = safei->channel; - setban[1] = "-b"; - setban[2] = mask; + setban.push_back(safei->channel); + setban.push_back("-b"); + setban.push_back(mask); CUList empty; cr->WriteAllExcept(ServerInstance->FakeClient, true, '@', empty, "NOTICE %s :*** Timed ban on %s expired.", cr->name, safei->mask.c_str()); -- cgit v1.2.3