public/IGameConfigs.h
author Asher Baker <asherkin@gmail.com>
Thu Aug 01 14:31:03 2013 +0100 (2013-08-01)
changeset 3968 47745f9d30fd
parent 2901 f5a1cf24f505
child 4303 915476a973a5
permissions -rw-r--r--
Change wording for SteamAuthstringValidation config option to mark feature as experimental (bug 5791, r=psychonic).
dvander@547
     1
/**
ds@653
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1226
     4
 * SourceMod
ds@1947
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
ds@653
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
ds@653
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1226
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1226
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
ds@653
    28
 *
ds@653
    29
 * Version: $Id$
ds@653
    30
 */
dvander@547
    31
dvander@547
    32
#ifndef _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
dvander@547
    33
#define _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
dvander@547
    34
dvander@547
    35
#include <IShareSys.h>
dvander@949
    36
#include <IHandleSys.h>
pred@2217
    37
#include <ITextParsers.h>
dvander@547
    38
dvander@547
    39
/**
faluco@620
    40
 * @file IGameConfigs.h
dvander@547
    41
 * @brief Abstracts game private data configuration.
dvander@547
    42
 */
dvander@547
    43
dvander@547
    44
#define SMINTERFACE_GAMECONFIG_NAME			"IGameConfigManager"
downtown1@2901
    45
#define SMINTERFACE_GAMECONFIG_VERSION		6
dvander@547
    46
dvander@547
    47
class SendProp;
dvander@547
    48
dvander@547
    49
