core/HalfLife2.h
author Scott Ehlert <ds@alliedmods.net>
Fri Feb 27 00:22:59 2009 -0600 (2009-02-27)
changeset 2626 323b0dc87096
parent 2289 44045ead61cd
child 2400 76b7b4575e21
permissions -rw-r--r--
Added -dev tag back to version.h files for manual builds.
dvander@592
     1
/**
dvander@592
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
ds@1947
     5
 * Copyright (C) 2004-2008 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@1847
    38
#include <sm_trie_tpl.h>
dvander@592
    39
#include "sm_trie.h"
dvander@592
    40
#include "sm_globals.h"
dvander@1338
    41
#include "sm_queue.h"
dvander@965
    42
#include <IGameHelpers.h>
faluco@1218
    43
#include <KeyValues.h>
ds@2051
    44
#include <server_class.h>
ds@2051
    45
#include <datamap.h>
dvander@592
    46
dvander@1544
    47
class CCommand;
dvander@1544
    48
dvander@592
    49
using namespace SourceHook;
dvander@965
    50
using namespace SourceMod;
dvander@592
    51
dvander@895
    52
#define HUD_PRINTTALK		3
dvander@895
    53
#define HUD_PRINTCENTER		4
dvander@895
    54
dvander@592
    55
struct DataTableInfo
dvander@592
    56
{
dvander@592
    57
	ServerClass *sc;
dvander@1847
    58
	KTrie<sm_sendprop_info_t> lookup;
dvander@592
    59
};
dvander@592
    60
faluco@682
    61
struct DataMapTrie
faluco@682
    62
{
faluco@682
    63
	DataMapTrie() : trie(NULL) {}
faluco@682
    64
	Trie *trie;
faluco@682
    65
};
faluco@682
    66
dvander@1338
    67
struct DelayedFakeCliCmd
dvander@1338
    68
{
dvander@1338
    69
	String cmd;
dvander@1338
    70
	int client;
dvander@1338
    71
	int userid;
dvander@1338
    72
};
dvander@1338
    73
dvander@1544
    74
struct CachedCommandInfo
dvander@1544
    75
{
dvander@1544
    76
	const CCommand *args;
dvander@1544
    77
#if !defined ORANGEBOX_BUILD
dvander@1544
    78
	char cmd[300];
dvander@1544
    79
#endif
dvander@1544
    80
};
dvander@1544
    81
dvander@2162
    82
struct DelayedKickInfo
dvander@2162
    83
{
dvander@2162
    84
	int userid;
dvander@2162
    85
	int client;
dvander@2162
    86
	char buffer[384];
dvander@2162
    87
};
dvander@2162
    88
dvander@965
    89
class CHalfLife2 : 
dvander@965
    90
	public SMGlobalClass,
dvander@965
    91
	public IGameHelpers
dvander@592
    92
{
dvander@592
    93
public:
dvander@592
    94
	CHalfLife2();
dvander@592
    95
	~CHalfLife2();
dvander@592
    96
public:
dvander@677
    97
	void OnSourceModStartup(bool late);
ds@873
    98
	void OnSourceModAllInitialized();
dvander@677
    99
	/*void OnSourceModAllShutdown();*/
dvander@965
   100
public: //IGameHelpers
dvander@592
   101
	SendProp *FindInSendTable(const char *classname, const char *offset);
dvander@1847
   102
	bool FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info);
dvander@965
   103
	datamap_t *GetDataMap(CBaseEntity *pEntity);
dvander@592
   104
	ServerClass *FindServerClass(const char *classname);
faluco@682
   105
	typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
dvander@685
   106
	void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
dvander@1132
   107
	bool TextMsg(int client, int dest, const char *msg);
teame06@1264
   108
	bool HintTextMsg(int client, const char *msg);
faluco@1218
   109
	bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
dvander@1423
   110
	bool IsLANServer();
ds@1944
   111
	bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL);
dvander@1338
   112
public:
dvander@1338
   113
	void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
dvander@1338
   114
	void ProcessFakeCliCmdQueue();
dvander@1544
   115
public:
dvander@1544
   116
	void PushCommandStack(const CCommand *cmd);
dvander@1544
   117
	void PopCommandStack();
dvander@1544
   118
	const CCommand *PeekCommandStack();
dvander@1544
   119
	const char *CurrentCommandName();
dvander@2162
   120
	void AddDelayedKick(int client, int userid, const char *msg);
dvander@2162
   121
	void ProcessDelayedKicks();
dvander@1581
   122
#if !defined METAMOD_PLAPI_VERSION
dvander@1581
   123
	bool IsOriginalEngine();
dvander@1581
   124
#endif
dvander@592
   125
private:
dvander@592
   126
	DataTableInfo *_FindServerClass(const char *classname);
dvander@592
   127
private:
dvander@592
   128
	Trie *m_pClasses;
dvander@592
   129
	List<DataTableInfo *> m_Tables;
faluco@682
   130
	THash<datamap_t *, DataMapTrie> m_Maps;
ds@873
   131
	int m_MsgTextMsg;
faluco@1218
   132
	int m_HinTextMsg;
faluco@1218
   133
	int m_VGUIMenu;
dvander@1338
   134
	Queue<DelayedFakeCliCmd *> m_CmdQueue;
dvander@1338
   135
	CStack<DelayedFakeCliCmd *> m_FreeCmds;
dvander@1544
   136
	CStack<CachedCommandInfo> m_CommandStack;
dvander@2162
   137
	Queue<DelayedKickInfo> m_DelayedKicks;
dvander@592
   138
};
dvander@592
   139
dvander@592
   140
extern CHalfLife2 g_HL2;
dvander@592
   141
dvander@592
   142
#endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_