Update CS:GO team score gamedata.
2 * vim: set ts=4 sw=4 tw=99 noet :
3 * =============================================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_ADMINCACHE_H_
33 #define _INCLUDE_SOURCEMOD_ADMINCACHE_H_
35 #include "sm_memtable.h"
38 #include <sh_string.h>
39 #include <IAdminSystem.h>
40 #include "sm_globals.h"
41 #include <IForwardSys.h>
42 #include <sm_stringhashmap.h>
43 #include <sm_namehashset.h>
45 using namespace SourceHook;
47 #define GRP_MAGIC_SET 0xDEADFADE
48 #define GRP_MAGIC_UNSET 0xFACEFACE
49 #define USR_MAGIC_SET 0xDEADFACE
50 #define USR_MAGIC_UNSET 0xFADEDEAD
52 typedef StringHashMap<OverrideRule> OverrideMap;
56 uint32_t magic; /* Magic flag, for memory validation (ugh) */
57 unsigned int immunity_level; /* Immunity level */
58 /* Immune from target table (-1 = nonexistent)
59 * [0] = number of entries
60 * [1...N] = immune targets
63 OverrideMap *pCmdTable; /* Command override table (can be NULL) */
64 OverrideMap *pCmdGrpTable; /* Command group override table (can be NULL) */
65 int next_grp; /* Next group in the chain */
66 int prev_grp; /* Previous group in the chain */
67 int nameidx; /* Name */
68 FlagBits addflags; /* Additive flags */
74 StringHashMap<AdminId> identities;
76 AuthMethod(const char *name)
81 static inline bool matches(const char *name, const AuthMethod *method)
83 return strcmp(name, method->name.c_str()) == 0;
89 unsigned int index; /* Index into auth table */
90 int identidx; /* Index into the string table */
95 uint32_t magic; /* Magic flag, for memory validation */
96 FlagBits flags; /* Flags */
97 FlagBits eflags; /* Effective flags */
98 int nameidx; /* Name index */
99 int password; /* Password index */
100 unsigned int grp_count; /* Number of groups */
101 unsigned int grp_size; /* Size of groups table */
102 int grp_table; /* Group table itself */
103 int next_user; /* Next user in the list */
104 int prev_user; /* Previous user in the list */
105 UserAuth auth; /* Auth method for this user */
106 unsigned int immunity_level; /* Immunity level */
107 unsigned int serialchange; /* Serial # for changes */
117 public: //SMGlobalClass
118 void OnSourceModStartup(bool late);
119 void OnSourceModAllInitialized();
120 void OnSourceModLevelChange(const char *mapName);
121 void OnSourceModShutdown();
122 void OnSourceModPluginsLoaded();
123 public: //IAdminSystem
124 /** Command cache stuff */
125 void AddCommandOverride(const char *cmd, OverrideType type, FlagBits flags);
126 bool GetCommandOverride(const char *cmd, OverrideType type, FlagBits *flags);
127 void UnsetCommandOverride(const char *cmd, OverrideType type);
128 /** Group cache stuff */
129 GroupId AddGroup(const char *group_name);
130 GroupId FindGroupByName(const char *group_name);
131 void SetGroupAddFlag(GroupId id, AdminFlag flag, bool enabled);
132 bool GetGroupAddFlag(GroupId id, AdminFlag flag);
133 FlagBits GetGroupAddFlags(GroupId id);
134 void SetGroupGenericImmunity(GroupId id, ImmunityType type, bool enabled);
135 bool GetGroupGenericImmunity(GroupId id, ImmunityType type);
136 void InvalidateGroup(GroupId id);
137 void AddGroupImmunity(GroupId id, GroupId other_id);
138 unsigned int GetGroupImmunityCount(GroupId id);
139 GroupId GetGroupImmunity(GroupId id, unsigned int number);
140 void AddGroupCommandOverride(GroupId id, const char *name, OverrideType type, OverrideRule rule);
141 bool GetGroupCommandOverride(GroupId id, const char *name, OverrideType type, OverrideRule *pRule);
142 void DumpAdminCache(AdminCachePart part, bool rebuild);
143 void AddAdminListener(IAdminListener *pListener);
144 void RemoveAdminListener(IAdminListener *pListener);
146 void RegisterAuthIdentType(const char *name);
147 AdminId CreateAdmin(const char *name);
148 const char *GetAdminName(AdminId id);
149 bool BindAdminIdentity(AdminId id, const char *auth, const char *ident);
150 virtual void SetAdminFlag(AdminId id, AdminFlag flag, bool enabled);
151 bool GetAdminFlag(AdminId id, AdminFlag flag, AccessMode mode);
152 FlagBits GetAdminFlags(AdminId id, AccessMode mode);
153 bool AdminInheritGroup(AdminId id, GroupId gid);
154 unsigned int GetAdminGroupCount(AdminId id);
155 GroupId GetAdminGroup(AdminId id, unsigned int index, const char **name);
156 void SetAdminPassword(AdminId id, const char *password);
157 const char *GetAdminPassword(AdminId id);
158 AdminId FindAdminByIdentity(const char *auth, const char *identity);
159 bool InvalidateAdmin(AdminId id);
160 unsigned int FlagBitsToBitArray(FlagBits bits, bool array[], unsigned int maxSize);
161 FlagBits FlagBitArrayToBits(const bool array[], unsigned int maxSize);
162 FlagBits FlagArrayToBits(const AdminFlag array[], unsigned int numFlags);
163 unsigned int FlagBitsToArray(FlagBits bits, AdminFlag array[], unsigned int maxSize);
164 bool CheckAdminFlags(AdminId id, FlagBits bits);
165 bool CanAdminTarget(AdminId id, AdminId target);
166 void SetAdminFlags(AdminId id, AccessMode mode, FlagBits bits);
167 bool FindFlag(const char *str, AdminFlag *pFlag);
168 bool FindFlag(char c, AdminFlag *pAdmFlag);
169 FlagBits ReadFlagString(const char *flags, const char **end);
170 size_t FillFlagString(FlagBits bits, char *buffer, size_t maxlen);
171 unsigned int GetAdminSerialChange(AdminId id);
172 bool CanAdminUseCommand(int client, const char *cmd);
173 const char *GetGroupName(GroupId gid);
174 unsigned int SetGroupImmunityLevel(GroupId gid, unsigned int level);
175 unsigned int GetGroupImmunityLevel(GroupId gid);
176 unsigned int SetAdminImmunityLevel(AdminId id, unsigned int level);
177 unsigned int GetAdminImmunityLevel(AdminId id);
178 bool CheckAccess(int client,
182 bool FindFlagChar(AdminFlag flag, char *c);
184 bool IsValidAdmin(AdminId id);
185 void DumpCache(FILE *fp);
186 AdminGroup *GetGroup(GroupId gid);
187 AdminUser *GetUser(AdminId id);
188 const char *GetString(int idx);
190 void _UnsetCommandOverride(const char *cmd);
191 void _UnsetCommandGroupOverride(const char *group);
192 void InvalidateGroupCache();
193 void InvalidateAdminCache(bool unlink_admins);
194 void DumpCommandOverrideCache(OverrideType type);
195 AuthMethod *GetMethodByIndex(unsigned int index);
196 bool GetMethodIndex(const char *name, unsigned int *_index);
197 const char *GetMethodName(unsigned int index);
198 void NameFlag(const char *str, AdminFlag flag);
200 typedef StringHashMap<FlagBits> FlagMap;
202 BaseStringTable *m_pStrings;
203 BaseMemTable *m_pMemory;
204 FlagMap m_CmdOverrides;
205 FlagMap m_CmdGrpOverrides;
209 StringHashMap<GroupId> m_Groups;
210 List<IAdminListener *> m_hooks;
211 List<AuthMethod *> m_AuthMethods;
212 NameHashSet<AuthMethod *> m_AuthTables;
213 IForward *m_pCacheFwd;
217 bool m_InvalidatingAdmins;
219 StringHashMap<AdminFlag> m_LevelNames;
222 extern AdminCache g_Admins;
224 #endif //_INCLUDE_SOURCEMOD_ADMINCACHE_H_