namespace SourceMod
dvander@547
    50
{
dvander@547
    51
	/**
dvander@547
    52
	 * @brief Describes a game private data config file
dvander@547
    53
	 */
dvander@547
    54
	class IGameConfig
dvander@547
    55
	{
dvander@547
    56
	public:
dvander@547
    57
		/**
dvander@547
    58
		 * @brief Returns an offset value.
dvander@547
    59
		 *
dvander@547
    60
		 * @param key			Key to retrieve from the offset section.
dvander@547
    61
		 * @param value			Pointer to store the offset value in.
dvander@547
    62
		 * @return				True if found, false otherwise.
dvander@547
    63
		 */
dvander@547
    64
		virtual bool GetOffset(const char *key, int *value) =0;
dvander@547
    65
dvander@547
    66
		/**
dvander@548
    67
		 * @brief Returns information about a dynamic offset.
dvander@547
    68
		 *
dvander@547
    69
		 * @param key			Key to retrieve from the property section.
faluco@703
    70
		 * @return				A SendProp pointer, or NULL if not found.
dvander@547
    71
		 */
dvander@547
    72
		virtual SendProp *GetSendProp(const char *key) =0;
dvander@548
    73
dvander@548
    74
		/**
dvander@548
    75
		 * @brief Returns the value of a key from the "Keys" section.
dvander@548
    76
		 *
dvander@548
    77
		 * @param key			Key to retrieve from the Keys section.
dvander@548
    78
		 * @return				String containing the value, or NULL if not found.
dvander@548
    79
		 */
dvander@548
    80
		virtual const char *GetKeyValue(const char *key) =0;
dvander@947
    81
dvander@947
    82
		/**
dvander@947
    83
		 * @brief Retrieves a cached memory signature.
dvander@947
    84
		 *
dvander@947
    85
		 * @param key			Name of the signature.
dvander@947
    86
		 * @param addr			Pointer to store the memory address in.
dvander@949
    87
		 * @return				True if the key was found, false otherwise.
dvander@949
    88
		 *						Note that true is a valid return even if the
dvander@949
    89
		 *						address is NULL.
dvander@947
    90
		 */
dvander@947
    91
		virtual bool GetMemSig(const char *key, void **addr) =0;
downtown1@2901
    92
downtown1@2901
    93
		/**
downtown1@2901
    94
		 * @brief Retrieves the value of an address from the "Address" section.
downtown1@2901
    95
		 *
downtown1@2901
    96
		 * @param key			Key to retrieve from the Address section.
downtown1@2901
    97
		 * @param addr          Pointer to store the memory address.
downtown1@2901
    98
		 * @return				True on success, false on failure.
downtown1@2901
    99
		 */
downtown1@2901
   100
		virtual bool GetAddress(const char *key, void **addr) =0;
dvander@547
   101
	};
dvander@547
   102
dvander@547
   103
	/**
dvander@547
   104
	 * @brief Manages game config files
dvander@547
   105
	 */
dvander@547
   106
	class IGameConfigManager : public SMInterface
dvander@547
   107
	{
dvander@547
   108
	public:
dvander@547
   109
		const char *GetInterfaceName()
dvander@547
   110
		{
dvander@547
   111
			return SMINTERFACE_GAMECONFIG_NAME;
dvander@547
   112
		}
dvander@547
   113
		unsigned int GetInterfaceVersion()
dvander@547
   114
		{
dvander@547
   115
			return SMINTERFACE_GAMECONFIG_VERSION;
dvander@547
   116
		}
dvander@547
   117
	public:
dvander@547
   118
		/**
dvander@547
   119
		 * @brief Loads or finds an already loaded game config file.  
dvander@547
   120
		 *
dvander@949
   121
		 * @param file		File to load.  The path must be relative to the 
dvander@949
   122
		 *					'gamedata' folder and the extension should be 
dvander@949
   123
		 *					omitted.
dvander@949
   124
		 * @param pConfig	Pointer to store the game config pointer.  Pointer 
dvander@949
   125
		 *					will be valid even on failure.
dvander@547
   126
		 * @param error		Optional error message buffer.
dvander@547
   127
		 * @param maxlength	Maximum length of the error buffer.
dvander@547
   128
		 * @return			True on success, false if the file failed.
dvander@547
   129
		 */
dvander@949
   130
		virtual bool LoadGameConfigFile(const char *file, 
dvander@949
   131
			IGameConfig **pConfig, 
dvander@949
   132
			char *error, 
dvander@949
   133
			size_t maxlength) =0;
dvander@547
   134
dvander@547
   135
		/**
dvander@949
   136
		 * @brief Closes an IGameConfig pointer.  Since a file can be loaded 
dvander@949
   137
		 * more than once, the file will not actually be removed from memory 
dvander@949
   138
		 * until it is closed once for each call to LoadGameConfigfile().
dvander@547
   139
		 *
dvander@547
   140
		 * @param cfg		Pointer to the IGameConfig to close.
dvander@547
   141
		 */
dvander@547
   142
		virtual void CloseGameConfigFile(IGameConfig *cfg) =0;
dvander@949
   143
dvander@949
   144
		/**
dvander@949
   145
		 * @brief Reads an GameConfig Handle.
dvander@949
   146
		 *
dvander@949
   147
		 * @param hndl		Handle to read.
dvander@949
   148
		 * @param ident		Identity of the owner (can be NULL).
dvander@949
   149
		 * @param err		Optional error buffer.
dvander@949
   150
		 * @return			IGameConfig pointer on success, NULL otherwise.
dvander@949
   151
		 */
dvander@949
   152
		virtual IGameConfig *ReadHandle(Handle_t hndl,
dvander@949
   153
			IdentityToken_t *ident,
pred@2217
   154
			HandleError *err) =0;
pred@2217
   155
pred@2217
   156
		/**
pred@2217
   157
		 * @brief Adds a custom gamedata section hook.
pred@2217
   158
		 *
pred@2217
   159
		 * @param sectionname	Section name to hook.
pred@2217
   160
		 * @param listener		Listener callback.
pred@2217
   161
		 * @noreturn
pred@2217
   162
		 */
pred@2217
   163
		virtual void AddUserConfigHook(const char *sectionname, ITextListener_SMC *listener) =0;
pred@2217
   164
pred@2217
   165
		/**
pred@2217
   166
		 * @brief Removes a custom gamedata section hook.
pred@2217
   167
		 *
pred@2217
   168
		 * @param sectionname	Section name to unhook.
pred@2217
   169
		 * @param listener		Listener callback.
pred@2217
   170
		 * @noreturn
pred@2217
   171
		 */
pred@2217
   172
		virtual void RemoveUserConfigHook(const char *sectionname, ITextListener_SMC *listener) =0;
dvander@2562
   173
dvander@2562
   174
		/**
dvander@2573
   175
		 * @brief Does nothing.
dvander@2562
   176
		 */
dvander@2562
   177
		virtual void AcquireLock() = 0;
dvander@2562
   178
dvander@2562
   179
		/**
dvander@2573
   180
		 * @brief Does nothing.
dvander@2562
   181
		 */
dvander@2562
   182
		virtual void ReleaseLock() = 0;
dvander@547
   183
	};
dvander@547
   184
}
dvander@547
   185
dvander@547
   186
#endif //_INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_