diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-09 11:40:25 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-09 11:40:25 +0000 |
commit | dbbe105fbb9c0de2f0f3c51e4b7c2bc292625df7 (patch) | |
tree | a67d079f156982b0b582a69ef49fbdd7aed047ca /src | |
parent | b251c1feb7f7e379181266f23f4f20a740b68fe8 (diff) |
Grant and revoke now use iterators
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3581 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/mode.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/mode.cpp b/src/mode.cpp index 5b5523dfe..c343ed10b 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -72,29 +72,31 @@ userrec* ModeParser::SanityChecks(userrec *user,char *dest,chanrec *chan,int sta char* ModeParser::Grant(userrec *d,chanrec *chan,int MASK) { - for (unsigned int i = 0; i < d->chans.size(); i++) + if (!chan) + return NULL; + + for (std::vector<ucrec*>::const_iterator i = d->chans.begin(); i != d->chans.end(); i++) { - if ((d->chans[i].channel != NULL) && (chan != NULL)) - if (d->chans[i].channel == chan) + if (((ucrec*)(*i))->channel == chan) { - if (d->chans[i].uc_modes & MASK) + if (((ucrec*)(*i))->uc_modes & MASK) { return NULL; } - d->chans[i].uc_modes = d->chans[i].uc_modes | MASK; + ((ucrec*)(*i))->uc_modes = ((ucrec*)(*i))->uc_modes | MASK; switch (MASK) { case UCMODE_OP: - d->chans[i].channel->AddOppedUser(d); + ((ucrec*)(*i))->channel->AddOppedUser(d); break; case UCMODE_HOP: - d->chans[i].channel->AddHalfoppedUser(d); + ((ucrec*)(*i))->channel->AddHalfoppedUser(d); break; case UCMODE_VOICE: - d->chans[i].channel->AddVoicedUser(d); + ((ucrec*)(*i))->channel->AddVoicedUser(d); break; } - log(DEBUG,"grant: %s %s",d->chans[i].channel->name,d->nick); + log(DEBUG,"grant: %s %s",((ucrec*)(*i))->channel->name,d->nick); return d->nick; } } @@ -103,29 +105,31 @@ char* ModeParser::Grant(userrec *d,chanrec *chan,int MASK) char* ModeParser::Revoke(userrec *d,chanrec *chan,int MASK) { - for (unsigned int i = 0; i < d->chans.size(); i++) + if (!chan) + return NULL; + + for (std::vector<ucrec*>::const_iterator i = d->chans.begin(); i != d->chans.end(); i++) { - if ((d->chans[i].channel != NULL) && (chan != NULL)) - if (d->chans[i].channel == chan) + if (((ucrec*)(*i))->channel == chan) { - if ((d->chans[i].uc_modes & MASK) == 0) + if ((((ucrec*)(*i))->uc_modes & MASK) == 0) { return NULL; } - d->chans[i].uc_modes ^= MASK; + ((ucrec*)(*i))->uc_modes ^= MASK; switch (MASK) { case UCMODE_OP: - d->chans[i].channel->DelOppedUser(d); + ((ucrec*)(*i))->channel->DelOppedUser(d); break; case UCMODE_HOP: - d->chans[i].channel->DelHalfoppedUser(d); + ((ucrec*)(*i))->channel->DelHalfoppedUser(d); break; case UCMODE_VOICE: - d->chans[i].channel->DelVoicedUser(d); + ((ucrec*)(*i))->channel->DelVoicedUser(d); break; } - log(DEBUG,"revoke: %s %s",d->chans[i].channel->name,d->nick); + log(DEBUG,"revoke: %s %s",((ucrec*)(*i))->channel->name,d->nick); return d->nick; } } |