diff options
author | aquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-13 15:47:01 +0000 |
---|---|---|
committer | aquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-13 15:47:01 +0000 |
commit | 09197a4a21d0922d92407902db0019ee4670aa9f (patch) | |
tree | 9258eb3ddce35ddf1b7656b0d2a8be41bfcca032 | |
parent | 76e9dc04d73d94e178224bcda021edae2f7bed9b (diff) |
Changed Allowed Modes to bitsets.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10541 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/users.h | 4 | ||||
-rw-r--r-- | src/users.cpp | 45 |
2 files changed, 10 insertions, 39 deletions
diff --git a/include/users.h b/include/users.h index 5aff66e54..fdfa4606b 100644 --- a/include/users.h +++ b/include/users.h @@ -456,10 +456,10 @@ class CoreExport User : public EventHandler std::map<std::string, bool>* AllowedOperCommands; /** Allowed user modes from oper classes. */ - bool* AllowedUserModes; + std::bitset<64> AllowedUserModes; /** Allowed channel modes from oper classes. */ - bool* AllowedChanModes; + std::bitset<64> AllowedChanModes; public: /** Contains a pointer to the connect class a user is on from - this will be NULL for remote connections. diff --git a/src/users.cpp b/src/users.cpp index 01a973dea..c5a76a803 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -216,8 +216,6 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance Visibility = NULL; ip = NULL; MyClass = NULL; - AllowedUserModes = NULL; - AllowedChanModes = NULL; AllowedOperCommands = NULL; chans.clear(); invites.clear(); @@ -250,18 +248,6 @@ User::~User() AllowedOperCommands = NULL; } - if (this->AllowedUserModes) - { - delete[] AllowedUserModes; - AllowedUserModes = NULL; - } - - if (this->AllowedChanModes) - { - delete[] AllowedChanModes; - AllowedChanModes = NULL; - } - this->InvalidateCache(); this->DecrementModes(); @@ -483,8 +469,7 @@ bool User::HasModePermission(unsigned char mode, ModeType type) if (!IS_OPER(this)) return false; - if (!AllowedUserModes || !AllowedChanModes) - return false; + if (mode < 'A' || mode > ('A' + 64)) return false; return ((type == MODETYPE_USER ? AllowedUserModes : AllowedChanModes))[(mode - 'A')]; @@ -735,14 +720,9 @@ void User::Oper(const std::string &opertype, const std::string &opername) else AllowedOperCommands = new std::map<std::string, bool>; - if (!AllowedChanModes) - AllowedChanModes = new bool[64]; - - if (!AllowedUserModes) - AllowedUserModes = new bool[64]; - - memset(AllowedUserModes, 0, 64); - memset(AllowedChanModes, 0, 64); + AllowedUserModes.reset(); + AllowedChanModes.reset(); + this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want. char* Classes = strdup(iter_opertype->second); char* myclass = strtok_r(Classes," ",&savept); @@ -759,12 +739,11 @@ void User::Oper(const std::string &opertype, const std::string &opername) mycmd = strtok_r(NULL," ",&savept2); } free(CommandList); - this->AllowedUserModes['o' - 'A'] = true; // Call me paranoid if you want. for (unsigned char* c = (unsigned char*)iter_operclass->second.umodelist; *c; ++c) { if (*c == '*') { - memset(this->AllowedUserModes, (int)(true), 64); + this->AllowedUserModes.set(); } else { @@ -775,7 +754,7 @@ void User::Oper(const std::string &opertype, const std::string &opername) { if (*c == '*') { - memset(this->AllowedChanModes, (int)(true), 64); + this->AllowedChanModes.set(); } else { @@ -826,17 +805,9 @@ void User::UnOper() delete AllowedOperCommands; AllowedOperCommands = NULL; } - if (AllowedUserModes) - { - delete[] AllowedUserModes; - AllowedUserModes = NULL; - } - if (AllowedChanModes) - { - delete[] AllowedChanModes; - AllowedChanModes = NULL; - } + AllowedUserModes.reset(); + AllowedChanModes.reset(); } } |