2008-03-30 09:00:22 +02:00
|
|
|
/**
|
|
|
|
* vim: set ts=4 :
|
|
|
|
* =============================================================================
|
|
|
|
* SourceMod
|
|
|
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
|
|
|
|
|
|
|
#include <sh_list.h>
|
|
|
|
#include <sh_string.h>
|
|
|
|
#include <sh_tinyhash.h>
|
|
|
|
#include <sm_trie_tpl.h>
|
|
|
|
#include "sm_trie.h"
|
|
|
|
#include "sm_globals.h"
|
|
|
|
#include "sm_queue.h"
|
|
|
|
#include <IGameHelpers.h>
|
|
|
|
#include <KeyValues.h>
|
2008-05-13 10:22:49 +02:00
|
|
|
#include <server_class.h>
|
|
|
|
#include <datamap.h>
|
2009-07-24 02:34:31 +02:00
|
|
|
#include <ihandleentity.h>
|
2012-02-25 21:23:39 +01:00
|
|
|
#include <tier0/icommandline.h>
|
2012-05-27 22:08:03 +02:00
|
|
|
#if SOURCE_ENGINE >= SE_PORTAL2
|
|
|
|
#include <string_t.h>
|
|
|
|
#endif
|
2012-02-25 21:09:56 +01:00
|
|
|
|
2008-03-30 09:00:22 +02:00
|
|
|
class CCommand;
|
|
|
|
|
|
|
|
using namespace SourceHook;
|
|
|
|
using namespace SourceMod;
|
|
|
|
|
|
|
|
#define HUD_PRINTTALK 3
|
|
|
|
#define HUD_PRINTCENTER 4
|
|
|
|
|
|
|
|
struct DataTableInfo
|
|
|
|
{
|
|
|
|
ServerClass *sc;
|
|
|
|
KTrie<sm_sendprop_info_t> lookup;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DataMapTrie
|
|
|
|
{
|
|
|
|
DataMapTrie() : trie(NULL) {}
|
|
|
|
Trie *trie;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DelayedFakeCliCmd
|
|
|
|
{
|
|
|
|
String cmd;
|
|
|
|
int client;
|
|
|
|
int userid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CachedCommandInfo
|
|
|
|
{
|
|
|
|
const CCommand *args;
|
2009-02-18 09:19:22 +01:00
|
|
|
#if SOURCE_ENGINE <= SE_DARKMESSIAH
|
2008-03-30 09:00:22 +02:00
|
|
|
char cmd[300];
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2008-07-06 02:45:26 +02:00
|
|
|
struct DelayedKickInfo
|
|
|
|
{
|
|
|
|
int userid;
|
|
|
|
int client;
|
|
|
|
char buffer[384];
|
|
|
|
};
|
|
|
|
|
2012-05-27 22:08:03 +02:00
|
|
|
// copy from game/shared/entitylist_base.h
|
2009-07-24 02:34:31 +02:00
|
|
|
class CEntInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IHandleEntity *m_pEntity;
|
|
|
|
int m_SerialNumber;
|
|
|
|
CEntInfo *m_pPrev;
|
|
|
|
CEntInfo *m_pNext;
|
2013-03-19 16:18:44 +01:00
|
|
|
#if (SOURCE_ENGINE >= SE_PORTAL2) && (SOURCE_ENGINE != SE_DOTA)
|
2012-05-27 22:08:03 +02:00
|
|
|
string_t m_iName;
|
|
|
|
string_t m_iClassName;
|
|
|
|
#endif
|
2009-07-24 02:34:31 +02:00
|
|
|
};
|
|
|
|
|
2008-03-30 09:00:22 +02:00
|
|
|
class CHalfLife2 :
|
|
|
|
public SMGlobalClass,
|
|
|
|
public IGameHelpers
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CHalfLife2();
|
|
|
|
~CHalfLife2();
|
|
|
|
public:
|
|
|
|
void OnSourceModStartup(bool late);
|
|
|
|
void OnSourceModAllInitialized();
|
2009-07-24 02:34:31 +02:00
|
|
|
void OnSourceModAllInitialized_Post();
|
2008-03-30 09:00:22 +02:00
|
|
|
/*void OnSourceModAllShutdown();*/
|
|
|
|
public: //IGameHelpers
|
|
|
|
SendProp *FindInSendTable(const char *classname, const char *offset);
|
|
|
|
bool FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info);
|
|
|
|
datamap_t *GetDataMap(CBaseEntity *pEntity);
|
|
|
|
ServerClass *FindServerClass(const char *classname);
|
|
|
|
typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
|
2012-09-03 21:26:39 +02:00
|
|
|
typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset, bool *isNested);
|
2008-03-30 09:00:22 +02:00
|
|
|
void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
|
|
|
|
bool TextMsg(int client, int dest, const char *msg);
|
|
|
|
bool HintTextMsg(int client, const char *msg);
|
2009-09-17 08:54:40 +02:00
|
|
|
bool HintTextMsg(cell_t *players, int count, const char *msg);
|
2008-03-30 09:00:22 +02:00
|
|
|
bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
|
|
|
|
bool IsLANServer();
|
|
|
|
bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL);
|
2009-02-22 02:38:05 +01:00
|
|
|
edict_t *EdictOfIndex(int index);
|
|
|
|
int IndexOfEdict(edict_t *pEnt);
|
|
|
|
edict_t *GetHandleEntity(CBaseHandle &hndl);
|
|
|
|
void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt);
|
2009-03-01 05:14:16 +01:00
|
|
|
const char *GetCurrentMap();
|
|
|
|
void ServerCommand(const char *buffer);
|
2009-07-24 02:34:31 +02:00
|
|
|
CBaseEntity *ReferenceToEntity(cell_t entRef);
|
|
|
|
cell_t EntityToReference(CBaseEntity *pEntity);
|
|
|
|
cell_t IndexToReference(int entIndex);
|
|
|
|
int ReferenceToIndex(cell_t entRef);
|
|
|
|
cell_t ReferenceToBCompatRef(cell_t entRef);
|
|
|
|
CEntInfo *LookupEntity(int entIndex);
|
|
|
|
cell_t EntityToBCompatRef(CBaseEntity *pEntity);
|
|
|
|
void *GetGlobalEntityList();
|
2010-05-15 08:35:42 +02:00
|
|
|
int GetSendPropOffset(SendProp *prop);
|
2012-02-25 21:09:56 +01:00
|
|
|
ICommandLine *GetValveCommandLine();
|
2012-08-28 22:20:15 +02:00
|
|
|
const char *GetEntityClassname(edict_t *pEdict);
|
|
|
|
const char *GetEntityClassname(CBaseEntity *pEntity);
|
2013-02-15 01:28:12 +01:00
|
|
|
bool IsMapValid(const char *map);
|
2008-03-30 09:00:22 +02:00
|
|
|
public:
|
|
|
|
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
|
|
|
void ProcessFakeCliCmdQueue();
|
|
|
|
public:
|
|
|
|
void PushCommandStack(const CCommand *cmd);
|
|
|
|
void PopCommandStack();
|
|
|
|
const CCommand *PeekCommandStack();
|
|
|
|
const char *CurrentCommandName();
|
2008-07-06 02:45:26 +02:00
|
|
|
void AddDelayedKick(int client, int userid, const char *msg);
|
|
|
|
void ProcessDelayedKicks();
|
2009-10-29 09:33:57 +01:00
|
|
|
#if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
|
2008-03-30 09:00:22 +02:00
|
|
|
bool IsOriginalEngine();
|
|
|
|
#endif
|
|
|
|
private:
|
|
|
|
DataTableInfo *_FindServerClass(const char *classname);
|
2012-02-25 21:09:56 +01:00
|
|
|
private:
|
|
|
|
void InitLogicalEntData();
|
|
|
|
void InitCommandLine();
|
2008-03-30 09:00:22 +02:00
|
|
|
private:
|
|
|
|
Trie *m_pClasses;
|
|
|
|
List<DataTableInfo *> m_Tables;
|
|
|
|
THash<datamap_t *, DataMapTrie> m_Maps;
|
|
|
|
int m_MsgTextMsg;
|
|
|
|
int m_HinTextMsg;
|
2009-02-18 09:19:22 +01:00
|
|
|
int m_SayTextMsg;
|
2008-03-30 09:00:22 +02:00
|
|
|
int m_VGUIMenu;
|
|
|
|
Queue<DelayedFakeCliCmd *> m_CmdQueue;
|
|
|
|
CStack<DelayedFakeCliCmd *> m_FreeCmds;
|
|
|
|
CStack<CachedCommandInfo> m_CommandStack;
|
2008-07-06 02:45:26 +02:00
|
|
|
Queue<DelayedKickInfo> m_DelayedKicks;
|
2012-02-25 22:41:00 +01:00
|
|
|
void *m_pGetCommandLine;
|
2008-03-30 09:00:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CHalfLife2 g_HL2;
|
|
|
|
|
2009-12-16 08:14:53 +01:00
|
|
|
bool IndexToAThings(cell_t, CBaseEntity **pEntData, edict_t **pEdictData);
|
2009-02-22 02:38:05 +01:00
|
|
|
|
2008-03-30 09:00:22 +02:00
|
|
|
#endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|