summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-14 17:46:47 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-14 17:46:47 +0000
commita78cecbeb9c677bdd4b2f44c01195759af63485b (patch)
tree03b0a71514c6e0dcf6eec78eefe160a2ea7f8b47 /src/mode.cpp
parent4eb254df411f8dd1694f1b3781c77f702538c59f (diff)
Refactor userrec::chans.
Old way: A vector of ucrec, MAXCHANS in size by default populated by NULLS, so you have to scan the vector to find an empty slot when joining a user, parting a user etc New way: std::map<chanrec*, char> (the char holds their basic core permissions on the channel [voice, halfop, op]) This increases speed a ton, and removes some wtf-age. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5986 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp82
1 files changed, 38 insertions, 44 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index eee50c293..d56e6ec38 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -175,31 +175,28 @@ const char* ModeParser::Grant(userrec *d,chanrec *chan,int MASK)
if (!chan)
return "";
- for (std::vector<ucrec*>::const_iterator i = d->chans.begin(); i != d->chans.end(); i++)
+ UCListIter n = d->chans.find(chan);
+ if (n != d->chans.end())
{
- ucrec* n = (ucrec*)(*i);
- if (n->channel == chan)
+ if (n->second & MASK)
{
- if (n->uc_modes & MASK)
- {
- return "";
- }
- n->uc_modes = n->uc_modes | MASK;
- switch (MASK)
- {
- case UCMODE_OP:
- n->channel->AddOppedUser(d);
- break;
- case UCMODE_HOP:
- n->channel->AddHalfoppedUser(d);
- break;
- case UCMODE_VOICE:
- n->channel->AddVoicedUser(d);
- break;
- }
- ServerInstance->Log(DEBUG,"grant: %s %s",n->channel->name,d->nick);
- return d->nick;
+ return "";
+ }
+ n->second = n->second | MASK;
+ switch (MASK)
+ {
+ case UCMODE_OP:
+ n->first->AddOppedUser(d);
+ break;
+ case UCMODE_HOP:
+ n->first->AddHalfoppedUser(d);
+ break;
+ case UCMODE_VOICE:
+ n->first->AddVoicedUser(d);
+ break;
}
+ ServerInstance->Log(DEBUG,"grant: %s %s",n->first->name,d->nick);
+ return d->nick;
}
return "";
}
@@ -209,31 +206,28 @@ const char* ModeParser::Revoke(userrec *d,chanrec *chan,int MASK)
if (!chan)
return "";
- for (std::vector<ucrec*>::const_iterator i = d->chans.begin(); i != d->chans.end(); i++)
+ UCListIter n = d->chans.find(chan);
+ if (n != d->chans.end())
{
- ucrec* n = (ucrec*)(*i);
- if (n->channel == chan)
+ if ((n->second & MASK) == 0)
{
- if ((n->uc_modes & MASK) == 0)
- {
- return "";
- }
- n->uc_modes ^= MASK;
- switch (MASK)
- {
- case UCMODE_OP:
- n->channel->DelOppedUser(d);
- break;
- case UCMODE_HOP:
- n->channel->DelHalfoppedUser(d);
- break;
- case UCMODE_VOICE:
- n->channel->DelVoicedUser(d);
- break;
- }
- ServerInstance->Log(DEBUG,"revoke: %s %s",n->channel->name,d->nick);
- return d->nick;
+ return "";
+ }
+ n->second ^= MASK;
+ switch (MASK)
+ {
+ case UCMODE_OP:
+ n->first->DelOppedUser(d);
+ break;
+ case UCMODE_HOP:
+ n->first->DelHalfoppedUser(d);
+ break;
+ case UCMODE_VOICE:
+ n->first->DelVoicedUser(d);
+ break;
}
+ ServerInstance->Log(DEBUG,"revoke: %s %s",n->first->name,d->nick);
+ return d->nick;
}
return "";
}