Trigger build for hl2sdk-l4d changes.
1 /* ======== SourceMM ========
2 * Copyright (C) 2004-2008 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): David "BAILOPAN" Anderson
8 * ============================
11 #ifndef _INCLUDE_ISMM_API_H
12 #define _INCLUDE_ISMM_API_H
15 * @brief External API interface
19 #include <interface.h>
21 #include <sourcehook/sourcehook.h>
22 #include "IPluginManager.h"
25 #if ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) || (__GNUC__ < 3)
26 #error "You must compile with at least GCC 3.4! If you know what you are doing, you can remove this message."
27 #endif //version check
30 class IMetamodListener;
31 class ISmmPluginManager;
34 #define MMIFACE_SOURCEHOOK "ISourceHook" /**< ISourceHook Pointer */
35 #define MMIFACE_PLMANAGER "IPluginManager" /**< SourceMM Plugin Functions */
36 #define IFACE_MAXNUM 999
38 #define SOURCE_ENGINE_UNKNOWN 0 /**< Could not determine the engine version */
39 #define SOURCE_ENGINE_ORIGINAL 1 /**< Original Source Engine (used by The Ship) */
40 #define SOURCE_ENGINE_EPISODEONE 2 /**< Episode 1 Source Engine (second major SDK) */
46 * @brief Logs a message through the HL2 log system.
47 * Note: Newlines are appended automatically.
49 * @param pl Plugin API pointer (used for tagging message)
50 * @param msg Formatted string.
52 virtual void LogMsg(ISmmPlugin *pl, const char *msg, ...) =0;
55 * @brief Returns an interface factory for the HL2 engine.
57 * @param syn If syn is true, the synthetic wrapper is returned.
58 * If syn is false, the true function is returned.
59 * @return CreateInterfaceFn function pointer.
61 virtual CreateInterfaceFn engineFactory(bool syn=true) =0;
64 * @brief Returns an interface factory for the HL2 physics engine.
66 * @param syn If syn is true, the synthetic wrapper is returned.
67 * If syn is false, the true function is returned.
68 * @return CreateInterfaceFn function pointer.
70 virtual CreateInterfaceFn physicsFactory(bool syn=true) =0;
73 * @brief Returns an interface factory for the HL2 file system.
75 * @param syn If syn is true, the synthetic wrapper is returned.
76 * If syn is false, the true function is returned.
77 * @return CreateInterfaceFn function pointer.
79 virtual CreateInterfaceFn fileSystemFactory(bool syn=true) =0;
82 * @brief Returns an interface factory for the GameDLL.
84 * @param syn If syn is true, the synthetic wrapper is returned.
85 * If syn is false, the true function is returned.
86 * @return CreateInterfaceFn function pointer.
88 virtual CreateInterfaceFn serverFactory(bool syn=true) =0;
91 * @brief Returns a CGlobalVars pointer from the HL2 Engine.
93 * @return CGlobalVars pointer.
95 virtual CGlobalVars *pGlobals() =0;
98 * @brief Used with SourceHook, sets teh last meta return value.
99 * Note: Do not call this directly, use the Metamod macros.
101 * @param res META_RETURN value to set.
103 virtual void SetLastMetaReturn(META_RES res) =0;
106 * @brief Used with SourceHook, returns the last meta return value.
107 * Note: This is only valid inside a hook function.
109 * @return Last META_RETURN value set by a plugin.
111 virtual META_RES GetLastMetaReturn() =0;
113 public: // Added in 1.00-RC2 (0:0)
115 * @brief Allows access to Metamod's ConCommandBaseAccessor.
117 * @return Returns IConCommandBaseAccessor pointer.
119 virtual IConCommandBaseAccessor *GetCvarBaseAccessor() =0;
122 * @brief Registers a ConCommandBase.
124 * @param plugin Parent plugin API pointer.
125 * @param pCommand ConCommandBase to register.
126 * @return True if successful, false otherwise. Does not return false yet.
128 virtual bool RegisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
131 * @brief Unregisters a ConCommandBase.
133 * @param plugin Parent plugin API pointer.
134 * @param pCommand ConCommandBase to unlink.
136 virtual void UnregisterConCmdBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
139 * @brief Prints an unformatted string to the remote server console.
140 * Note: Newlines are not added automatically.
142 * @param str Message string.
144 virtual void ConPrint(const char *str) =0;
147 * @brief Prints a formatted message to the remote server console.
148 * Note: Newlines are not added automatically.
150 * @param fmt Formatted message.
152 virtual void ConPrintf(const char *fmt, ...) =0;
154 public: // Added in 1.1.0 (1:0)
156 * @brief Checks if ConPrint/ConPrintf will mirror to rcon.
158 * @return True if remote printing available, false otherwise.
160 virtual bool RemotePrintingAvailable() =0;
163 * @brief Returns the Metamod Version numbers as major version and minor (API) version.
164 * Changes to minor version are guaranteed to be backwards compatible.
165 * Changes to major version are not.
167 * @param major Filled with the major API version number.
168 * @param minor Filled with the minor API version number.
169 * @param plvers Filled with the current plugin API version number.
170 * @param plmin Filled with the minimum plugin API version number supported.
172 virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin) =0;
175 * @brief Returns sourcehook API version and implementation version.
177 * @param shvers Filled with the SourceHook API version number.
178 * @param shimpl Filled with the SourceHook implementation number.
180 virtual void GetShVersions(int &shvers, int &shimpl) =0;
183 * @brief Adds a Metamod listener.
185 * @param plugin Plugin interface pointer.
186 * @param pListener Listener interface pointer to add.
188 virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener) =0;
191 * @brief Queries the metamod factory
193 * @param iface String containing interface name
194 * @param ret Optional pointer to store return status
195 * @param id Optional pointer to store id of plugin that overrode interface, 0 if none
196 * @return Returned pointer
198 virtual void *MetaFactory(const char *iface, int *ret, PluginId *id) =0;
200 public: // Added in 1.1.2 (1:1)
202 * @brief Given a base interface name, such as ServerGameDLL or ServerGameDLL003,
203 * reformats the string to increase the number, then returns the new number.
204 * This is the base function to InterfaceSearch() and VInterfaceMatch().
206 * @param iface Input/output interface name. Must be writable.
207 * @param maxlength Maximum length of iface buffer. Must be at least strlen(iface)+4 chars.
208 * @return The newly incremented iface version number.
210 virtual int FormatIface(char iface[], unsigned int maxlength) =0;
212 public: // Added in 1.2 (1:2)
214 * @brief Searches for an interface for you.
216 * @param fn InterfaceFactory function.
217 * @param iface Interface string name.
218 * @param max Maximum version to look up.
219 * @param ret Last return code from interface factory function.
220 * @return Interface pointer, or NULL if not found.
222 virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret) =0;
225 * @brief Returns the base directory of the game/server, equivalent to
226 * IVEngineServer::GetGameDir(), except the path is absolute.
228 * @return Static pointer to game's absolute basedir.
230 virtual const char *GetBaseDir() =0;
233 * @brief Formats a file path to the local OS. Does not include any base directories.
234 * Note that all slashes and black slashes are reverted to the local OS's expectancy.
236 * @param buffer Destination buffer to store path.
237 * @param len Maximum length of buffer, including null terminator.
238 * @param fmt Formatted string.
240 virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0;
242 public: // Added in 1.2.2 (1:3)
244 * @brief Prints text in the specified client's console. Same as IVEngineServer::ClientPrintf
245 * except that it allows for string formatting.
247 * @param client Client edict pointer.
248 * @param fmt Formatted string to print to the client.
250 virtual void ClientConPrintf(edict_t *client, const char *fmt, ...) =0;
252 public: // Added in 1.3 (1:4)
254 * @brief Wrapper around InterfaceSearch(). Assumes no maximum.
255 * This is designed to replace the fact that searches only went upwards.
256 * The "V" is intended to convey that this is for Valve formatted interface strings.
258 * @param fn Interface factory function.
259 * @param iface Interface string.
260 * @param min Minimum value to search from. If zero, searching begins from the
261 * first available version regardless of the interface.
262 * Note that this can return interfaces EARLIER than the version specified.
263 * A value of -1 (default) specifies the string version as the minimum.
264 * Any other value specifices the minimum value to search from.
265 * @return Interface pointer, or NULL if not found.
267 virtual void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1) =0;
269 public: // Added in 1.4 (1:5)
271 * @brief Tells SourceMM to add VSP hooking capability to plugins.
273 * Since this potentially uses more resources than it would otherwise, plugins have to
274 * explicitly enable the feature. Whether requested or not, if it is enabled, all plugins
275 * will get a pointer to the VSP listener through IMetamodListener.
277 virtual void EnableVSPListener() =0;
280 * @brief Returns the interface version of the GameDLL's IServerGameDLL implementation.
282 * @return Interface version of the loaded IServerGameDLL.
284 virtual int GetGameDLLVersion() =0;
287 * @brief Returns the number of user messages in the GameDLL.
289 * @return Number of user messages, or -1 if SourceMM has failed to get user message list.
291 virtual int GetUserMessageCount() =0;
294 * @brief Returns the index of the specified user message.
296 * @param name User message name.
297 * @param size Optional pointer to store size of user message.
298 * @return Message index, or -1 on failure.
300 virtual int FindUserMessage(const char *name, int *size=NULL) =0;
303 * @brief Returns the name of the specified user message.
305 * @param index User message index.
306 * @param size Optional pointer to store size of user message.
307 * @return Message name, or NULL on failure.
309 virtual const char *GetUserMessage(int index, int *size=NULL) =0;
312 * @brief Returns the VSP listener loaded.
314 * This is useful for late-loading plugins which need to decide whether
315 * to add a listener or not (or need to get the pointer at all).
317 * @param pVersion Optional pointer to store the VSP version.
318 * @return IServerPluginCallbacks pointer, or NULL if an
319 * IMetamodListener event has yet to occur for
320 * EnableVSPListener().
322 virtual IServerPluginCallbacks *GetVSPInfo(int *pVersion) =0;
325 * @brief Returns the engine interface that MM:S is using as a backend.
327 * The values will be one of the SOURCE_ENGINE_* constants from the top
330 * @return A SOURCE_ENGINE_* constant value.
332 virtual int GetSourceEngineBuild() =0;
340 * 1.1.0 Bumped API to 1:0. The breaking changes occurred in SourceHook and the plugin API.
341 * 1.1.2 Added API call for generating iface names.
342 * 1.2 Added API more helper functions and new SourceHook version.
343 * 1.2.2 Added API for printing to client console (with string formatting).
344 * 1.3 Added new interface search API.
345 * 1.4 Added VSP listener and user message API.
346 * 1.8 Backported SH VP hooks and various "new API" calls.
349 #endif //_INCLUDE_ISMM_API_H