1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core/AdminCache.h Wed Jan 24 21:51:49 2007 +0000
1.3 @@ -0,0 +1,80 @@
1.4 +#ifndef _INCLUDE_SOURCEMOD_ADMINCACHE_H_
1.5 +#define _INCLUDE_SOURCEMOD_ADMINCACHE_H_
1.6 +
1.7 +#include "sm_memtable.h"
1.8 +#include <sm_trie.h>
1.9 +#include <IAdminSystem.h>
1.10 +#include "sm_globals.h"
1.11 +
1.12 +#define GRP_MAGIC_SET 0xDEADFADE
1.13 +#define GRP_MAGIC_UNSET 0xFACEFACE
1.14 +
1.15 +struct AdminGroup
1.16 +{
1.17 + uint32_t magic; /* Magic flag, for memory validation (ugh) */
1.18 + bool immune_global; /* Global immunity? */
1.19 + bool immune_default; /* Default immunity? */
1.20 + /* Immune from target table (-1 = nonexistant)
1.21 + * [0] = number of entries
1.22 + * [1...N] = immune targets
1.23 + */
1.24 + int immune_table;
1.25 + Trie *pCmdTable; /* Command override table (can be NULL) */
1.26 + Trie *pCmdGrpTable; /* Command group override table (can be NULL) */
1.27 + int next_grp; /* Next group in the chain */
1.28 + int prev_grp; /* Previous group in the chain */
1.29 + int nameidx; /* Name */
1.30 + bool addflags[AdminFlags_TOTAL]; /* Additive flags */
1.31 +};
1.32 +
1.33 +class AdminCache :
1.34 + public IAdminSystem,
1.35 + public SMGlobalClass
1.36 +{
1.37 +public:
1.38 + AdminCache();
1.39 + ~AdminCache();
1.40 +public: //SMGlobalClass
1.41 + void OnSourceModAllInitialized();
1.42 +public: //IAdminSystem
1.43 + /** Command cache stuff */
1.44 + void AddCommandOverride(const char *cmd, OverrideType type, AdminFlag flag);
1.45 + bool GetCommandOverride(const char *cmd, OverrideType type, AdminFlag *pFlag);
1.46 + void UnsetCommandOverride(const char *cmd, OverrideType type);
1.47 + void DumpCommandOverrideCache(OverrideType type);
1.48 + /** Group cache stuff */
1.49 + GroupId AddGroup(const char *group_name);
1.50 + GroupId FindGroupByName(const char *group_name);
1.51 + void SetGroupAddFlag(GroupId id, AdminFlag flag, bool enabled);
1.52 + bool GetGroupAddFlag(GroupId id, AdminFlag flag);
1.53 + unsigned int GetGroupAddFlags(GroupId Id, AdminFlag flags[], unsigned int total);
1.54 + void SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled);
1.55 + bool GetGroupGenericImmunity(GroupId id, ImmunityType type);
1.56 + void InvalidateGroup(GroupId id);
1.57 + void InvalidateGroupCache();
1.58 + void AddGroupImmunity(GroupId id, GroupId other_id);
1.59 + unsigned int GetGroupImmunityCount(GroupId id);
1.60 + GroupId GetGroupImmunity(GroupId id, unsigned int number);
1.61 + void AddGroupCommandOverride(GroupId id, const char *name, OverrideType type, OverrideRule rule);
1.62 + bool GetGroupCommandOverride(GroupId id, const char *name, OverrideType type, OverrideRule *pRule);
1.63 +private:
1.64 + void _AddCommandOverride(const char *cmd, AdminFlag flag);
1.65 + void _AddCommandGroupOverride(const char *group, AdminFlag flag);
1.66 + bool _GetCommandOverride(const char *cmd, AdminFlag *pFlag);
1.67 + bool _GetCommandGroupOverride(const char *group, AdminFlag *pFlag);
1.68 + void _UnsetCommandOverride(const char *cmd);
1.69 + void _UnsetCommandGroupOverride(const char *group);
1.70 +public:
1.71 + BaseStringTable *m_pStrings;
1.72 + BaseMemTable *m_pMemory;
1.73 + Trie *m_pCmdOverrides;
1.74 + Trie *m_pCmdGrpOverrides;
1.75 + int m_FirstGroup;
1.76 + int m_LastGroup;
1.77 + int m_FreeGroupList;
1.78 + Trie *m_pGroups;
1.79 +};
1.80 +
1.81 +extern AdminCache g_Admins;
1.82 +
1.83 +#endif //_INCLUDE_SOURCEMOD_ADMINCACHE_H_