added CheckCommandAccess() equivalent to IAdminSystem

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401479
This commit is contained in:
David Anderson 2007-09-26 01:03:20 +00:00
parent 2df94fb594
commit 69c65a848b
3 changed files with 46 additions and 5 deletions

View File

@ -1707,3 +1707,25 @@ unsigned int AdminCache::GetAdminImmunityLevel(AdminId id)
return pUser->immunity_level;
}
bool AdminCache::CheckAccess(int client, const char *cmd, AdminFlag flags, bool override_only)
{
if (client == 0)
{
return true;
}
/* Auto-detect a command if we can */
FlagBits bits = flags;
bool found_command = false;
if (!override_only)
{
found_command = g_ConCmds.LookForCommandAdminFlags(cmd, &bits);
}
if (!found_command)
{
GetCommandOverride(cmd, Override_Command, &bits);
}
return g_ConCmds.CheckCommandAccess(client, cmd, bits) ? 1 : 0;
}

View File

@ -156,10 +156,14 @@ public: //IAdminSystem
unsigned int GetAdminSerialChange(AdminId id);
bool CanAdminUseCommand(int client, const char *cmd);
const char *GetGroupName(GroupId gid);
virtual unsigned int SetGroupImmunityLevel(GroupId gid, unsigned int level);
virtual unsigned int GetGroupImmunityLevel(GroupId gid);
virtual unsigned int SetAdminImmunityLevel(AdminId id, unsigned int level);
virtual unsigned int GetAdminImmunityLevel(AdminId id);
unsigned int SetGroupImmunityLevel(GroupId gid, unsigned int level);
unsigned int GetGroupImmunityLevel(GroupId gid);
unsigned int SetAdminImmunityLevel(AdminId id, unsigned int level);
unsigned int GetAdminImmunityLevel(AdminId id);
bool CheckAccess(int client,
const char *cmd,
AdminFlag flags,
bool override_only);
public:
bool IsValidAdmin(AdminId id);
private:

View File

@ -35,7 +35,7 @@
#include <IShareSys.h>
#define SMINTERFACE_ADMINSYS_NAME "IAdminSys"
#define SMINTERFACE_ADMINSYS_VERSION 4
#define SMINTERFACE_ADMINSYS_VERSION 5
/**
* @file IAdminSystem.h
@ -702,6 +702,21 @@ namespace SourceMod
* @return Immunity level value.
*/
virtual unsigned int GetAdminImmunityLevel(AdminId id) =0;
/**
* @brief Computers access to an override.
*
* @param client Client index.
* @param override Override name.
* @param flags Default flags.
* @param override_only If false, if a command matches the override,
* then its flags will override the default.
* @return True if the client has access, false otherwise.
*/
virtual bool CheckAccess(int client,
const char *cmd,
AdminFlag flags,
bool override_only) =0;
};
}