initial import of the new admin api restructuring

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40439
This commit is contained in:
David Anderson
2007-02-05 09:14:40 +00:00
parent 6a7f216615
commit b018cd9d3a
6 changed files with 289 additions and 209 deletions
+79 -18
View File
@@ -54,25 +54,53 @@ namespace SourceMod
*/
enum AdminFlag
{
Admin_None = 0,
Admin_Reservation, /**< Reserved slot */
Admin_Reservation = 0, /**< Reserved slot */
Admin_Generic, /**< Generic admin abilities */
Admin_Kick, /**< Kick another user */
Admin_Ban, /**< Ban another user */
Admin_Unban, /**< Unban another user */
Admin_Slay, /**< Slay/kill/damage another user */
Admin_Changemap, /**< Change the map */
Admin_Convars, /**< Change basic convars */
Admin_Configs, /**< Change configs */
Admin_Config, /**< Change configuration */
Admin_Chat, /**< Special chat privileges */
Admin_Vote, /**< Special vote privileges */
Admin_Password, /**< Set a server password */
Admin_RCON, /**< Use RCON */
Admin_Cheats, /**< Change sv_cheats and use its commands */
Admin_Root, /**< All access by default */
Admin_Custom1, /**< First custom flag type */
Admin_Custom2, /**< Second custom flag type */
Admin_Custom3, /**< Third custom flag type */
Admin_Custom4, /**< Fourth custom flag type */
Admin_Custom5, /**< Fifth custom flag type */
Admin_Custom6, /**< Sixth custom flag type */
/* --- */
AdminFlags_TOTAL,
};
#define ADMFLAG_RESERVATION (1<<0) /**< Convenience macro for Admin_Reservation as a FlagBit */
#define ADMFLAG_GENERIC (1<<1) /**< Convenience macro for Admin_Generic as a FlagBit */
#define ADMFLAG_KICK (1<<2) /**< Convenience macro for Admin_Kick as a FlagBit */
#define ADMFLAG_BAN (1<<3) /**< Convenience macro for Admin_Ban as a FlagBit */
#define ADMFLAG_UNBAN (1<<4) /**< Convenience macro for Admin_Unban as a FlagBit */
#define ADMFLAG_SLAY (1<<5) /**< Convenience macro for Admin_Slay as a FlagBit */
#define ADMFLAG_CHANGEMAP (1<<6) /**< Convenience macro for Admin_Changemap as a FlagBit */
#define ADMFLAG_CONVARS (1<<7) /**< Convenience macro for Admin_Convars as a FlagBit */
#define ADMFLAG_CONFIG (1<<8) /**< Convenience macro for Admin_Config as a FlagBit */
#define ADMFLAG_CHAT (1<<9) /**< Convenience macro for Admin_Chat as a FlagBit */
#define ADMFLAG_VOTE (1<<10) /**< Convenience macro for Admin_Vote as a FlagBit */
#define ADMFLAG_PASSWORD (1<<11) /**< Convenience macro for Admin_Password as a FlagBit */
#define ADMFLAG_RCON (1<<12) /**< Convenience macro for Admin_RCON as a FlagBit */
#define ADMFLAG_CHEATS (1<<13) /**< Convenience macro for Admin_Cheats as a FlagBit */
#define ADMFLAG_ROOT (1<<14) /**< Convenience macro for Admin_Root as a FlagBit */
#define ADMFLAG_CUSTOM1 (1<<15) /**< Convenience macro for Admin_Custom1 as a FlagBit */
#define ADMFLAG_CUSTOM2 (1<<16) /**< Convenience macro for Admin_Custom2 as a FlagBit */
#define ADMFLAG_CUSTOM3 (1<<17) /**< Convenience macro for Admin_Custom3 as a FlagBit */
#define ADMFLAG_CUSTOM4 (1<<18) /**< Convenience macro for Admin_Custom4 as a FlagBit */
#define ADMFLAG_CUSTOM5 (1<<19) /**< Convenience macro for Admin_Custom5 as a FlagBit */
#define ADMFLAG_CUSTOM6 (1<<20) /**< Convenience macro for Admin_Custom6 as a FlagBit */
/**
* @brief Specifies which type of command to override (command or command group).
*/
@@ -148,6 +176,8 @@ namespace SourceMod
virtual void OnRebuildAdminCache(int cache_flags) =0;
};
typedef unsigned int FlagBits;
/**
* @brief Provides functions for manipulating the admin options cache.
*/
@@ -169,19 +199,19 @@ namespace SourceMod
*
* @param cmd String containing command name (case sensitive).
* @param type Override type (specific command or group).
* @param flag New admin flag.
* @param flags New admin flag.
*/
virtual void AddCommandOverride(const char *cmd, OverrideType type, AdminFlag flag) =0;
virtual void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags) =0;
/**
* @brief Returns a command override.
*
* @param cmd String containing command name (case sensitive).
* @param type Override type (specific command or group).
* @param pFlag Optional pointer to the set flag.
* @param pFlags Optional pointer to the set flag.
* @return True if there is an override, false otherwise.
*/
virtual bool GetCommandOverride(const char *cmd, OverrideType type, AdminFlag *pFlag) =0;
virtual bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags) =0;
/**
* @brief Unsets a command override.
@@ -231,11 +261,9 @@ namespace SourceMod
* Note: These are called "add flags" because they add to a user's flags.
*
* @param id GroupId of the group.
* @param flags Array to store flags bits in.
* @param total Total number of flags that can be stored in the array.
* @return Number of flags that were written to the array.
* @return Bit string containing the bits of each flag.
*/
virtual unsigned int GetGroupAddFlagBits(GroupId id, bool flags[], unsigned int total) =0;
virtual FlagBits GetGroupAddFlags(GroupId id) =0;
/**
* @brief Toggles a generic immunity type.
@@ -391,15 +419,10 @@ namespace SourceMod
* @brief Returns a bitarray of flags enabled on an admin.
*
* @param id AdminId index of the admin.
* @param flag Array to store flag bits in.
* @param total Maximum size of the flag array.
* @param mode Access mode to use.
* @return Number of flags written to the array.
* @return A bit string containing which flags are enabled.
*/
virtual unsigned int GetAdminFlags(AdminId id,
bool flags[],
unsigned int total,
AccessMode mode) =0;
virtual FlagBits GetAdminFlags(AdminId id, AccessMode mode) =0;
/**
* @brief Adds a group to an admin's inherited group list.
@@ -463,6 +486,44 @@ namespace SourceMod
* @return True on success, false otherwise.
*/
virtual bool InvalidateAdmin(AdminId id) =0;
/**
* @brief Converts a flag bit string to a bit array.
*
* @param bits Bit string containing the flags.
* @param array Array to write the flags to. Enabled flags will be 'true'.
* @param maxSize Maximum number of flags the array can store.
* @return Number of flags written.
*/
virtual unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize) =0;
/**
* @brief Converts a flag array to a bit string.
*
* @param array Array containing true or false for each AdminFlag.
* @param maxSize Maximum size of the flag array.
* @return A bit string composed of the array bits.
*/
virtual FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize) =0;
/**
* @brief Converts an array of flags to bits.
*
* @param array Array containing flags that are enabled.
* @param numFlags Number of flags in the array.
* @return A bit string composed of the array flags.
*/
virtual FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags) =0;
/**
* @brief Converts a bit string to an array of flags.
*
* @param bits Bit string containing the flags.
* @param array Output array to write flags.
* @param maxSize Maximum size of the flag array.
* @return Number of flags written.
*/
virtual unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize) =0;
};
}