diff options
| author | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-03-23 21:05:29 +0000 |
|---|---|---|
| committer | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-03-23 21:05:29 +0000 |
| commit | b3eeb815b6e01456b0c987305454bc9b5a5f5a14 (patch) | |
| tree | f3832a89e3a123fe4c57223bf1b18294be9f0edd /src/nickcore.cpp | |
| parent | da43e02228dfddc921946a94ae3790a35559b1d5 (diff) | |
Replace manually allocated array for NickCore's access list with an std::vector, cleans up the code and provides a more sane interface, also fixes bug #1023 in the process.
Also add missing help for NS ACCESS.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2201 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/nickcore.cpp')
| -rw-r--r-- | src/nickcore.cpp | 104 |
1 files changed, 70 insertions, 34 deletions
diff --git a/src/nickcore.cpp b/src/nickcore.cpp index af4680f45..6dadc9217 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -1,34 +1,70 @@ -#include "services.h"
-
-NickCore::NickCore()
-{
- next = prev = NULL;
- display = email = greet = url = NULL;
- ot = NULL;
- pass[0] = '\0';
- icq = flags = 0;
- language = accesscount = channelcount = 0;
- lastmail = 0;
-}
-
-bool NickCore::HasCommand(const std::string &cmdstr) const
-{
- if (!this->ot)
- {
- // No opertype.
- return false;
- }
-
- return this->ot->HasCommand(cmdstr);
-}
-
-bool NickCore::HasPriv(const std::string &privstr) const
-{
- if (!this->ot)
- {
- // No opertype.
- return false;
- }
-
- return this->ot->HasPriv(privstr);
-}
+#include "services.h" + +NickCore::NickCore() +{ + next = prev = NULL; + display = email = greet = url = NULL; + ot = NULL; + pass[0] = '\0'; + icq = flags = 0; + language = channelcount = 0; + lastmail = 0; +} + +bool NickCore::HasCommand(const std::string &cmdstr) const +{ + if (!this->ot) + { + // No opertype. + return false; + } + + return this->ot->HasCommand(cmdstr); +} + +bool NickCore::HasPriv(const std::string &privstr) const +{ + if (!this->ot) + { + // No opertype. + return false; + } + + return this->ot->HasPriv(privstr); +} + +void NickCore::AddAccess(const std::string &entry) +{ + access.push_back(entry); +} + +std::string NickCore::GetAccess(unsigned entry) +{ + if (access.empty() || entry >= access.size()) + return ""; + return access[entry]; +} + +bool NickCore::FindAccess(const std::string &entry) +{ + for (unsigned i = 0; i < access.size(); ++i) + if (access[i] == entry) + return true; + + return false; +} + +void NickCore::EraseAccess(const std::string &entry) +{ + for (unsigned i = 0; i < access.size(); ++i) + if (access[i] == entry) + { + access.erase(access.begin() + i); + break; + } +} + +void NickCore::ClearAccess() +{ + access.clear(); +} |
