summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-02-21 15:11:24 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-02-21 15:11:24 +0100
commit7ffef79f97c8dc9f21da35dff9f822be7f62edf3 (patch)
tree075be36de9df1ee6e1a5845343e4bf970824dc00 /include
parent1b6dda7ad54dd0242cd9eac30f167d76f061d2fa (diff)
Index Channel::modes and User::modes with the id of the mode instead of its letter
Diffstat (limited to 'include')
-rw-r--r--include/channels.h10
-rw-r--r--include/users.h14
2 files changed, 10 insertions, 14 deletions
diff --git a/include/channels.h b/include/channels.h
index ba2018e97..628f34f9f 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -41,12 +41,10 @@ class CoreExport Channel : public Extensible, public InviteBase<Channel>
void SetDefaultModes();
/** Modes for the channel.
- * This is not a null terminated string! It is a bitset where
- * each item in it represents if a mode is set. For example
- * for mode +A, index 0. Use modechar-65 to calculate which
- * field to check.
+ * It is a bitset where each item in it represents if a mode is set.
+ * To see if a mode is set, inspect modes[mh->modeid]
*/
- std::bitset<64> modes;
+ std::bitset<ModeParser::MODEID_MAX> modes;
/** Remove the given membership from the channel's internal map of
* memberships and destroy the Membership object.
@@ -113,7 +111,7 @@ class CoreExport Channel : public Extensible, public InviteBase<Channel>
* @param mode The mode character you wish to query
* @return True if the custom mode is set, false if otherwise
*/
- inline bool IsModeSet(ModeHandler* mode) { return modes[mode->GetModeChar()-'A']; }
+ bool IsModeSet(ModeHandler* mode) { return ((mode->GetId() != ModeParser::MODEID_MAX) && (modes[mode->GetId()])); }
bool IsModeSet(ModeHandler& mode) { return IsModeSet(&mode); }
bool IsModeSet(ChanModeReference& mode);
diff --git a/include/users.h b/include/users.h
index c699ebab7..24783b304 100644
--- a/include/users.h
+++ b/include/users.h
@@ -241,11 +241,11 @@ class CoreExport User : public Extensible
/** The user's mode list.
* Much love to the STL for giving us an easy to use bitset, saving us RAM.
- * if (modes[modeletter-65]) is set, then the mode is
- * set, for example, to work out if mode +s is set, we check the field
- * User::modes['s'-65] != 0.
+ * if (modes[modeid]) is set, then the mode is set.
+ * For example, to work out if mode +i is set, we check the field
+ * User::modes[invisiblemode->modeid] == true.
*/
- std::bitset<64> modes;
+ std::bitset<ModeParser::MODEID_MAX> modes;
public:
@@ -865,8 +865,7 @@ inline FakeUser* IS_SERVER(User* u)
inline bool User::IsModeSet(ModeHandler* mh)
{
- char m = mh->GetModeChar();
- return (modes[m-65]);
+ return (modes[mh->GetId()]);
}
inline bool User::IsModeSet(UserModeReference& moderef)
@@ -878,6 +877,5 @@ inline bool User::IsModeSet(UserModeReference& moderef)
inline void User::SetMode(ModeHandler* mh, bool value)
{
- char m = mh->GetModeChar();
- modes[m-65] = value;
+ modes[mh->GetId()] = value;
}