X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=e7564c3ea6ceddac42aa347dbf7edd47675039fa;hb=3382adb9e9a79748b4db09bb41a296861800fa2d;hp=4d68af99cf1d45a6a00dbaf8f389924db4bf3722;hpb=8b864c8a828d6ca97b5ec15fa7bf8fcc35027294;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index 4d68af99c..e7564c3ea 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -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::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::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); +} +