3 * ===============================================================
4 * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC.
6 * ===============================================================
8 * This file is part of the SourceMod/SourcePawn SDK. This file may only be
9 * used or modified under the Terms and Conditions of its License Agreement,
10 * which is found in public/licenses/LICENSE.txt. As of this notice, derivative
11 * works must be licensed under the GNU General Public License (version 2 or
12 * greater). A copy of the GPL is included under public/licenses/GPL.txt.
14 * To view the latest information, see: http://www.sourcemod.net/license.php
19 #ifndef _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
20 #define _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
22 #include <IShareSys.h>
23 #include <IHandleSys.h>
26 * @file IGameConfigs.h
27 * @brief Abstracts game private data configuration.
30 #define SMINTERFACE_GAMECONFIG_NAME "IGameConfigManager"
31 #define SMINTERFACE_GAMECONFIG_VERSION 3
38 * @brief Describes a game private data config file
44 * @brief Returns an offset value.
46 * @param key Key to retrieve from the offset section.
47 * @param value Pointer to store the offset value in.
48 * @return True if found, false otherwise.
50 virtual bool GetOffset(const char *key, int *value) =0;
53 * @brief Returns information about a dynamic offset.
55 * @param key Key to retrieve from the property section.
56 * @return A SendProp pointer, or NULL if not found.
58 virtual SendProp *GetSendProp(const char *key) =0;
61 * @brief Returns the value of a key from the "Keys" section.
63 * @param key Key to retrieve from the Keys section.
64 * @return String containing the value, or NULL if not found.
66 virtual const char *GetKeyValue(const char *key) =0;
69 * @brief Retrieves a cached memory signature.
71 * @param key Name of the signature.
72 * @param addr Pointer to store the memory address in.
73 * @return True if the key was found, false otherwise.
74 * Note that true is a valid return even if the
77 virtual bool GetMemSig(const char *key, void **addr) =0;
81 * @brief Manages game config files
83 class IGameConfigManager : public SMInterface
86 const char *GetInterfaceName()
88 return SMINTERFACE_GAMECONFIG_NAME;
90 unsigned int GetInterfaceVersion()
92 return SMINTERFACE_GAMECONFIG_VERSION;
96 * @brief Loads or finds an already loaded game config file.
98 * @param file File to load. The path must be relative to the
99 * 'gamedata' folder and the extension should be
101 * @param pConfig Pointer to store the game config pointer. Pointer
102 * will be valid even on failure.
103 * @param error Optional error message buffer.
104 * @param maxlength Maximum length of the error buffer.
105 * @return True on success, false if the file failed.
107 virtual bool LoadGameConfigFile(const char *file,
108 IGameConfig **pConfig,
110 size_t maxlength) =0;
113 * @brief Closes an IGameConfig pointer. Since a file can be loaded
114 * more than once, the file will not actually be removed from memory
115 * until it is closed once for each call to LoadGameConfigfile().
117 * @param cfg Pointer to the IGameConfig to close.
119 virtual void CloseGameConfigFile(IGameConfig *cfg) =0;
122 * @brief Reads an GameConfig Handle.
124 * @param hndl Handle to read.
125 * @param ident Identity of the owner (can be NULL).
126 * @param err Optional error buffer.
127 * @return IGameConfig pointer on success, NULL otherwise.
129 virtual IGameConfig *ReadHandle(Handle_t hndl,
130 IdentityToken_t *ident,
131 HandleError *err) =0;
135 #endif //_INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_