3 * ======================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC and authors.
7 * ======================================================
9 * This software is provided 'as-is', without any express or implied warranty.
10 * In no event will the authors be held liable for any damages arising from
11 * the use of this software.
13 * Permission is granted to anyone to use this software for any purpose,
14 * including commercial applications, and to alter it and redistribute it
15 * freely, subject to the following restrictions:
17 * 1. The origin of this software must not be misrepresented; you must not
18 * claim that you wrote the original software. If you use this software in a
19 * product, an acknowledgment in the product documentation would be
20 * appreciated but is not required.
21 * 2. Altered source versions must be plainly marked as such, and must not be
22 * misrepresented as being the original software.
23 * 3. This notice may not be removed or altered from any source distribution.
28 #ifndef _INCLUDE_SOURCEMM_H
29 #define _INCLUDE_SOURCEMM_H
32 * @brief SourceMM main functionality for GameDLL interception
37 #include <interface.h>
39 #include <sourcehook/sourcehook_impl.h>
40 #include <sourcehook/sourcehook.h>
41 #include <ISmmPlugin.h>
42 #include "metamod_provider.h"
43 #include "svn_version.h"
45 using namespace SourceMM;
49 * increase api_major when API breaks
50 * increase api_minor when new functions are added (non-breaking)
52 #define SOURCEMM_VERSION SVN_FILE_VERSION_STRING
53 #define SOURCEMM_DATE __DATE__
54 #define SM_VERS_API_MAJOR 2 //increase this on a breaking change
55 #define SM_VERS_API_MINOR 0 //increase this on a non-breaking API change
57 class MetamodSource : public ISmmAPI
60 void LogMsg(ISmmPlugin *pl, const char *msg, ...);
61 CreateInterfaceFn GetEngineFactory(bool syn=true);
62 CreateInterfaceFn GetPhysicsFactory(bool syn=true);
63 CreateInterfaceFn GetFileSystemFactory(bool syn=true);
64 CreateInterfaceFn GetServerFactory(bool syn=true);
65 CGlobalVars *GetCGlobals();
66 void SetLastMetaReturn(META_RES res);
67 META_RES GetLastMetaReturn();
68 IConCommandBaseAccessor *GetCvarBaseAccessor();
69 bool RegisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
70 void UnregisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand);
71 void ConPrint(const char *str);
72 void ConPrintf(const char *fmt, ...);
73 bool RemotePrintingAvailable();
74 void GetApiVersions(int &major, int &minor, int &plvers, int &plmin);
75 void GetShVersions(int &shvers, int &shimpl);
76 void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener);
77 void *MetaFactory(const char *iface, int *ret, PluginId *id);
78 int FormatIface(char iface[], unsigned int maxlength);
79 void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
80 const char *GetBaseDir();
81 void PathFormat(char *buffer, size_t len, const char *fmt, ...);
82 void ClientConPrintf(edict_t *client, const char *fmt, ...);
83 void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1);
84 void EnableVSPListener();
85 int GetGameDLLVersion();
86 int GetUserMessageCount();
87 int FindUserMessage(const char *name, int *size=NULL);
88 const char *GetUserMessage(int index, int *size=NULL);
90 int GetSourceEngineBuild();
91 IServerPluginCallbacks *GetVSPInfo(int *pVersion);
92 size_t Format(char *buffer, size_t maxlength, const char *format, ...);
93 size_t FormatArgs(char *buffer, size_t maxlength, const char *format, va_list ap);
95 const char *GetGameBinaryPath();
96 const char *GetPluginsFile();
97 void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
98 void NotifyVSPListening(IServerPluginCallbacks *callbacks);
101 void LogMessage(const char *msg, ...);
102 int LoadPluginsFromFile(const char *_file);
104 extern MetamodSource g_Metamod;
105 extern SourceHook::Impl::CSourceHookImpl g_SourceHook;
107 #endif //_INCLUDE_SOURCEMM_H