core/GameConfigs.h
changeset 592 c2a2c38f1331
child 616 d5b1dcf38c07
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/GameConfigs.h	Sat Mar 10 21:26:04 2007 +0000
     1.3 @@ -0,0 +1,88 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * ===============================================================
     1.7 + * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 + * ===============================================================
     1.9 + *
    1.10 + * This file is not open source and may not be copied without explicit
    1.11 + * written permission of AlliedModders LLC.  This file may not be redistributed 
    1.12 + * in whole or significant part.
    1.13 + * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    1.14 + *
    1.15 + * Version: $Id$
    1.16 + */
    1.17 +
    1.18 +#ifndef _INCLUDE_SOURCEMOD_CGAMECONFIGS_H_
    1.19 +#define _INCLUDE_SOURCEMOD_CGAMECONFIGS_H_
    1.20 +
    1.21 +#include <IGameConfigs.h>
    1.22 +#include <ITextParsers.h>
    1.23 +#include <sh_list.h>
    1.24 +#include "sm_trie.h"
    1.25 +#include "sm_globals.h"
    1.26 +#include "sm_memtable.h"
    1.27 +
    1.28 +using namespace SourceMod;
    1.29 +using namespace SourceHook;
    1.30 +
    1.31 +class SendProp;
    1.32 +
    1.33 +class CGameConfig : 
    1.34 +	public ITextListener_SMC,
    1.35 +	public IGameConfig
    1.36 +{
    1.37 +public:
    1.38 +	CGameConfig(const char *file);
    1.39 +	~CGameConfig();
    1.40 +public:
    1.41 +	bool Reparse(char *error, size_t maxlength);
    1.42 +public: //ITextListener_SMC
    1.43 +	SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
    1.44 +	SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
    1.45 +	SMCParseResult ReadSMC_LeavingSection();
    1.46 +public: //IGameConfig
    1.47 +	const char *GetKeyValue(const char *key);
    1.48 +	bool GetOffset(const char *key, int *value);
    1.49 +	SendProp *GetSendProp(const char *key);
    1.50 +public:
    1.51 +	void IncRefCount();
    1.52 +	unsigned int DecRefCount();
    1.53 +private:
    1.54 +	BaseStringTable *m_pStrings;
    1.55 +	char *m_pFile;
    1.56 +	Trie *m_pOffsets;
    1.57 +	Trie *m_pProps;
    1.58 +	Trie *m_pKeys;
    1.59 +	unsigned int m_RefCount;
    1.60 +	/* Parse states */
    1.61 +	int m_ParseState;
    1.62 +	unsigned int m_IgnoreLevel;
    1.63 +	char m_class[64];
    1.64 +	char m_prop[64];
    1.65 +	char m_offset[64];
    1.66 +	char m_mod[255];
    1.67 +};
    1.68 +
    1.69 +class CGameConfigManager : 
    1.70 +	public IGameConfigManager,
    1.71 +	public SMGlobalClass
    1.72 +{
    1.73 +public:
    1.74 +	CGameConfigManager();
    1.75 +	~CGameConfigManager();
    1.76 +public: //IGameConfigManager
    1.77 +	bool LoadGameConfigFile(const char *file, IGameConfig **pConfig, char *error, size_t maxlength);
    1.78 +	void CloseGameConfigFile(IGameConfig *cfg);
    1.79 +public: //SMGlobalClass
    1.80 +	void OnSourceModStartup(bool late);
    1.81 +	void OnSourceModAllInitialized();
    1.82 +	void OnSourceModAllShutdown();
    1.83 +private:
    1.84 +	List<CGameConfig *> m_cfgs;
    1.85 +	Trie *m_pLookup;
    1.86 +};
    1.87 +
    1.88 +extern CGameConfigManager g_GameConfigs;
    1.89 +extern IGameConfig *g_pGameConf;
    1.90 +
    1.91 +#endif //_INCLUDE_SOURCEMOD_CGAMECONFIGS_H_