summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-06-18 19:17:39 +0200
committerattilamolnar <attilamolnar@hush.com>2013-07-19 19:40:05 +0200
commit2dc01893c67fedb7b249773c43bc83b46086ee5f (patch)
tree40a1bc5936628b98b4ae0c0c9427b44cf2cf1809
parentfd1d19d6345943ecdb5ce4ef947f9b3c5c8bca86 (diff)
Get rid of enum UserModes and mark User::modes as private
-rw-r--r--include/users.h33
-rw-r--r--src/modules/m_spanningtree/opertype.cpp5
-rw-r--r--src/users.cpp8
3 files changed, 17 insertions, 29 deletions
diff --git a/include/users.h b/include/users.h
index 40ba17332..503357348 100644
--- a/include/users.h
+++ b/include/users.h
@@ -40,19 +40,6 @@ enum ClassTypes {
CC_NAMED = 2
};
-/** RFC1459 channel modes
- */
-enum UserModes {
- /** +s: Server notice mask */
- UM_SNOMASK = 's' - 65,
- /** +w: WALLOPS */
- UM_WALLOPS = 'w' - 65,
- /** +i: Invisible */
- UM_INVISIBLE = 'i' - 65,
- /** +o: Operator */
- UM_OPERATOR = 'o' - 65
-};
-
/** Registration state of a user, e.g.
* have they sent USER, NICK, PASS yet?
*/
@@ -252,6 +239,14 @@ class CoreExport User : public Extensible
*/
std::string cachedip;
+ /** 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.
+ */
+ std::bitset<64> modes;
+
public:
/** Hostname of connection.
@@ -300,18 +295,6 @@ class CoreExport User : public Extensible
*/
std::string fullname;
- /** The user's mode list.
- * NOT a null terminated string.
- * Also NOT an array.
- * 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.
- * The following RFC characters o, w, s, i have constants defined via an
- * enum, such as UM_SERVERNOTICE and UM_OPETATOR.
- */
- std::bitset<64> modes;
-
/** What snomasks are set on this user.
* This functions the same as the above modes.
*/
diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp
index 021100870..9e8c8ed9d 100644
--- a/src/modules/m_spanningtree/opertype.cpp
+++ b/src/modules/m_spanningtree/opertype.cpp
@@ -32,7 +32,10 @@ CmdResult CommandOpertype::Handle(const std::vector<std::string>& params, User *
const std::string& opertype = params[0];
if (!u->IsOper())
ServerInstance->Users->all_opers.push_back(u);
- u->modes[UM_OPERATOR] = 1;
+
+ ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
+ u->SetMode(opermh, true);
+
OperIndex::iterator iter = ServerInstance->Config->oper_blocks.find(" " + opertype);
if (iter != ServerInstance->Config->oper_blocks.end())
u->oper = iter->second;
diff --git a/src/users.cpp b/src/users.cpp
index f4055d464..fe593a139 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -367,10 +367,11 @@ CullResult FakeUser::cull()
void User::Oper(OperInfo* info)
{
- if (this->IsModeSet('o'))
+ ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
+ if (this->IsModeSet(opermh))
this->UnOper();
- this->modes[UM_OPERATOR] = 1;
+ this->SetMode(opermh, true);
this->oper = info;
this->WriteServ("MODE %s :+o", this->nick.c_str());
FOREACH_MOD(I_OnOper, OnOper(this, info->name));
@@ -490,7 +491,8 @@ void User::UnOper()
/* remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404 */
ServerInstance->Users->all_opers.remove(this);
- this->modes[UM_OPERATOR] = 0;
+ ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
+ this->SetMode(opermh, false);
}
/*