added experimental extension interface for loading external extensions from mm:s
hard-bumped the extension api
3 * =============================================================================
5 * Copyright (C) 2004-2007 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_MAIN_HELPER_INTERFACE_H_
33 #define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
37 * @brief Defines miscellaneous helper functions useful to extensions.
40 #include <IHandleSys.h>
41 #include <sp_vm_api.h>
42 #include <IDataPack.h>
44 #define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
45 #define SMINTERFACE_SOURCEMOD_VERSION 3
48 * @brief Forward declaration of the KeyValues class.
55 * @brief Describes various ways of formatting a base path.
59 Path_None = 0, /**< No base path */
60 Path_Game, /**< Base path is absolute mod folder */
61 Path_SM, /**< Base path is absolute to SourceMod */
62 Path_SM_Rel, /**< Base path is relative to SourceMod */
66 * @brief Contains miscellaneous helper functions.
68 class ISourceMod : public SMInterface
71 virtual const char *GetInterfaceName()
73 return SMINTERFACE_SOURCEMOD_NAME;
75 virtual unsigned int GetInterfaceVersion()
77 return SMINTERFACE_SOURCEMOD_VERSION;
81 * @brief Returns the full path to the game directory.
83 * @return A string containing the full game path.
85 virtual const char *GetGamePath() const =0;
88 * @brief Returns the full path to the SourceMod directory.
90 * @return A string containing the full SourceMod path.
92 virtual const char *GetSourceModPath() const =0;
95 * @brief Builds a platform path for a specific target base path.
97 * @param type Type of path to use as a base.
98 * @param buffer Buffer to write to.
99 * @param maxlength Size of buffer.
100 * @param format Format string.
101 * @param ... Format arguments.
102 * @return Number of bytes written.
104 virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...) =0;
107 * @brief Logs a message to the SourceMod logs.
109 * @param pExt Extension calling this function.
110 * @param format Message format.
111 * @param ... Message format parameters.
113 virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
116 * @brief Logs a message to the SourceMod error logs.
118 * @param pExt Extension calling this function.
119 * @param format Message format.
120 * @param ... Message format parameters.
122 virtual void LogError(IExtension *pExt, const char *format, ...) =0;
125 * @brief Formats a string from a native.
127 * @param buffer Buffer to store message.
128 * @param maxlength Maximum length of buffer (including null terminator).
129 * @param pContext Pointer to the plugin's context.
130 * @param params Parameter array that was passed to the native.
131 * @param param Parameter index where format string and variable arguments begin.
132 * Note: parameter indexes start at 1.
133 * @return Number of bytes written, not including the null terminator.
135 virtual size_t FormatString(char *buffer,
137 SourcePawn::IPluginContext *pContext,
138 const cell_t *params,
139 unsigned int param) =0;
142 * @brief Creates a data pack object.
144 * @return A new IDataPack object.
146 virtual IDataPack *CreateDataPack() =0;
149 * @brief Releases a data pack's resources so it can be re-used.
151 * @param pack An IDataPack object to release.
153 virtual void FreeDataPack(IDataPack *pack) =0;
156 * @brief Not implemented, do not use.
158 * @param readonly Ignored
161 virtual HandleType_t GetDataPackHandleType(bool readonly=false) =0;
164 * @brief Retrieves a KeyValues pointer from a handle.
166 * @param hndl Handle_t from which to retrieve contents.
167 * @param err Optional address to store a possible handle error.
168 * @param root If true it will return the root KeyValues pointer for the whole structure.
170 * @return The KeyValues pointer, or NULL for any error encountered.
172 virtual KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false) =0;
175 * @brief Returns the name of the game directory.
177 * @return A string containing the name of the game directory.
179 virtual const char *GetGameFolderName() const =0;
182 * @brief Returns the scripting engine interface.
184 * @return A pointer to the scripting engine interface.
186 virtual SourcePawn::ISourcePawnEngine *GetScriptingEngine() =0;
189 * @brief Returns the JIT interface.
191 * @return A pointer to the JIT interface.
193 virtual SourcePawn::IVirtualMachine *GetScriptingVM() =0;
196 * @brief Returns the adjusted server time.
198 * @return Adjusted server time.
200 virtual time_t GetAdjustedTime() =0;
204 #endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_