public/IGameHelpers.h
author Matt Woodrow <pred@alliedmods.net>
Sun Jul 06 03:30:06 2008 +0000 (2008-07-06)
changeset 2165 ca3757e676f6
parent 2051 568678a2e847
child 2289 44045ead61cd
permissions -rw-r--r--
Fixed requiring dependencies at the wrong time.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #ifndef _INCLUDE_SOURCEMOD_GAMEHELPERS_H_
    33 #define _INCLUDE_SOURCEMOD_GAMEHELPERS_H_
    34 
    35 #include <IShareSys.h>
    36 
    37 /**
    38  * @file IGameHelpers.h
    39  * @brief Provides Source helper functions.
    40  */
    41 
    42 #define SMINTERFACE_GAMEHELPERS_NAME		"IGameHelpers"
    43 #define SMINTERFACE_GAMEHELPERS_VERSION		2
    44 
    45 class CBaseEntity;
    46 class SendProp;
    47 class ServerClass;
    48 struct edict_t;
    49 struct datamap_t;
    50 struct typedescription_t;
    51 
    52 namespace SourceMod
    53 {
    54 	/**
    55 	 * @brief Maps the heirarchy of a SendProp.
    56 	 */
    57 	struct sm_sendprop_info_t
    58 	{
    59 		SendProp *prop;					/**< Property instance. */
    60 		unsigned int actual_offset;		/**< Actual computed offset. */
    61 	};
    62 
    63 	class IGameHelpers : public SMInterface
    64 	{
    65 	public:
    66 		virtual const char *GetInterfaceName()
    67 		{
    68 			return SMINTERFACE_GAMEHELPERS_NAME;
    69 		}
    70 		virtual unsigned int GetInterfaceVersion()
    71 		{
    72 			return SMINTERFACE_GAMEHELPERS_VERSION;
    73 		}
    74 	public:
    75 		/**
    76 		 * @brief Deprecated; use FindSendPropInfo() instead.
    77 		 *
    78 		 * @param classname		Do not use.
    79 		 * @param offset		Do not use.
    80 		 * @return				Do not use.
    81 		 */
    82 		virtual SendProp *FindInSendTable(const char *classname, const char *offset) =0;
    83 
    84 		/**
    85 		 * @brief Finds a named server class.
    86 		 *
    87 		 * @return				ServerClass pointer on success, NULL on failure.
    88 		 */
    89 		virtual ServerClass *FindServerClass(const char *classname) =0;
    90 
    91 		/**
    92 		 * @brief Finds a datamap_t definition.
    93 		 *
    94 		 * @param pMap			datamap_t pointer.
    95 		 * @param offset		Property name.
    96 		 * @return				typedescription_t pointer on success, NULL 
    97 		 *						on failure.
    98 		 */
    99 		virtual typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset) =0;
   100 
   101 		/**
   102 		 * @brief Retrieves an entity's datamap_t pointer.
   103 		 *
   104 		 * @param pEntity		CBaseEntity entity.
   105 		 * @return				datamap_t pointer, or NULL on failure.
   106 		 */
   107 		virtual datamap_t *GetDataMap(CBaseEntity *pEntity) =0;
   108 
   109 		/**
   110 		 * @brief Marks an edict as state changed for an offset.
   111 		 *
   112 		 * @param pEdict		Edict pointer.
   113 		 * @param offset		Offset index.
   114 		 */
   115 		virtual void SetEdictStateChanged(edict_t *pEdict, unsigned short offset) =0;
   116 
   117 		/**
   118 		 * @brief Sends a text message to a client.
   119 		 *
   120 		 * @param client		Client index.
   121 		 * @param dest			Destination on the HUD.
   122 		 * @param msg			Message to send.
   123 		 * @return				True on success, false on failure.
   124 		 */
   125 		virtual bool TextMsg(int client, int dest, const char *msg) =0;
   126 		
   127 		/**
   128 		 * @brief Returns whether the server ls a LAN server.
   129 		 * 
   130 		 * @return				True if LAN server, false otherwise.
   131 		 */
   132 		virtual bool IsLANServer() =0;
   133 
   134 		/**
   135 		 * @brief Finds a send property in a named ServerClass.
   136 		 *
   137 		 * This version, unlike FindInSendTable(), correctly deduces the 
   138 		 * offsets of nested tables.
   139 		 *
   140 		 * @param classname		ServerClass name (such as CBasePlayer).
   141 		 * @param offset		Offset name (such as m_iAmmo).
   142 		 * @param info			Buffer to store sm_sendprop_info_t data.
   143 		 * @return				True on success, false on failure.
   144 		 */
   145 		virtual bool FindSendPropInfo(const char *classname,
   146 			const char *offset,
   147 			sm_sendprop_info_t *info) =0;
   148 	};
   149 }
   150 
   151 #endif //_INCLUDE_SOURCEMOD_GAMEHELPERS_H_