core/HalfLife2.h
author David Anderson <dvander@alliedmods.net>
Sun Jun 17 04:04:17 2007 +0000 (2007-06-17)
changeset 965 327edbb1357a
parent 895 a1068846fee8
child 1132 e8d4e82e9541
permissions -rw-r--r--
finally exposed IGameHelpers interface
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  * This file is not open source and may not be copied without explicit
     8  * written permission of AlliedModders LLC.  This file may not be redistributed 
     9  * in whole or significant part.
    10  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #ifndef _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
    16 #define _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
    17 
    18 #include <sh_list.h>
    19 #include <sh_tinyhash.h>
    20 #include "sm_trie.h"
    21 #include "sm_globals.h"
    22 #include <IGameHelpers.h>
    23 
    24 using namespace SourceHook;
    25 using namespace SourceMod;
    26 
    27 #define HUD_PRINTTALK		3
    28 #define HUD_PRINTCENTER		4
    29 
    30 struct DataTableInfo
    31 {
    32 	ServerClass *sc;
    33 	Trie *lookup;
    34 };
    35 
    36 struct DataMapTrie
    37 {
    38 	DataMapTrie() : trie(NULL) {}
    39 	Trie *trie;
    40 };
    41 
    42 class CHalfLife2 : 
    43 	public SMGlobalClass,
    44 	public IGameHelpers
    45 {
    46 public:
    47 	CHalfLife2();
    48 	~CHalfLife2();
    49 public:
    50 	void OnSourceModStartup(bool late);
    51 	void OnSourceModAllInitialized();
    52 	/*void OnSourceModAllShutdown();*/
    53 public: //IGameHelpers
    54 	SendProp *FindInSendTable(const char *classname, const char *offset);
    55 	datamap_t *GetDataMap(CBaseEntity *pEntity);
    56 	ServerClass *FindServerClass(const char *classname);
    57 	typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
    58 	void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
    59 	void TextMsg(int client, int dest, const char *msg);
    60 private:
    61 	DataTableInfo *_FindServerClass(const char *classname);
    62 private:
    63 	Trie *m_pClasses;
    64 	List<DataTableInfo *> m_Tables;
    65 	THash<datamap_t *, DataMapTrie> m_Maps;
    66 	int m_MsgTextMsg;
    67 };
    68 
    69 extern CHalfLife2 g_HL2;
    70 extern bool g_IsOriginalEngine;
    71 
    72 #endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_