Base Votes import.
3 * ================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * ================================================================
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License,
10 * version 3.0, as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to
21 * link the code of this program (as well as its derivative works) to
22 * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
23 * Game MODs that run on software by the Valve Corporation. You must
24 * obey the GNU General Public License in all respects for all other
25 * code used. Additionally, AlliedModders LLC grants this exception
26 * to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version
28 * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
33 #ifndef _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
34 #define _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
36 #include <IShareSys.h>
37 #include <IHandleSys.h>
40 * @file IGameConfigs.h
41 * @brief Abstracts game private data configuration.
44 #define SMINTERFACE_GAMECONFIG_NAME "IGameConfigManager"
45 #define SMINTERFACE_GAMECONFIG_VERSION 3
52 * @brief Describes a game private data config file
58 * @brief Returns an offset value.
60 * @param key Key to retrieve from the offset section.
61 * @param value Pointer to store the offset value in.
62 * @return True if found, false otherwise.
64 virtual bool GetOffset(const char *key, int *value) =0;
67 * @brief Returns information about a dynamic offset.
69 * @param key Key to retrieve from the property section.
70 * @return A SendProp pointer, or NULL if not found.
72 virtual SendProp *GetSendProp(const char *key) =0;
75 * @brief Returns the value of a key from the "Keys" section.
77 * @param key Key to retrieve from the Keys section.
78 * @return String containing the value, or NULL if not found.
80 virtual const char *GetKeyValue(const char *key) =0;
83 * @brief Retrieves a cached memory signature.
85 * @param key Name of the signature.
86 * @param addr Pointer to store the memory address in.
87 * @return True if the key was found, false otherwise.
88 * Note that true is a valid return even if the
91 virtual bool GetMemSig(const char *key, void **addr) =0;
95 * @brief Manages game config files
97 class IGameConfigManager : public SMInterface
100 const char *GetInterfaceName()
102 return SMINTERFACE_GAMECONFIG_NAME;
104 unsigned int GetInterfaceVersion()
106 return SMINTERFACE_GAMECONFIG_VERSION;
110 * @brief Loads or finds an already loaded game config file.
112 * @param file File to load. The path must be relative to the
113 * 'gamedata' folder and the extension should be
115 * @param pConfig Pointer to store the game config pointer. Pointer
116 * will be valid even on failure.
117 * @param error Optional error message buffer.
118 * @param maxlength Maximum length of the error buffer.
119 * @return True on success, false if the file failed.
121 virtual bool LoadGameConfigFile(const char *file,
122 IGameConfig **pConfig,
124 size_t maxlength) =0;
127 * @brief Closes an IGameConfig pointer. Since a file can be loaded
128 * more than once, the file will not actually be removed from memory
129 * until it is closed once for each call to LoadGameConfigfile().
131 * @param cfg Pointer to the IGameConfig to close.
133 virtual void CloseGameConfigFile(IGameConfig *cfg) =0;
136 * @brief Reads an GameConfig Handle.
138 * @param hndl Handle to read.
139 * @param ident Identity of the owner (can be NULL).
140 * @param err Optional error buffer.
141 * @return IGameConfig pointer on success, NULL otherwise.
143 virtual IGameConfig *ReadHandle(Handle_t hndl,
144 IdentityToken_t *ident,
145 HandleError *err) =0;
149 #endif //_INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_