core/HalfLife2.h
author David Anderson <dvander@alliedmods.net>
Tue Dec 04 15:58:07 2007 +0000 (2007-12-04)
changeset 1764 e4f24e9789fd
parent 1581 2562512b4a44
child 1847 5336a438763f
permissions -rw-r--r--
- removed ancient bcompat shim for translations/core.cfg file
- fixed msvc8 whining about BfReadString
dvander@592
     1
/**
dvander@592
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
dvander@1231
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
dvander@592
     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.
dvander@1231
    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@1231
    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@1231
    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>.
dvander@592
    28
 *
dvander@592
    29
 * Version: $Id$
dvander@592
    30
 */
dvander@592
    31
dvander@592
    32
#ifndef _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
dvander@592
    33
#define _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
dvander@592
    34
dvander@592
    35
#include <sh_list.h>
dvander@1338
    36
#include <sh_string.h>
faluco@682
    37
#include <sh_tinyhash.h>
dvander@592
    38
#include "sm_trie.h"
dvander@592
    39
#include "sm_globals.h"
dvander@1338
    40
#include "sm_queue.h"
dvander@965
    41
#include <IGameHelpers.h>
faluco@1218
    42
#include <KeyValues.h>
dvander@592
    43
dvander@1544
    44
class CCommand;
dvander@1544
    45
dvander@592
    46
using namespace SourceHook;
dvander@965
    47
using namespace SourceMod;
dvander@592
    48
dvander@895
    49
#define HUD_PRINTTALK		3
dvander@895
    50
#define HUD_PRINTCENTER		4
dvander@895
    51
dvander@592
    52
struct DataTableInfo
dvander@592
    53
{
dvander@592
    54
	ServerClass *sc;
dvander@592
    55
	Trie *lookup;
dvander@592
    56
};
dvander@592
    57
faluco@682
    58
struct DataMapTrie
faluco@682
    59
{
faluco@682
    60
	DataMapTrie() : trie(NULL) {}
faluco@682
    61
	Trie *trie;
faluco@682
    62
};
faluco@682
    63
dvander@1338
    64
struct DelayedFakeCliCmd
dvander@1338
    65
{
dvander@1338
    66
	String cmd;
dvander@1338
    67
	int client;
dvander@1338
    68
	int userid;
dvander@1338
    69
};
dvander@1338
    70
dvander@1544
    71
struct CachedCommandInfo
dvander@1544
    72
{
dvander@1544
    73
	const CCommand *args;
dvander@1544
    74
#if !defined ORANGEBOX_BUILD
dvander@1544
    75
	char cmd[300];
dvander@1544
    76
#endif
dvander@1544
    77
};
dvander@1544
    78
dvander@965
    79
class CHalfLife2 : 
dvander@965
    80
	public SMGlobalClass,
dvander@965
    81
	public IGameHelpers
dvander@592
    82
{
dvander@592
    83
public:
dvander@592
    84
	CHalfLife2();
dvander@592
    85
	~CHalfLife2();
dvander@592
    86
public:
dvander@677
    87
	void OnSourceModStartup(bool late);
ds@873
    88
	void OnSourceModAllInitialized();
dvander@677
    89
	/*void OnSourceModAllShutdown();*/
dvander@965
    90
public: //IGameHelpers
dvander@592
    91
	SendProp *FindInSendTable(const char *classname, const char *offset);
dvander@965
    92
	datamap_t *GetDataMap(CBaseEntity *pEntity);
dvander@592
    93
	ServerClass *FindServerClass(const char *classname);
faluco@682
    94
	typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
dvander@685
    95
	void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
dvander@1132
    96
	bool TextMsg(int client, int dest, const char *msg);
teame06@1264
    97
	bool HintTextMsg(int client, const char *msg);
faluco@1218
    98
	bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
dvander@1423
    99
	bool IsLANServer();
dvander@1338
   100
public:
dvander@1338
   101
	void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
dvander@1338
   102
	void ProcessFakeCliCmdQueue();
dvander@1544
   103
public:
dvander@1544
   104
	void PushCommandStack(const CCommand *cmd);
dvander@1544
   105
	void PopCommandStack();
dvander@1544
   106
	const CCommand *PeekCommandStack();
dvander@1544
   107
	const char *CurrentCommandName();
dvander@1581
   108
#if !defined METAMOD_PLAPI_VERSION
dvander@1581
   109
	bool IsOriginalEngine();
dvander@1581
   110
#endif
dvander@592
   111
private:
dvander@592
   112
	DataTableInfo *_FindServerClass(const char *classname);
dvander@592
   113
private:
dvander@592
   114
	Trie *m_pClasses;
dvander@592
   115
	List<DataTableInfo *> m_Tables;
faluco@682
   116
	THash<datamap_t *, DataMapTrie> m_Maps;
ds@873
   117
	int m_MsgTextMsg;
faluco@1218
   118
	int m_HinTextMsg;
faluco@1218
   119
	int m_VGUIMenu;
dvander@1338
   120
	Queue<DelayedFakeCliCmd *> m_CmdQueue;
dvander@1338
   121
	CStack<DelayedFakeCliCmd *> m_FreeCmds;
dvander@1544
   122
	CStack<CachedCommandInfo> m_CommandStack;
dvander@592
   123
};
dvander@592
   124
dvander@592
   125
extern CHalfLife2 g_HL2;
dvander@592
   126
dvander@592
   127
#endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_