dvander@592: /**
dvander@592: * vim: set ts=4 :
ds@1330: * =============================================================================
dvander@1231: * SourceMod
ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
dvander@592: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
dvander@1231: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
dvander@1231: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
dvander@1231: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
dvander@592: *
dvander@592: * Version: $Id$
dvander@592: */
dvander@592:
dvander@592: #ifndef _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
dvander@592: #define _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
dvander@592:
dvander@592: #include
dvander@1338: #include
faluco@682: #include
dvander@1847: #include
dvander@592: #include "sm_trie.h"
dvander@592: #include "sm_globals.h"
dvander@1338: #include "sm_queue.h"
dvander@965: #include
faluco@1218: #include
ds@2051: #include
ds@2051: #include
pred@2746: #include
skamonkey@3461: #include
skamonkey@3515: #if SOURCE_ENGINE >= SE_PORTAL2
skamonkey@3515: #include
skamonkey@3515: #endif
skamonkey@3460:
dvander@1544: class CCommand;
dvander@1544:
dvander@592: using namespace SourceHook;
dvander@965: using namespace SourceMod;
dvander@592:
dvander@895: #define HUD_PRINTTALK 3
dvander@895: #define HUD_PRINTCENTER 4
dvander@895:
dvander@592: struct DataTableInfo
dvander@592: {
dvander@592: ServerClass *sc;
dvander@1847: KTrie lookup;
dvander@592: };
dvander@592:
faluco@682: struct DataMapTrie
faluco@682: {
faluco@682: DataMapTrie() : trie(NULL) {}
faluco@682: Trie *trie;
faluco@682: };
faluco@682:
dvander@1338: struct DelayedFakeCliCmd
dvander@1338: {
dvander@1338: String cmd;
dvander@1338: int client;
dvander@1338: int userid;
dvander@1338: };
dvander@1338:
dvander@1544: struct CachedCommandInfo
dvander@1544: {
dvander@1544: const CCommand *args;
ds@2583: #if SOURCE_ENGINE <= SE_DARKMESSIAH
dvander@1544: char cmd[300];
dvander@1544: #endif
dvander@1544: };
dvander@1544:
dvander@2162: struct DelayedKickInfo
dvander@2162: {
dvander@2162: int userid;
dvander@2162: int client;
dvander@2162: char buffer[384];
dvander@2162: };
dvander@2162:
skamonkey@3515: // copy from game/shared/entitylist_base.h
pred@2746: class CEntInfo
pred@2746: {
pred@2746: public:
pred@2746: IHandleEntity *m_pEntity;
pred@2746: int m_SerialNumber;
pred@2746: CEntInfo *m_pPrev;
pred@2746: CEntInfo *m_pNext;
skamonkey@3853: #if (SOURCE_ENGINE >= SE_PORTAL2) && (SOURCE_ENGINE != SE_DOTA)
skamonkey@3515: string_t m_iName;
skamonkey@3515: string_t m_iClassName;
skamonkey@3515: #endif
pred@2746: };
pred@2746:
dvander@965: class CHalfLife2 :
dvander@965: public SMGlobalClass,
dvander@965: public IGameHelpers
dvander@592: {
dvander@592: public:
dvander@592: CHalfLife2();
dvander@592: ~CHalfLife2();
dvander@592: public:
dvander@677: void OnSourceModStartup(bool late);
ds@873: void OnSourceModAllInitialized();
pred@2746: void OnSourceModAllInitialized_Post();
dvander@677: /*void OnSourceModAllShutdown();*/
dvander@965: public: //IGameHelpers
dvander@592: SendProp *FindInSendTable(const char *classname, const char *offset);
dvander@1847: bool FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info);
dvander@965: datamap_t *GetDataMap(CBaseEntity *pEntity);
dvander@592: ServerClass *FindServerClass(const char *classname);
faluco@682: typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
asherkin@3806: typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset, bool *isNested);
dvander@685: void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
dvander@1132: bool TextMsg(int client, int dest, const char *msg);
teame06@1264: bool HintTextMsg(int client, const char *msg);
pred@2801: bool HintTextMsg(cell_t *players, int count, const char *msg);
faluco@1218: bool ShowVGUIMenu(int client, const char *name, KeyValues *data, bool show);
dvander@1423: bool IsLANServer();
ds@1944: bool KVLoadFromFile(KeyValues *kv, IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL);
pred@2596: edict_t *EdictOfIndex(int index);
pred@2596: int IndexOfEdict(edict_t *pEnt);
pred@2596: edict_t *GetHandleEntity(CBaseHandle &hndl);
pred@2596: void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt);
dvander@2628: const char *GetCurrentMap();
dvander@2628: void ServerCommand(const char *buffer);
pred@2746: CBaseEntity *ReferenceToEntity(cell_t entRef);
pred@2746: cell_t EntityToReference(CBaseEntity *pEntity);
pred@2746: cell_t IndexToReference(int entIndex);
pred@2746: int ReferenceToIndex(cell_t entRef);
pred@2746: cell_t ReferenceToBCompatRef(cell_t entRef);
pred@2746: CEntInfo *LookupEntity(int entIndex);
pred@2746: cell_t EntityToBCompatRef(CBaseEntity *pEntity);
pred@2746: void *GetGlobalEntityList();
dvander@3010: int GetSendPropOffset(SendProp *prop);
skamonkey@3460: ICommandLine *GetValveCommandLine();
kyle@3638: const char *GetEntityClassname(edict_t *pEdict);
kyle@3638: const char *GetEntityClassname(CBaseEntity *pEntity);
skamonkey@3789: bool IsMapValid(const char *map);
dvander@1338: public:
dvander@1338: void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
dvander@1338: void ProcessFakeCliCmdQueue();
dvander@1544: public:
dvander@1544: void PushCommandStack(const CCommand *cmd);
dvander@1544: void PopCommandStack();
dvander@1544: const CCommand *PeekCommandStack();
dvander@1544: const char *CurrentCommandName();
dvander@2162: void AddDelayedKick(int client, int userid, const char *msg);
dvander@2162: void ProcessDelayedKicks();
dvander@2846: #if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
dvander@1581: bool IsOriginalEngine();
dvander@1581: #endif
dvander@592: private:
dvander@592: DataTableInfo *_FindServerClass(const char *classname);
dvander@592: private:
skamonkey@3460: void InitLogicalEntData();
skamonkey@3460: void InitCommandLine();
skamonkey@3460: private:
dvander@592: Trie *m_pClasses;
dvander@592: List m_Tables;
faluco@682: THash m_Maps;
ds@873: int m_MsgTextMsg;
faluco@1218: int m_HinTextMsg;
ds@2583: int m_SayTextMsg;
faluco@1218: int m_VGUIMenu;
dvander@1338: Queue m_CmdQueue;
dvander@1338: CStack m_FreeCmds;
dvander@1544: CStack m_CommandStack;
dvander@2162: Queue m_DelayedKicks;
skamonkey@3462: void *m_pGetCommandLine;
dvander@592: };
dvander@592:
dvander@592: extern CHalfLife2 g_HL2;
dvander@592:
fyrenmoo@2879: bool IndexToAThings(cell_t, CBaseEntity **pEntData, edict_t **pEdictData);
pred@2596:
dvander@592: #endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_