00001 /** 00002 * vim: set ts=4 : 00003 * ============================================================================= 00004 * SourceMod 00005 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. 00006 * ============================================================================= 00007 * 00008 * This program is free software; you can redistribute it and/or modify it under 00009 * the terms of the GNU General Public License, version 3.0, as published by the 00010 * Free Software Foundation. 00011 * 00012 * This program is distributed in the hope that it will be useful, but WITHOUT 00013 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00015 * details. 00016 * 00017 * You should have received a copy of the GNU General Public License along with 00018 * this program. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 * As a special exception, AlliedModders LLC gives you permission to link the 00021 * code of this program (as well as its derivative works) to "Half-Life 2," the 00022 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software 00023 * by the Valve Corporation. You must obey the GNU General Public License in 00024 * all respects for all other code used. Additionally, AlliedModders LLC grants 00025 * this exception to all derivative works. AlliedModders LLC defines further 00026 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), 00027 * or <http://www.sourcemod.net/license.php>. 00028 * 00029 * Version: $Id$ 00030 */ 00031 00032 #ifndef _INCLUDE_SOURCEMOD_GAMEHELPERS_H_ 00033 #define _INCLUDE_SOURCEMOD_GAMEHELPERS_H_ 00034 00035 #include <IShareSys.h> 00036 00037 /** 00038 * @file IGameHelpers.h 00039 * @brief Provides Source helper functions. 00040 */ 00041 00042 #define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers" 00043 #define SMINTERFACE_GAMEHELPERS_VERSION 2 00044 00045 class CBaseEntity; 00046 class SendProp; 00047 class ServerClass; 00048 struct edict_t; 00049 struct datamap_t; 00050 struct typedescription_t; 00051 00052 namespace SourceMod 00053 { 00054 /** 00055 * @brief Maps the heirarchy of a SendProp. 00056 */ 00057 struct sm_sendprop_info_t 00058 { 00059 SendProp *prop; /**< Property instance. */ 00060 unsigned int actual_offset; /**< Actual computed offset. */ 00061 }; 00062 00063 class IGameHelpers : public SMInterface 00064 { 00065 public: 00066 virtual const char *GetInterfaceName() 00067 { 00068 return SMINTERFACE_GAMEHELPERS_NAME; 00069 } 00070 virtual unsigned int GetInterfaceVersion() 00071 { 00072 return SMINTERFACE_GAMEHELPERS_VERSION; 00073 } 00074 public: 00075 /** 00076 * @brief Deprecated; use FindSendPropInfo() instead. 00077 * 00078 * @param classname Do not use. 00079 * @param offset Do not use. 00080 * @return Do not use. 00081 */ 00082 virtual SendProp *FindInSendTable(const char *classname, const char *offset) =0; 00083 00084 /** 00085 * @brief Finds a named server class. 00086 * 00087 * @return ServerClass pointer on success, NULL on failure. 00088 */ 00089 virtual ServerClass *FindServerClass(const char *classname) =0; 00090 00091 /** 00092 * @brief Finds a datamap_t definition. 00093 * 00094 * @param pMap datamap_t pointer. 00095 * @param offset Property name. 00096 * @return typedescription_t pointer on success, NULL 00097 * on failure. 00098 */ 00099 virtual typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset) =0; 00100 00101 /** 00102 * @brief Retrieves an entity's datamap_t pointer. 00103 * 00104 * @param pEntity CBaseEntity entity. 00105 * @return datamap_t pointer, or NULL on failure. 00106 */ 00107 virtual datamap_t *GetDataMap(CBaseEntity *pEntity) =0; 00108 00109 /** 00110 * @brief Marks an edict as state changed for an offset. 00111 * 00112 * @param pEdict Edict pointer. 00113 * @param offset Offset index. 00114 */ 00115 virtual void SetEdictStateChanged(edict_t *pEdict, unsigned short offset) =0; 00116 00117 /** 00118 * @brief Sends a text message to a client. 00119 * 00120 * @param client Client index. 00121 * @param dest Destination on the HUD. 00122 * @param msg Message to send. 00123 * @return True on success, false on failure. 00124 */ 00125 virtual bool TextMsg(int client, int dest, const char *msg) =0; 00126 00127 /** 00128 * @brief Returns whether the server ls a LAN server. 00129 * 00130 * @return True if LAN server, false otherwise. 00131 */ 00132 virtual bool IsLANServer() =0; 00133 00134 /** 00135 * @brief Finds a send property in a named ServerClass. 00136 * 00137 * This version, unlike FindInSendTable(), correctly deduces the 00138 * offsets of nested tables. 00139 * 00140 * @param classname ServerClass name (such as CBasePlayer). 00141 * @param offset Offset name (such as m_iAmmo). 00142 * @param info Buffer to store sm_sendprop_info_t data. 00143 * @return True on success, false on failure. 00144 */ 00145 virtual bool FindSendPropInfo(const char *classname, 00146 const char *offset, 00147 sm_sendprop_info_t *info) =0; 00148 }; 00149 } 00150 00151 #endif //_INCLUDE_SOURCEMOD_GAMEHELPERS_H_
1.5.1