From 8b864c8a828d6ca97b5ec15fa7bf8fcc35027294 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 23 Aug 2006 20:20:41 +0000 Subject: Mode handlers handling listmodes where a listmode item is a nickname can now specify prefixes!!!!!! This isnt documented yet. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4997 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/channels.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 14 deletions(-) (limited to 'src/channels.cpp') diff --git a/src/channels.cpp b/src/channels.cpp index a89b9b2c4..4d68af99c 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -430,6 +430,7 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr,ucrec *a,userrec* u /* first user in is given ops */ a->uc_modes = UCMODE_OP; Ptr->AddOppedUser(user); + Ptr->SetPrefix(user, '@', OP_VALUE, true); } else { @@ -880,26 +881,26 @@ long chanrec::GetMaxBans() const char* chanrec::GetStatusChar(userrec *user) { - for (std::vector::const_iterator i = user->chans.begin(); i != user->chans.end(); i++) + static char px[2]; + unsigned int mx = 0; + + *px = 0; + *(px+1) = 0; + + prefixlist::iterator n = prefixes.find(user); + if (n != prefixes.end()) { - if ((*i)->channel == this) + for (std::vector::iterator x = n->second.begin(); x != n->second.end(); x++) { - if (((*i)->uc_modes & UCMODE_OP) > 0) - { - return "@"; - } - if (((*i)->uc_modes & UCMODE_HOP) > 0) - { - return "%"; - } - if (((*i)->uc_modes & UCMODE_VOICE) > 0) + if (x->second > mx) { - return "+"; + *px = x->first; + mx = x->second; } - return ""; } } - return ""; + + return px; } @@ -944,4 +945,34 @@ int chanrec::GetStatus(userrec *user) return STATUS_NORMAL; } +void chanrec::SetPrefix(userrec* user, char prefix, unsigned int prefix_value, bool adding) +{ + prefixlist::iterator n = prefixes.find(user); + prefixtype pfx = std::make_pair(prefix,prefix_value); + if (adding) + { + if (n != prefixes.end()) + { + if (std::find(n->second.begin(), n->second.end(), pfx) == n->second.end()) + { + n->second.push_back(pfx); + } + } + else + { + pfxcontainer one; + one.push_back(pfx); + prefixes.insert(std::make_pair(user, one)); + } + } + else + { + if (n != prefixes.end()) + { + pfxcontainer::iterator x = std::find(n->second.begin(), n->second.end(), pfx); + if (x != n->second.end()) + n->second.erase(x); + } + } +} -- cgit v1.2.3