diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-09-01 14:25:15 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-09-11 12:10:07 +0200 |
commit | 34fa5627de0a0431ca76f34445c680a76a9a7dc5 (patch) | |
tree | 4b63f6ce49983e161051f70e066ecf9bf974cc88 /src/channels.cpp | |
parent | 537ad4740afdbc656326cce766d1818cf5811c37 (diff) |
Create a base class for prefix modes
Move Channel::SetPrefix() into Membership
Diffstat (limited to 'src/channels.cpp')
-rw-r--r-- | src/channels.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index afc569909..91aec6fa5 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -343,9 +343,8 @@ void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, boo if (mh && mh->GetPrefixRank()) { std::string nick = user->nick; - /* Set, and make sure that the mode handler knows this mode was now set */ - this->SetPrefix(user, mh->GetModeChar(), true); - mh->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, nick, true); + // Set the mode on the user + mh->OnModeChange(ServerInstance->FakeClient, NULL, this, nick, true); } } } @@ -792,29 +791,23 @@ unsigned int Channel::GetPrefixValue(User* user) return m->second->getRank(); } -bool Channel::SetPrefix(User* user, char prefix, bool adding) +bool Membership::SetPrefix(ModeHandler* delta_mh, bool adding) { - ModeHandler* delta_mh = ServerInstance->Modes->FindMode(prefix, MODETYPE_CHANNEL); - if (!delta_mh) - return false; - UserMembIter m = userlist.find(user); - if (m == userlist.end()) - return false; - for(unsigned int i=0; i < m->second->modes.length(); i++) + char prefix = delta_mh->GetModeChar(); + for (unsigned int i = 0; i < modes.length(); i++) { - char mchar = m->second->modes[i]; + char mchar = modes[i]; ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL); if (mh && mh->GetPrefixRank() <= delta_mh->GetPrefixRank()) { - m->second->modes = - m->second->modes.substr(0,i) + + modes = modes.substr(0,i) + (adding ? std::string(1, prefix) : "") + - m->second->modes.substr(mchar == prefix ? i+1 : i); + modes.substr(mchar == prefix ? i+1 : i); return adding != (mchar == prefix); } } if (adding) - m->second->modes += std::string(1, prefix); + modes.push_back(prefix); return adding; } |