]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/xline.cpp
Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters
[user/henk/code/inspircd.git] / src / xline.cpp
index 63a64d6b9d74d2b9ab73a4e38c8702f37b3c990b..003d77e80ef4facc76d73b42c6b25c3d5e15c417 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "inspircd.h"
 #include "xline.h"
-#include "bancache.h"
 
 /** An XLineFactory specialized to generate GLine* pointers
  */
@@ -156,7 +155,8 @@ void XLineManager::CheckELines()
        if (ELines.empty())
                return;
 
-       for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++)
        {
                LocalUser* u = *u2;
 
@@ -276,7 +276,7 @@ bool XLineManager::AddLine(XLine* line, User* user)
        if (!xlf)
                return false;
 
-       ServerInstance->BanCache->RemoveEntries(line->type, false); // XXX perhaps remove ELines here?
+       ServerInstance->BanCache.RemoveEntries(line->type, false); // XXX perhaps remove ELines here?
 
        if (xlf->AutoApplyToUserList(line))
                pending_lines.push_back(line);
@@ -306,15 +306,13 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User*
        if (simulate)
                return true;
 
-       ServerInstance->BanCache->RemoveEntries(y->second->type, true);
+       ServerInstance->BanCache.RemoveEntries(y->second->type, true);
 
        FOREACH_MOD(OnDelLine, (user, y->second));
 
        y->second->Unset();
 
-       std::vector<XLine*>::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), y->second);
-       if (pptr != pending_lines.end())
-               pending_lines.erase(pptr);
+       stdalgo::erase(pending_lines, y->second);
 
        delete y->second;
        x->second.erase(y);
@@ -326,7 +324,8 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User*
 void ELine::Unset()
 {
        /* remove exempt from everyone and force recheck after deleting eline */
-       for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++)
        {
                LocalUser* u = *u2;
                u->exempt = false;
@@ -418,9 +417,7 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
         * is pending, cleared when it is no longer pending, so we skip over this loop if its not pending?
         * -- Brain
         */
-       std::vector<XLine*>::iterator pptr = std::find(pending_lines.begin(), pending_lines.end(), item->second);
-       if (pptr != pending_lines.end())
-               pending_lines.erase(pptr);
+       stdalgo::erase(pending_lines, item->second);
 
        delete item->second;
        container->second.erase(item);
@@ -430,10 +427,10 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
 // applies lines, removing clients and changing nicks etc as applicable
 void XLineManager::ApplyLines()
 {
-       LocalUserList::reverse_iterator u2 = ServerInstance->Users->local_users.rbegin();
-       while (u2 != ServerInstance->Users->local_users.rend())
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator j = list.begin(); j != list.end(); ++j)
        {
-               LocalUser* u = *u2++;
+               LocalUser* u = *j;
 
                // Don't ban people who are exempt.
                if (u->exempt)
@@ -471,7 +468,7 @@ void XLineManager::InvokeStats(const std::string &type, int numeric, User* user,
                                ExpireLine(n, i);
                        }
                        else
-                               results.push_back(ServerInstance->Config->ServerName+" "+ConvToStr(numeric)+" "+user->nick+" :"+i->second->Displayable()+" "+
+                               results.push_back(ConvToStr(numeric)+" "+user->nick+" :"+i->second->Displayable()+" "+
                                        ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+i->second->source+" :"+i->second->reason);
                        i = safei;
                }
@@ -534,7 +531,7 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
        const std::string banReason = line + "-Lined: " + reason;
 
        if (!ServerInstance->Config->XLineMessage.empty())
-               u->WriteNotice("*** " + ServerInstance->Config->XLineMessage);
+               u->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
 
        if (ServerInstance->Config->HideBans)
                ServerInstance->Users->QuitUser(u, line + "-Lined", &banReason);
@@ -545,7 +542,7 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache)
        if (bancache)
        {
                ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Adding positive hit (" + line + ") for " + u->GetIPString());
-               ServerInstance->BanCache->AddHit(u->GetIPString(), this->type, banReason, this->duration);
+               ServerInstance->BanCache.AddHit(u->GetIPString(), this->type, banReason, this->duration);
        }
 }
 
@@ -642,7 +639,7 @@ bool QLine::Matches(User *u)
 void QLine::Apply(User* u)
 {
        /* Force to uuid on apply of qline, no need to disconnect any more :) */
-       u->ForceNickChange(u->uuid);
+       u->ChangeNick(u->uuid);
 }
 
 
@@ -680,7 +677,8 @@ bool GLine::Matches(const std::string &str)
 void ELine::OnAdd()
 {
        /* When adding one eline, only check the one eline */
-       for (LocalUserList::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
+       const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+       for (UserManager::LocalList::const_iterator u2 = list.begin(); u2 != list.end(); u2++)
        {
                LocalUser* u = *u2;
                if (this->Matches(u))