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>
26 * @brief Abstracts game private data configuration.
29 #define SMINTERFACE_GAMECONFIG_NAME "IGameConfigManager"
30 #define SMINTERFACE_GAMECONFIG_VERSION 1
37 * @brief Details the property types.
41 PropType_Unknown = 0, /**< Property type is not known */
42 PropType_Send = 1, /**< Property type is a networkable property */
43 PropType_Data = 2, /**< Property type is a data/save property */
48 PropError_Okay = 0, /**< No error */
49 PropError_NotSet, /**< Property is not set in the config file */
50 PropError_NotFound, /**< Property was not found in the game */
53 #define INVALID_PROPERTY_VALUE -1 /**< Property value is not valid */
56 * @brief Describes a game private data config file
62 * @brief Returns an offset value.
64 * @param key Key to retrieve from the offset section.
65 * @param value Pointer to store the offset value in.
66 * @return True if found, false otherwise.
68 virtual bool GetOffset(const char *key, int *value) =0;
71 * @brief Returns information about a dynamic offset.
73 * @param key Key to retrieve from the property section.
74 * @param value Pointer to store the offset value. Will be -1 on failure.
75 * @return A PropError error code.
77 virtual SendProp *GetSendProp(const char *key) =0;
80 * @brief Returns the value of a key from the "Keys" section.
82 * @param key Key to retrieve from the Keys section.
83 * @return String containing the value, or NULL if not found.
85 virtual const char *GetKeyValue(const char *key) =0;
89 * @brief Manages game config files
91 class IGameConfigManager : public SMInterface
94 const char *GetInterfaceName()
96 return SMINTERFACE_GAMECONFIG_NAME;
98 unsigned int GetInterfaceVersion()
100 return SMINTERFACE_GAMECONFIG_VERSION;
104 * @brief Loads or finds an already loaded game config file.
106 * @param file File to load. The path must be relative to the 'gamedata'
107 * folder under the config folder, and the extension should be ommitted.
108 * @param pConfig Pointer to store the game config pointer. Pointer will be valid even on failure.
109 * @param error Optional error message buffer.
110 * @param maxlength Maximum length of the error buffer.
111 * @return True on success, false if the file failed.
113 virtual bool LoadGameConfigFile(const char *file, IGameConfig **pConfig, char *error, size_t maxlength) =0;
116 * @brief Closes an IGameConfig pointer. Since a file can be loaded more than once,
117 * the file will not actually be removed from memory until it is closed once for each
118 * call to LoadGameConfigfile().
120 * @param cfg Pointer to the IGameConfig to close.
122 virtual void CloseGameConfigFile(IGameConfig *cfg) =0;
126 #endif //_INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_