diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-10 15:44:03 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-10 15:44:03 +0000 |
commit | dafc021be4f3ad34ca37953de6a0109a161dd165 (patch) | |
tree | f6263063894fa0a923656d64d0e3e1351e0e205f /src/channels.cpp | |
parent | 667bf736370b1d632f6ff99ce32bdcd7f0de9b3f (diff) |
cmode(), cflags(), cstatus() -> chanrec::GetStatusChar(), chanrec::GetStatusFlags(), chanrec::GetStatus()
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4837 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/channels.cpp')
-rw-r--r-- | src/channels.cpp | 77 |
1 files changed, 74 insertions, 3 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index a78b92642..20353ff1f 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -588,8 +588,8 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason) if ((MOD_RESULT == ACR_DEFAULT) || (!is_uline(src->server))) { - int them = cstatus(src, this); - int us = cstatus(user, this); + int them = this->GetStatus(src); + int us = this->GetStatus(user); if ((them < STATUS_HOP) || (them < us)) { if (them == STATUS_HOP) @@ -838,7 +838,7 @@ void chanrec::UserList(userrec *user) continue; } - size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", cmode(i->second, this), i->second->nick); + size_t ptrlen = snprintf(ptr, MAXBUF, "%s%s ", this->GetStatusChar(i->second), i->second->nick); curlen += ptrlen; ptr += ptrlen; @@ -881,3 +881,74 @@ 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) +{ + for (std::vector<ucrec*>::const_iterator i = user->chans.begin(); i != user->chans.end(); i++) + { + if ((*i)->channel == this) + { + if (((*i)->uc_modes & UCMODE_OP) > 0) + { + return "@"; + } + if (((*i)->uc_modes & UCMODE_HOP) > 0) + { + return "%"; + } + if (((*i)->uc_modes & UCMODE_VOICE) > 0) + { + return "+"; + } + return ""; + } + } + return ""; +} + + +int chanrec::GetStatusFlags(userrec *user) +{ + for (std::vector<ucrec*>::const_iterator i = user->chans.begin(); i != user->chans.end(); i++) + { + if ((*i)->channel == this) + { + return (*i)->uc_modes; + } + } + return 0; +} + + + +int chanrec::GetStatus(userrec *user) +{ + if (is_uline(user->server)) + return STATUS_OP; + + for (std::vector<ucrec*>::const_iterator i = user->chans.begin(); i != user->chans.end(); i++) + { + if ((*i)->channel == this) + { + if (((*i)->uc_modes & UCMODE_OP) > 0) + { + return STATUS_OP; + } + if (((*i)->uc_modes & UCMODE_HOP) > 0) + { + return STATUS_HOP; + } + if (((*i)->uc_modes & UCMODE_VOICE) > 0) + { + return STATUS_VOICE; + } + return STATUS_NORMAL; + } + } + return STATUS_NORMAL; +} + + |