added handle reading to GameConfigManager

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40955
This commit is contained in:
David Anderson 2007-06-16 08:35:26 +00:00
parent 15a7be0e3e
commit c133002c14
3 changed files with 49 additions and 10 deletions

View File

@ -24,6 +24,7 @@
#include "ShareSys.h"
#include "MemoryUtils.h"
#include "LibrarySys.h"
#include "HandleSys.h"
#if defined PLATFORM_LINUX
#include <dlfcn.h>
@ -560,3 +561,19 @@ void GameConfigManager::CloseGameConfigFile(IGameConfig *cfg)
delete pConfig;
}
}
extern HandleType_t g_GameConfigsType;
IGameConfig *GameConfigManager::ReadHandle(Handle_t hndl, IdentityToken_t *ident, HandleError *err)
{
HandleSecurity sec(ident, g_pCoreIdent);
IGameConfig *conf = NULL;
HandleError _err = g_HandleSys.ReadHandle(hndl, g_GameConfigsType, &sec, (void **)&conf);
if (err)
{
*err = _err;
}
return conf;
}

View File

@ -76,6 +76,9 @@ public:
public: //IGameConfigManager
bool LoadGameConfigFile(const char *file, IGameConfig **pConfig, char *error, size_t maxlength);
void CloseGameConfigFile(IGameConfig *cfg);
IGameConfig *ReadHandle(Handle_t hndl,
IdentityToken_t *ident,
HandleError *err);
public: //SMGlobalClass
void OnSourceModStartup(bool late);
void OnSourceModAllInitialized();

View File

@ -20,6 +20,7 @@
#define _INCLUDE_SOURCEMOD_GAMECONFIG_SYSTEM_H_
#include <IShareSys.h>
#include <IHandleSys.h>
/**
* @file IGameConfigs.h
@ -27,7 +28,7 @@
*/
#define SMINTERFACE_GAMECONFIG_NAME "IGameConfigManager"
#define SMINTERFACE_GAMECONFIG_VERSION 2
#define SMINTERFACE_GAMECONFIG_VERSION 3
class SendProp;
@ -69,8 +70,9 @@ namespace SourceMod
*
* @param key Name of the signature.
* @param addr Pointer to store the memory address in.
* @return A MemorySignature pointer on success, or NULL
* if the key was not found.
* @return True if the key was found, false otherwise.
* Note that true is a valid return even if the
* address is NULL.
*/
virtual bool GetMemSig(const char *key, void **addr) =0;
};
@ -93,23 +95,40 @@ namespace SourceMod
/**
* @brief Loads or finds an already loaded game config file.
*
* @param file File to load. The path must be relative to the 'gamedata'
* folder under the config folder, and the extension should be omitted.
* @param pConfig Pointer to store the game config pointer. Pointer will be valid even on failure.
* @param file File to load. The path must be relative to the
* 'gamedata' folder and the extension should be
* omitted.
* @param pConfig Pointer to store the game config pointer. Pointer
* will be valid even on failure.
* @param error Optional error message buffer.
* @param maxlength Maximum length of the error buffer.
* @return True on success, false if the file failed.
*/
virtual bool LoadGameConfigFile(const char *file, IGameConfig **pConfig, char *error, size_t maxlength) =0;
virtual bool LoadGameConfigFile(const char *file,
IGameConfig **pConfig,
char *error,
size_t maxlength) =0;
/**
* @brief Closes an IGameConfig pointer. Since a file can be loaded more than once,
* the file will not actually be removed from memory until it is closed once for each
* call to LoadGameConfigfile().
* @brief Closes an IGameConfig pointer. Since a file can be loaded
* more than once, the file will not actually be removed from memory
* until it is closed once for each call to LoadGameConfigfile().
*
* @param cfg Pointer to the IGameConfig to close.
*/
virtual void CloseGameConfigFile(IGameConfig *cfg) =0;
/**
* @brief Reads an GameConfig Handle.
*
* @param hndl Handle to read.
* @param ident Identity of the owner (can be NULL).
* @param err Optional error buffer.
* @return IGameConfig pointer on success, NULL otherwise.
*/
virtual IGameConfig *ReadHandle(Handle_t hndl,
IdentityToken_t *ident,
HandleError *err) =0;
};
}