]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
fix some unitialised vectors and tidy up a bit.
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 5 May 2008 03:40:03 +0000 (03:40 +0000)
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 5 May 2008 03:40:03 +0000 (03:40 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9637 e03df62e-2008-0410-955e-edbf42e46eb7

17 files changed:
include/u_listmode.h
src/modules/extra/m_sqloper.cpp
src/modules/m_antibottler.cpp
src/modules/m_auditorium.cpp
src/modules/m_banredirect.cpp
src/modules/m_chanprotect.cpp
src/modules/m_conn_umodes.cpp
src/modules/m_delayjoin.cpp
src/modules/m_devoice.cpp
src/modules/m_filter.h
src/modules/m_invisible.cpp
src/modules/m_opermodes.cpp
src/modules/m_services.cpp
src/modules/m_spanningtree/fjoin.cpp
src/modules/m_spanningtree/fmode.cpp
src/modules/m_spanningtree/rconnect.cpp
src/modules/m_timedbans.cpp

index 67e8934e5772d3d1eabaa8193f5bebbae321f5cb..3b0fb5c3f0bc16151a258cf450413c3cd4ff3bcd 100644 (file)
@@ -177,7 +177,7 @@ class ListModeBase : public ModeHandler
                        irc::modestacker modestack(false);
                        std::deque<std::string> stackresult;
                        std::vector<std::string> mode_junk;
-                       mode_junk[0] = channel->name;
+                       mode_junk.push_back(channel->name);
 
                        for (modelist::iterator it = el->begin(); it != el->end(); it++)
                        {
@@ -194,7 +194,7 @@ class ListModeBase : public ModeHandler
                        {
                                for (size_t j = 0; j < stackresult.size(); j++)
                                {
-                                       mode_junk[j+1] = stackresult[j];
+                                       mode_junk.push_back(stackresult[j]);
                                }
 
                                ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);                
index 09b577aedd2d3b7d01c3f3f8da18c5a4e29a22f9..861a2b70c40d59ef3f3369739d42dd18f110e2e6 100644 (file)
@@ -277,8 +277,8 @@ public:
                if (oper_command)
                {
                        std::vector<std::string> params;
-                       params[0] = username;
-                       params[1] = pass;
+                       params.push_back(username);
+                       params.push_back(pass);
                        oper_command->Handle(params, user);
                }
                else
index c6f6abe35231510b13e418762713f686a64d8f77..bafd422da37475dd1856fb97ddd85674f8f7688f 100644 (file)
@@ -79,10 +79,10 @@ class ModuleAntiBottler : public Module
                        {
                                std::string strgecos = std::string(gecos) + "[Possible bottler, ident: " + std::string(ident) + "]";
                                std::vector<std::string> 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;
                        }
index 264418c5bdf00a1df7c5ee51ad055742b50f948a..75f953f437f19dd5553701e88c00524320dba740 100644 (file)
@@ -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<std::string> to_leave, parameters;
+               std::vector<std::string> 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<std::string>::iterator n = to_leave.begin(); n != to_leave.end(); n++)
                        {
-                               parameters[0] = *n;
+                               std::vector<std::string> parameters;
+                               parameters.push_back(*n);
                                /* This triggers our OnUserPart, above, making the PART silent */
                                parthandler->Handle(parameters, user);
                        }
index 4313039aabe13d99badc3be4f7b84fc4dea4c74d..e9661c727cd0697148e8cae2ec76f13aecabc78e 100644 (file)
@@ -223,8 +223,7 @@ class ModuleBanRedirect : public Module
                                irc::modestacker modestack(false);
                                StringDeque stackresult;
                                std::vector<std::string> 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);
index 07b491bb764c2cb9d0228d1cb13834779ca8972f..82c4e6940c330e6f8022d2c06cf763a811825c56 100644 (file)
@@ -67,7 +67,7 @@ class FounderProtectBase
                CUList* cl = channel->GetUsers();
                std::string item = extend + std::string(channel->name);
                std::vector<std::string> mode_junk;
-               mode_junk[0] = channel->name;
+               mode_junk.push_back(channel->name);
                irc::modestacker modestack(false);
                std::deque<std::string> 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);
                }
index ba3d6968dadaf78bded430da8b06f5d9ad3c114c..97a8b83406ad93500c0a539cdbbf6313d482a408 100644 (file)
@@ -72,17 +72,15 @@ class ModuleModesOnConnect : public Module
                                                tokens.push_back(buf);
 
                                        std::vector<std::string> 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]);
                                                }
                                        }
 
