]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
ModeParser::InsertMode is no longer required -- this is auto-generated by the ModePar...
[user/henk/code/inspircd.git] / src / channels.cpp
index 4d68af99cf1d45a6a00dbaf8f389924db4bf3722..e7564c3ea6ceddac42aa347dbf7edd47675039fa 100644 (file)
@@ -482,6 +482,7 @@ long chanrec::PartUser(userrec *user, const char* reason)
                        }
                        user->chans[i]->uc_modes = 0;
                        user->chans[i]->channel = NULL;
+                       this->RemoveAllPrefixes(user);
                        break;
                }
        }
@@ -528,6 +529,7 @@ long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggereven
                        this->WriteChannelWithServ(ServerInstance->Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason);
                        user->chans[i]->uc_modes = 0;
                        user->chans[i]->channel = NULL;
+                       this->RemoveAllPrefixes(user);
                        break;
                }
        }
@@ -610,6 +612,7 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason)
                        this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason);
                        (*i)->uc_modes = 0;
                        (*i)->channel = NULL;
+                       this->RemoveAllPrefixes(user);
                        break;
                }
        }
@@ -832,7 +835,7 @@ void chanrec::UserList(userrec *user)
                        continue;
                }
 
-               size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", this->GetStatusChar(i->second), i->second->nick);
+               size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", this->GetPrefixChar(i->second), i->second->nick);
 
                curlen += ptrlen;
                ptr += ptrlen;
@@ -877,9 +880,9 @@ long chanrec::GetMaxBans()
 
 /* returns the status character for a given user on a channel, e.g. @ for op,
  * % for halfop etc. If the user has several modes set, the highest mode
- * the user has must be returned. */
-
-const char* chanrec::GetStatusChar(userrec *user)
+ * the user has must be returned.
+ */
+const char* chanrec::GetPrefixChar(userrec *user)
 {
        static char px[2];
        unsigned int mx = 0;
@@ -903,6 +906,43 @@ const char* chanrec::GetStatusChar(userrec *user)
        return px;
 }
 
+const char* chanrec::GetAllPrefixChars(userrec* user)
+{
+       static char prefix[MAXBUF];
+       int ctr = 0;
+       *prefix = 0;
+
+       prefixlist::iterator n = prefixes.find(user);
+       if (n != prefixes.end())
+       {
+               for (std::vector<prefixtype>::iterator x = n->second.begin(); x != n->second.end(); x++)
+               {
+                       prefix[ctr++] = x->first;
+               }
+       }
+
+       prefix[ctr] = 0;
+
+       return prefix;
+}
+
+unsigned int chanrec::GetPrefixValue(userrec* user)
+{
+       unsigned int mx = 0;
+
+       prefixlist::iterator n = prefixes.find(user);
+       if (n != prefixes.end())
+       {
+               for (std::vector<prefixtype>::iterator x = n->second.begin(); x != n->second.end(); x++)
+               {
+                       if (x->second > mx)
+                               mx  = x->second;
+               }
+       }
+
+       return mx;
+}
+
 
 int chanrec::GetStatusFlags(userrec *user)
 {
@@ -917,7 +957,6 @@ int chanrec::GetStatusFlags(userrec *user)
 }
 
 
-
 int chanrec::GetStatus(userrec *user)
 {
        if (ServerInstance->ULine(user->server))
@@ -976,3 +1015,10 @@ void chanrec::SetPrefix(userrec* user, char prefix, unsigned int prefix_value, b
        }
 }
 
+void chanrec::RemoveAllPrefixes(userrec* user)
+{
+       prefixlist::iterator n = prefixes.find(user);
+       if (n != prefixes.end())
+               prefixes.erase(n);
+}
+