1.1 --- a/public/IAdminSystem.h Mon Feb 05 08:58:03 2007 +0000
1.2 +++ b/public/IAdminSystem.h Mon Feb 05 09:14:40 2007 +0000
1.3 @@ -54,25 +54,53 @@
1.4 */
1.5 enum AdminFlag
1.6 {
1.7 - Admin_None = 0,
1.8 - Admin_Reservation, /**< Reserved slot */
1.9 + Admin_Reservation = 0, /**< Reserved slot */
1.10 + Admin_Generic, /**< Generic admin abilities */
1.11 Admin_Kick, /**< Kick another user */
1.12 Admin_Ban, /**< Ban another user */
1.13 Admin_Unban, /**< Unban another user */
1.14 Admin_Slay, /**< Slay/kill/damage another user */
1.15 Admin_Changemap, /**< Change the map */
1.16 Admin_Convars, /**< Change basic convars */
1.17 - Admin_Configs, /**< Change configs */
1.18 + Admin_Config, /**< Change configuration */
1.19 Admin_Chat, /**< Special chat privileges */
1.20 Admin_Vote, /**< Special vote privileges */
1.21 Admin_Password, /**< Set a server password */
1.22 Admin_RCON, /**< Use RCON */
1.23 Admin_Cheats, /**< Change sv_cheats and use its commands */
1.24 Admin_Root, /**< All access by default */
1.25 + Admin_Custom1, /**< First custom flag type */
1.26 + Admin_Custom2, /**< Second custom flag type */
1.27 + Admin_Custom3, /**< Third custom flag type */
1.28 + Admin_Custom4, /**< Fourth custom flag type */
1.29 + Admin_Custom5, /**< Fifth custom flag type */
1.30 + Admin_Custom6, /**< Sixth custom flag type */
1.31 /* --- */
1.32 AdminFlags_TOTAL,
1.33 };
1.34
1.35 + #define ADMFLAG_RESERVATION (1<<0) /**< Convenience macro for Admin_Reservation as a FlagBit */
1.36 + #define ADMFLAG_GENERIC (1<<1) /**< Convenience macro for Admin_Generic as a FlagBit */
1.37 + #define ADMFLAG_KICK (1<<2) /**< Convenience macro for Admin_Kick as a FlagBit */
1.38 + #define ADMFLAG_BAN (1<<3) /**< Convenience macro for Admin_Ban as a FlagBit */
1.39 + #define ADMFLAG_UNBAN (1<<4) /**< Convenience macro for Admin_Unban as a FlagBit */
1.40 + #define ADMFLAG_SLAY (1<<5) /**< Convenience macro for Admin_Slay as a FlagBit */
1.41 + #define ADMFLAG_CHANGEMAP (1<<6) /**< Convenience macro for Admin_Changemap as a FlagBit */
1.42 + #define ADMFLAG_CONVARS (1<<7) /**< Convenience macro for Admin_Convars as a FlagBit */
1.43 + #define ADMFLAG_CONFIG (1<<8) /**< Convenience macro for Admin_Config as a FlagBit */
1.44 + #define ADMFLAG_CHAT (1<<9) /**< Convenience macro for Admin_Chat as a FlagBit */
1.45 + #define ADMFLAG_VOTE (1<<10) /**< Convenience macro for Admin_Vote as a FlagBit */
1.46 + #define ADMFLAG_PASSWORD (1<<11) /**< Convenience macro for Admin_Password as a FlagBit */
1.47 + #define ADMFLAG_RCON (1<<12) /**< Convenience macro for Admin_RCON as a FlagBit */
1.48 + #define ADMFLAG_CHEATS (1<<13) /**< Convenience macro for Admin_Cheats as a FlagBit */
1.49 + #define ADMFLAG_ROOT (1<<14) /**< Convenience macro for Admin_Root as a FlagBit */
1.50 + #define ADMFLAG_CUSTOM1 (1<<15) /**< Convenience macro for Admin_Custom1 as a FlagBit */
1.51 + #define ADMFLAG_CUSTOM2 (1<<16) /**< Convenience macro for Admin_Custom2 as a FlagBit */
1.52 + #define ADMFLAG_CUSTOM3 (1<<17) /**< Convenience macro for Admin_Custom3 as a FlagBit */
1.53 + #define ADMFLAG_CUSTOM4 (1<<18) /**< Convenience macro for Admin_Custom4 as a FlagBit */
1.54 + #define ADMFLAG_CUSTOM5 (1<<19) /**< Convenience macro for Admin_Custom5 as a FlagBit */
1.55 + #define ADMFLAG_CUSTOM6 (1<<20) /**< Convenience macro for Admin_Custom6 as a FlagBit */
1.56 +
1.57 /**
1.58 * @brief Specifies which type of command to override (command or command group).
1.59 */
1.60 @@ -148,6 +176,8 @@
1.61 virtual void OnRebuildAdminCache(int cache_flags) =0;
1.62 };
1.63
1.64 + typedef unsigned int FlagBits;
1.65 +
1.66 /**
1.67 * @brief Provides functions for manipulating the admin options cache.
1.68 */
1.69 @@ -169,19 +199,19 @@
1.70 *
1.71 * @param cmd String containing command name (case sensitive).
1.72 * @param type Override type (specific command or group).
1.73 - * @param flag New admin flag.
1.74 + * @param flags New admin flag.
1.75 */
1.76 - virtual void AddCommandOverride(const char *cmd, OverrideType type, AdminFlag flag) =0;
1.77 + virtual void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags) =0;
1.78
1.79 /**
1.80 * @brief Returns a command override.
1.81 *
1.82 * @param cmd String containing command name (case sensitive).
1.83 * @param type Override type (specific command or group).
1.84 - * @param pFlag Optional pointer to the set flag.
1.85 + * @param pFlags Optional pointer to the set flag.
1.86 * @return True if there is an override, false otherwise.
1.87 */
1.88 - virtual bool GetCommandOverride(const char *cmd, OverrideType type, AdminFlag *pFlag) =0;
1.89 + virtual bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags) =0;
1.90
1.91 /**
1.92 * @brief Unsets a command override.
1.93 @@ -231,11 +261,9 @@
1.94 * Note: These are called "add flags" because they add to a user's flags.
1.95 *
1.96 * @param id GroupId of the group.
1.97 - * @param flags Array to store flags bits in.
1.98 - * @param total Total number of flags that can be stored in the array.
1.99 - * @return Number of flags that were written to the array.
1.100 + * @return Bit string containing the bits of each flag.
1.101 */
1.102 - virtual unsigned int GetGroupAddFlagBits(GroupId id, bool flags[], unsigned int total) =0;
1.103 + virtual FlagBits GetGroupAddFlags(GroupId id) =0;
1.104
1.105 /**
1.106 * @brief Toggles a generic immunity type.
1.107 @@ -391,15 +419,10 @@
1.108 * @brief Returns a bitarray of flags enabled on an admin.
1.109 *
1.110 * @param id AdminId index of the admin.
1.111 - * @param flag Array to store flag bits in.
1.112 - * @param total Maximum size of the flag array.
1.113 * @param mode Access mode to use.
1.114 - * @return Number of flags written to the array.
1.115 + * @return A bit string containing which flags are enabled.
1.116 */
1.117 - virtual unsigned int GetAdminFlags(AdminId id,
1.118 - bool flags[],
1.119 - unsigned int total,
1.120 - AccessMode mode) =0;
1.121 + virtual FlagBits GetAdminFlags(AdminId id, AccessMode mode) =0;
1.122
1.123 /**
1.124 * @brief Adds a group to an admin's inherited group list.
1.125 @@ -463,6 +486,44 @@
1.126 * @return True on success, false otherwise.
1.127 */
1.128 virtual bool InvalidateAdmin(AdminId id) =0;
1.129 +
1.130 + /**
1.131 + * @brief Converts a flag bit string to a bit array.
1.132 + *
1.133 + * @param bits Bit string containing the flags.
1.134 + * @param array Array to write the flags to. Enabled flags will be 'true'.
1.135 + * @param maxSize Maximum number of flags the array can store.
1.136 + * @return Number of flags written.
1.137 + */
1.138 + virtual unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize) =0;
1.139 +
1.140 + /**
1.141 + * @brief Converts a flag array to a bit string.
1.142 + *
1.143 + * @param array Array containing true or false for each AdminFlag.
1.144 + * @param maxSize Maximum size of the flag array.
1.145 + * @return A bit string composed of the array bits.
1.146 + */
1.147 + virtual FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize) =0;
1.148 +
1.149 + /**
1.150 + * @brief Converts an array of flags to bits.
1.151 + *
1.152 + * @param array Array containing flags that are enabled.
1.153 + * @param numFlags Number of flags in the array.
1.154 + * @return A bit string composed of the array flags.
1.155 + */
1.156 + virtual FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags) =0;
1.157 +
1.158 + /**
1.159 + * @brief Converts a bit string to an array of flags.
1.160 + *
1.161 + * @param bits Bit string containing the flags.
1.162 + * @param array Output array to write flags.
1.163 + * @param maxSize Maximum size of the flag array.
1.164 + * @return Number of flags written.
1.165 + */
1.166 + virtual unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize) =0;
1.167 };
1.168 }
1.169