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 7 00044 00045 class CBaseEntity; 00046 class CBaseHandle; 00047 class SendProp; 00048 class ServerClass; 00049 struct edict_t; 00050 struct datamap_t; 00051 struct typedescription_t; 00052 00053 #define TEXTMSG_DEST_NOTIFY 1 00054 #define TEXTMSG_DEST_CONSOLE 2 00055 #define TEXTMSG_DEST_CHAT 3 00056 #define TEXTMSG_DEST_CENTER 4 00057 00058 namespace SourceMod 00059 { 00060 /** 00061 * @brief Maps the heirarchy of a SendProp. 00062 */ 00063 struct sm_sendprop_info_t 00064 { 00065 SendProp *prop; /**< Property instance. */ 00066 unsigned int actual_offset; /**< Actual computed offset. */ 00067 }; 00068 00069 class IGameHelpers : public SMInterface 00070 { 00071 public: 00072 virtual const char *GetInterfaceName() 00073 { 00074 return SMINTERFACE_GAMEHELPERS_NAME; 00075 } 00076 virtual unsigned int GetInterfaceVersion() 00077 { 00078 return SMINTERFACE_GAMEHELPERS_VERSION; 00079 } 00080 public: 00081 /** 00082 * @brief Deprecated; use FindSendPropInfo() instead. 00083 * 00084 * @param classname Do not use. 00085 * @param offset Do not use. 00086 * @return Do not use. 00087 */ 00088 virtual SendProp *FindInSendTable(const char *classname, const char *offset) =0; 00089 00090 /** 00091 * @brief Finds a named server class. 00092 * 00093 * @return ServerClass pointer on success, NULL on failure. 00094 */ 00095 virtual ServerClass *FindServerClass(const char *classname) =0; 00096 00097 /** 00098 * @brief Finds a datamap_t definition. 00099 * 00100 * @param pMap datamap_t pointer. 00101 * @param offset Property name. 00102 * @return typedescription_t pointer on success, NULL 00103 * on failure. 00104 */ 00105 virtual typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset) =0; 00106 00107 /** 00108 * @brief Retrieves an entity's datamap_t pointer. 00109 * 00110 * @param pEntity CBaseEntity entity. 00111 * @return datamap_t pointer, or NULL on failure. 00112 */ 00113 virtual datamap_t *GetDataMap(CBaseEntity *pEntity) =0; 00114 00115 /** 00116 * @brief Marks an edict as state changed for an offset. 00117 * 00118 * @param pEdict Edict pointer. 00119 * @param offset Offset index. 00120 */ 00121 virtual void SetEdictStateChanged(edict_t *pEdict, unsigned short offset) =0; 00122 00123 /** 00124 * @brief Sends a text message to a client. 00125 * 00126 * @param client Client index. 00127 * @param dest Destination on the HUD (see TEXTMSG_DEST defines above). 00128 * @param msg Message to send. 00129 * @return True on success, false on failure. 00130 */ 00131 virtual bool TextMsg(int client, int dest, const char *msg) =0; 00132 00133 /** 00134 * @brief Returns whether the server ls a LAN server. 00135 * 00136 * @return True if LAN server, false otherwise. 00137 */ 00138 virtual bool IsLANServer() =0; 00139 00140 /** 00141 * @brief Finds a send property in a named ServerClass. 00142 * 00143 * This version, unlike FindInSendTable(), correctly deduces the 00144 * offsets of nested tables. 00145 * 00146 * @param classname ServerClass name (such as CBasePlayer). 00147 * @param offset Offset name (such as m_iAmmo). 00148 * @param info Buffer to store sm_sendprop_info_t data. 00149 * @return True on success, false on failure. 00150 */ 00151 virtual bool FindSendPropInfo(const char *classname, 00152 const char *offset, 00153 sm_sendprop_info_t *info) =0; 00154 00155 /** 00156 * @brief Converts an entity index into an edict pointer. 00157 * 00158 * @param index Entity Index. 00159 * @return Edict pointer or NULL on failure. 00160 */ 00161 virtual edict_t *EdictOfIndex(int index) =0; 00162 00163 /** 00164 * @brief Converts an edict pointer into an entity index. 00165 * 00166 * @param index Edict Pointer. 00167 * @return Entity index or -1 on failure. 00168 */ 00169 virtual int IndexOfEdict(edict_t *pEnt) =0; 00170 00171 /** 00172 * @brief Retrieves the edict pointer from a CBaseHandle object. 00173 * 00174 * @param hndl CBaseHandle object. 00175 * @return Edict pointer or NULL on failure. 00176 */ 00177 virtual edict_t *GetHandleEntity(CBaseHandle &hndl) =0; 00178 00179 /** 00180 * @brief Sets the edict pointer in a CBaseHandle object. 00181 * 00182 * @param hndl CBaseHandle object. 00183 * @param pEnt Edict pointer. 00184 * @noreturn 00185 */ 00186 virtual void SetHandleEntity(CBaseHandle &hndl, edict_t *pEnt) =0; 00187 00188 /** 00189 * @brief Returns the current map name. 00190 * 00191 * @return Current map name. 00192 */ 00193 virtual const char *GetCurrentMap() =0; 00194 00195 /** 00196 * @brief Wraps IVEngineServer::ServerCommand. 00197 * 00198 * @param buffer Command buffer (does not auto \n terminate). 00199 */ 00200 virtual void ServerCommand(const char *buffer) =0; 00201 00202 /** 00203 * @brief Looks up a reference and returns the CBasseEntity* it points to. 00204 * 00205 * @note Supports 'old style' simple indexes and does a serial confirmation check on references. 00206 * 00207 * @param entRef Entity reference. 00208 * @return Entity pointer. 00209 */ 00210 virtual CBaseEntity *ReferenceToEntity(cell_t entRef) =0; 00211 00212 /** 00213 * @brief Returns the entity reference for an entity. 00214 * 00215 * @param pEntity Entity pointer. 00216 * @return Entity reference. 00217 */ 00218 virtual cell_t EntityToReference(CBaseEntity *pEntity) =0; 00219 00220 /** 00221 * @brief Returns the entity reference for logical entities, or the index for networked entities. 00222 * 00223 * @param pEntity Entity pointer. 00224 * @return Entity reference/index. 00225 */ 00226 virtual cell_t EntityToBCompatRef(CBaseEntity *pEntity) =0; 00227 00228 /** 00229 * @brief Converts an entity index into an entity reference. 00230 * 00231 * @param entIndex Entity index. 00232 * @return Entity reference. 00233 */ 00234 virtual cell_t IndexToReference(int entIndex) =0; 00235 00236 /** 00237 * @brief Retrieves the entity index from a reference. 00238 * 00239 * @param entRef Entity reference. 00240 * @return Entity index. 00241 */ 00242 virtual int ReferenceToIndex(cell_t entRef) =0; 00243 00244 /** 00245 * @brief Converts a reference into a bcompat version (index for networked entities). 00246 * 00247 * @param entRef Entity reference. 00248 * @return Entity reference/index. 00249 */ 00250 virtual cell_t ReferenceToBCompatRef(cell_t entRef) =0; 00251 00252 /** 00253 * @brief Returns the g_EntList pointer. 00254 * 00255 * @return g_EntList pointer. 00256 */ 00257 virtual void *GetGlobalEntityList() =0; 00258 00259 /** 00260 * @brief Adds a client to the kick queue, where they will be kicked 00261 * next game frame. 00262 * 00263 * The user ID is used to ensure the correct player is kicked. 00264 * 00265 * @param client The index of the client to kick. 00266 * @param userid The user ID of the client to kick. 00267 * @param msg The kick message to show to the player. 00268 */ 00269 virtual void AddDelayedKick(int client, int userid, const char *msg) =0; 00270 00271 /** 00272 * @brief Returns the uncomputed offset of a SendProp. 00273 * 00274 * @param prop SendProp pointer. 00275 * @return Uncomputed sendprop offset. 00276 */ 00277 virtual int GetSendPropOffset(SendProp *prop) =0; 00278 00279 /** 00280 * @brief Sends a hint message to a client. 00281 * 00282 * @param client Client index. 00283 * @param msg Message to send. 00284 * @return True on success, false on failure. 00285 */ 00286 virtual bool HintTextMsg(int client, const char *msg) =0; 00287 }; 00288 } 00289 00290 #endif //_INCLUDE_SOURCEMOD_GAMEHELPERS_H_
1.7.1