3 * =============================================================================
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
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.
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
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/>.
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>.
32 #ifndef _INCLUDE_SOURCEMOD_GAMEHELPERS_H_
33 #define _INCLUDE_SOURCEMOD_GAMEHELPERS_H_
35 #include <IShareSys.h>
38 * @file IGameHelpers.h
39 * @brief Provides Source helper functions.
42 #define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers"
43 #define SMINTERFACE_GAMEHELPERS_VERSION 2
50 struct typedescription_t;
55 * @brief Maps the heirarchy of a SendProp.
57 struct sm_sendprop_info_t
59 SendProp *prop; /**< Property instance. */
60 unsigned int actual_offset; /**< Actual computed offset. */
63 class IGameHelpers : public SMInterface
66 virtual const char *GetInterfaceName()
68 return SMINTERFACE_GAMEHELPERS_NAME;
70 virtual unsigned int GetInterfaceVersion()
72 return SMINTERFACE_GAMEHELPERS_VERSION;
76 * @brief Deprecated; use FindSendPropInfo() instead.
78 * @param classname Do not use.
79 * @param offset Do not use.
82 virtual SendProp *FindInSendTable(const char *classname, const char *offset) =0;
85 * @brief Finds a named server class.
87 * @return ServerClass pointer on success, NULL on failure.
89 virtual ServerClass *FindServerClass(const char *classname) =0;
92 * @brief Finds a datamap_t definition.
94 * @param pMap datamap_t pointer.
95 * @param offset Property name.
96 * @return typedescription_t pointer on success, NULL
99 virtual typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset) =0;
102 * @brief Retrieves an entity's datamap_t pointer.
104 * @param pEntity CBaseEntity entity.
105 * @return datamap_t pointer, or NULL on failure.
107 virtual datamap_t *GetDataMap(CBaseEntity *pEntity) =0;
110 * @brief Marks an edict as state changed for an offset.
112 * @param pEdict Edict pointer.
113 * @param offset Offset index.
115 virtual void SetEdictStateChanged(edict_t *pEdict, unsigned short offset) =0;
118 * @brief Sends a text message to a client.
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.
125 virtual bool TextMsg(int client, int dest, const char *msg) =0;
128 * @brief Returns whether the server ls a LAN server.
130 * @return True if LAN server, false otherwise.
132 virtual bool IsLANServer() =0;
135 * @brief Finds a send property in a named ServerClass.
137 * This version, unlike FindInSendTable(), correctly deduces the
138 * offsets of nested tables.
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.
145 virtual bool FindSendPropInfo(const char *classname,
147 sm_sendprop_info_t *info) =0;
151 #endif //_INCLUDE_SOURCEMOD_GAMEHELPERS_H_