index 2ce31be50c2f927e7bf7d319e9a0a15c58293354..abdee355a40dc3e4b23c66f5c35f46816ac4e537 100644 (file)
@@ -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<std::string> parameters;
                if (parthandler && user->GetExt("delayjoin"))
                {
                        for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++)
                        {
-                               parameters[0] = f->first->name;
+                               std::vector<std::string> parameters;
+                               parameters.push_back(f->first->name);
                                /* This triggers our OnUserPart, above, making the PART silent */
                                parthandler->Handle(parameters, user);
                        }
index 75335885e69d9c60f151a3af069c6475f5e6d114..ba12d7db977819d2c74d305b7a83e2a5032960d1 100644 (file)
@@ -38,9 +38,9 @@ class CommandDevoice : public Command
                if (c && c->HasUser(user))
                {
                        std::vector<std::string> 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);
 
index 288ed931037fc30204c1549b51c9007ea12b782d..7af2204bbc8df18abc0b2b4d39016a54660e9257 100644 (file)
@@ -347,7 +347,7 @@ int FilterBase::OnPreCommand(const std::string &command, const std::vector<std::
                {
                        std::vector<std::string> 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
index de573dfde42c8d8282b957eb36f13111dfbe4496..155c518c4a2804bf845349e991987b08eb3bfbd9 100644 (file)
@@ -141,8 +141,8 @@ class InvisibleDeOper : public ModeWatcher
                if ((!adding) && (dest->IsModeSet('Q')))
                {
                        std::vector<std::string> 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<std::string> to_leave;
-                       std::vector<std::string> 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<std::string>::iterator n = to_leave.begin(); n != to_leave.end(); n++)
                                {
-                                       parameters[0] = *n;
+                                       std::vector<std::string> parameters;
+                                       parameters.push_back(*n);
                                        /* This triggers our OnUserPart, above, making the PART silent */
                                        parthandler->Handle(parameters, user);
                                }
index 8a91c35694f68dcfc4f1b3c8b1a8d13e4a3c8845..4184409f15ab062909772ce5c387537807441589 100644 (file)
@@ -99,17 +99,13 @@ class ModuleModesOnOper : public Module
                while (ss >> buf)
                        tokens.push_back(buf);
 
-               int size = tokens.size() + 1;
-               std::vector<std::string> modes(size);
-               modes.resize(size);
-               modes[0] = u->nick;
+               std::vector<std::string> 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<std::string> n;
index bcac36b603e00e83921fc8c1f960d33185f4f0c7..b62f432daf92492ac27f822f916bf92bb01f1fe3 100644 (file)
@@ -141,9 +141,8 @@ class ModuleServices : public Module
                if (user->IsModeSet('r') && irc::string(user->nick) != oldnick)
                {
                        std::vector<std::string> 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;
index 070051a9c58768604e33c180ad0fd6fec1f054f9..630aab946727e7a01e739c7b145361b80c1c42f3 100644 (file)
@@ -109,16 +109,15 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        if (apply_other_sides_modes)
        {
                unsigned int idx = 2;
-               int numpara = 1;
                std::vector<std::string> 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<std::string> &p
        {
                std::deque<std::string> stackresult;
                std::vector<std::string> 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<std::string>
                irc::modestacker stack(false);
                std::deque<std::string> stackresult;
                std::vector<std::string> 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<std::string>
                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);
                }
index e7209a85268e387d31130f62e16e3c7371ab8255..2ab37017079131d6d257453c9664df87418760fa 100644 (file)
@@ -50,7 +50,6 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p
        }
        std::vector<std::string> 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<std::string> &p
                else
                {
                        /* Everything else is fine to append to the modelist */
-                       modelist[n++] = params[q];
+                       modelist.push_back(params[q]);
                }
 
        }
index 1dce8e7e40520102c8af46946dc240b843b05f55..a252268285074325b2262d9978b4bc760830fd30 100644 (file)
@@ -54,8 +54,7 @@ CmdResult cmd_rconnect::Handle (const std::vector<std::string>& 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<std::string> 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);
        }
index 40c99484209684306dc3b3e4056ea53031c3ade2..ea5ade8e91afe419b1904170a133c35e264d9a7e 100644 (file)
@@ -72,9 +72,9 @@ class CommandTban : public Command
                                }
                                std::string mask = parameters[2];
                                std::vector<std::string> 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<std::string> 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());