diff --git a/core/AdminCache.cpp b/core/AdminCache.cpp index 7298347a..6f54c66d 100644 --- a/core/AdminCache.cpp +++ b/core/AdminCache.cpp @@ -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; +} diff --git a/core/AdminCache.h b/core/AdminCache.h index f7165a2d..d21bfaef 100644 --- a/core/AdminCache.h +++ b/core/AdminCache.h @@ -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: diff --git a/public/IAdminSystem.h b/public/IAdminSystem.h index 90522313..0a794b04 100644 --- a/public/IAdminSystem.h +++ b/public/IAdminSystem.h @@ -35,7 +35,7 @@ #include #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; }; }