]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
m_spanningtree Call the collision handler with the proper parameter (client ip instea...
[user/henk/code/inspircd.git] / src / users.cpp
index 2ee389c86ff36b5abb69ad005c61fde720b3515a..9c3d645f72c0a64b2ea6491269fedc18a32724db 100644 (file)
@@ -332,75 +332,45 @@ const std::string& User::GetFullRealHost()
 
 bool LocalUser::IsInvited(const irc::string &channel)
 {
-       time_t now = ServerInstance->Time();
-       InvitedList::iterator safei;
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
-       {
-               if (channel == i->first)
-               {
-                       if (i->second != 0 && now > i->second)
-                       {
-                               /* Expired invite, remove it. */
-                               safei = i;
-                               --i;
-                               invites.erase(safei);
-                               continue;
-                       }
-                       return true;
-               }
-       }
-       return false;
+       Channel* chan = ServerInstance->FindChan(channel.c_str());
+       if (!chan)
+               return false;
+
+       return (Invitation::Find(chan, this) != NULL);
 }
 
-InvitedList* LocalUser::GetInviteList()
+InviteList& LocalUser::GetInviteList()
 {
-       time_t now = ServerInstance->Time();
-       /* Weed out expired invites here. */
-       InvitedList::iterator safei;
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
-       {
-               if (i->second != 0 && now > i->second)
-               {
-                       /* Expired invite, remove it. */
-                       safei = i;
-                       --i;
-                       invites.erase(safei);
-               }
-       }
-       return &invites;
+       RemoveExpiredInvites();
+       return invites;
 }
 
 void LocalUser::InviteTo(const irc::string &channel, time_t invtimeout)
 {
-       time_t now = ServerInstance->Time();
-       if (invtimeout != 0 && now > invtimeout) return; /* Don't add invites that are expired from the get-go. */
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); ++i)
-       {
-               if (channel == i->first)
-               {
-                       if (i->second != 0 && invtimeout > i->second)
-                       {
-                               i->second = invtimeout;
-                       }
-
-                       return;
-               }
-       }
-       invites.push_back(std::make_pair(channel, invtimeout));
+       Channel* chan = ServerInstance->FindChan(channel.c_str());
+       if (chan)
+               Invitation::Create(chan, this, invtimeout);
 }
 
 void LocalUser::RemoveInvite(const irc::string &channel)
 {
-       for (InvitedList::iterator i = invites.begin(); i != invites.end(); i++)
+       Channel* chan = ServerInstance->FindChan(channel.c_str());
+       if (chan)
        {
-               if (channel == i->first)
+               Invitation* inv = Invitation::Find(chan, this);
+               if (inv)
                {
-                       invites.erase(i);
-                       return;
-               }
+                       inv->cull();
+                       delete inv;
+               }
        }
 }
 
+void LocalUser::RemoveExpiredInvites()
+{
+       Invitation::Find(NULL, this);
+}
+
 bool User::HasModePermission(unsigned char, ModeType)
 {
        return true;
@@ -559,8 +529,6 @@ CullResult User::cull()
                ServerInstance->Users->QuitUser(this, "Culled without QuitUser");
        PurgeEmptyChannels();
 
-       this->InvalidateCache();
-
        if (client_sa.sa.sa_family != AF_UNSPEC)
                ServerInstance->Users->RemoveCloneCounts(this);
 
@@ -575,6 +543,7 @@ CullResult LocalUser::cull()
        else
                ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector");
 
+       ClearInvites();
        eh.cull();
        return User::cull();
 }
@@ -841,7 +810,7 @@ void LocalUser::FullConnect()
 
        FOREACH_MOD(I_OnPostConnect,OnPostConnect(this));
 
-       ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s!%s@%s [%s] [%s]",
+       ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s!%s@%s (%s) [%s]",
                this->GetServerPort(), this->MyClass->name.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str(), this->GetIPString(), this->fullname.c_str());
        ServerInstance->Logs->Log("BANCACHE", DEBUG, "BanCache: Adding NEGATIVE hit for %s", this->GetIPString());
        ServerInstance->BanCache->AddHit(this->GetIPString(), "", "");