dvander@547: /** ds@653: * vim: set ts=4 : ds@653: * =============================================================== ds@653: * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC. ds@653: * All rights reserved. ds@653: * =============================================================== ds@653: * ds@653: * This file is part of the SourceMod/SourcePawn SDK. This file may only be ds@653: * used or modified under the Terms and Conditions of its License Agreement, ds@653: * which is found in public/licenses/LICENSE.txt. As of this notice, derivative ds@653: * works must be licensed under the GNU General Public License (version 2 or ds@653: * greater). A copy of the GPL is included under public/licenses/GPL.txt. ds@653: * ds@653: * To view the latest information, see: http://www.sourcemod.net/license.php ds@653: * ds@653: * Version: $Id$ ds@653: */ dvander@547: dvander@547: #ifndef _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_ dvander@547: #define _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_ dvander@547: dvander@547: #include dvander@547: dvander@547: /** faluco@620: * @file IGameConfigs.h dvander@547: * @brief Abstracts game private data configuration. dvander@547: */ dvander@547: dvander@547: #define SMINTERFACE_GAMECONFIG_NAME "IGameConfigManager" dvander@547: #define SMINTERFACE_GAMECONFIG_VERSION 1 dvander@547: dvander@547: class SendProp; dvander@547: dvander@547: namespace SourceMod dvander@547: { dvander@547: /** dvander@547: * @brief Describes a game private data config file dvander@547: */ dvander@547: class IGameConfig dvander@547: { dvander@547: public: dvander@547: /** dvander@547: * @brief Returns an offset value. dvander@547: * dvander@547: * @param key Key to retrieve from the offset section. dvander@547: * @param value Pointer to store the offset value in. dvander@547: * @return True if found, false otherwise. dvander@547: */ dvander@547: virtual bool GetOffset(const char *key, int *value) =0; dvander@547: dvander@547: /** dvander@548: * @brief Returns information about a dynamic offset. dvander@547: * dvander@547: * @param key Key to retrieve from the property section. faluco@703: * @return A SendProp pointer, or NULL if not found. dvander@547: */ dvander@547: virtual SendProp *GetSendProp(const char *key) =0; dvander@548: dvander@548: /** dvander@548: * @brief Returns the value of a key from the "Keys" section. dvander@548: * dvander@548: * @param key Key to retrieve from the Keys section. dvander@548: * @return String containing the value, or NULL if not found. dvander@548: */ dvander@548: virtual const char *GetKeyValue(const char *key) =0; dvander@547: }; dvander@547: dvander@547: /** dvander@547: * @brief Manages game config files dvander@547: */ dvander@547: class IGameConfigManager : public SMInterface dvander@547: { dvander@547: public: dvander@547: const char *GetInterfaceName() dvander@547: { dvander@547: return SMINTERFACE_GAMECONFIG_NAME; dvander@547: } dvander@547: unsigned int GetInterfaceVersion() dvander@547: { dvander@547: return SMINTERFACE_GAMECONFIG_VERSION; dvander@547: } dvander@547: public: dvander@547: /** dvander@547: * @brief Loads or finds an already loaded game config file. dvander@547: * dvander@547: * @param file File to load. The path must be relative to the 'gamedata' faluco@703: * folder under the config folder, and the extension should be omitted. dvander@547: * @param pConfig Pointer to store the game config pointer. Pointer will be valid even on failure. dvander@547: * @param error Optional error message buffer. dvander@547: * @param maxlength Maximum length of the error buffer. dvander@547: * @return True on success, false if the file failed. dvander@547: */ dvander@547: virtual bool LoadGameConfigFile(const char *file, IGameConfig **pConfig, char *error, size_t maxlength) =0; dvander@547: dvander@547: /** dvander@547: * @brief Closes an IGameConfig pointer. Since a file can be loaded more than once, dvander@547: * the file will not actually be removed from memory until it is closed once for each dvander@547: * call to LoadGameConfigfile(). dvander@547: * dvander@547: * @param cfg Pointer to the IGameConfig to close. dvander@547: */ dvander@547: virtual void CloseGameConfigFile(IGameConfig *cfg) =0; dvander@547: }; dvander@547: } dvander@547: dvander@547: #endif //_INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_